function CtoolsUnitObjectCachePlugins::assertValidCachePlugin

Check that the supplied array looks like a ctools cache plugin.

Parameters

mixed $p: The value to check.

string $msg: Prefix of the assertion message.

2 calls to CtoolsUnitObjectCachePlugins::assertValidCachePlugin()
CtoolsUnitObjectCachePlugins::testFindExportUICachePlugin in tests/object_cache_unit.test
Test to see that we can find the standard export_ui plugin.
CtoolsUnitObjectCachePlugins::testFindSimpleCachePlugin in tests/object_cache_unit.test
Test to see that we can find the standard simple plugin.

File

tests/object_cache_unit.test, line 36

Class

CtoolsUnitObjectCachePlugins
Test ctools_cache_find_plugin and the structure of the default cache plugins.

Code

public function assertValidCachePlugin($p, $msg) {
    $this->assertTrue(is_array($p), $msg . ': plugin is an array');
    $this->assertEqual($p['plugin type'], 'cache', $msg . ': type is cache');
    $this->assertTrue(array_key_exists('title', $p), $msg . ': title element exists');
    $this->assertTrue(!empty($p['title']) && is_string($p['title']), $msg . ': title is a string');
    $this->assertTrue(array_key_exists('cache get', $p), $msg . ': has a get function');
    $this->assertTrue(!empty($p['cache get']) && is_callable($p['cache get']), $msg . ': get is executable');
    $this->assertTrue(array_key_exists('cache set', $p), $msg . ': has a set function');
    $this->assertTrue(!empty($p['cache set']) && is_callable($p['cache set']), $msg . ': set is executable');
    // @todo Clear is required by the spec (cache.inc:40..48): but export_ui
    // cache doesn't implement it. Enable the assertions when that problem is
    // solved.
    // $this->assertTrue(array_key_exists('cache clear', $p), $msg . ': has a clear function');
    // $this->assertTrue(is_callable($p['cache clear']), $msg . ': clear is executable');
    // @todo Break is optional acc'd to spec but does anything implement it?
    $this->assertTrue(!array_key_exists('cache break', $p) || is_callable($p['cache break']), $msg . ': break is executable');
    // @todo Finalize is optional so don't fail if not there??
    $this->assertTrue(!array_key_exists('cache finalize', $p) || is_callable($p['cache finalize']), $msg . ': finalize is executable');
}