public function FacetapiApiFunctions::testAdapterLoad in Facet API 7
Same name and namespace in other branches
- 7.2 tests/facetapi.test \FacetapiApiFunctions::testAdapterLoad()
Tests the loading of the adapter.
Performs three tests:
- A valid adapter can be loaded.
- An invalid adapter returns FALSE.
- Only one instance per searcher is loaded.
File
- tests/
facetapi.test, line 610 - Tests for the Facet API module.
Class
- FacetapiApiFunctions
- Test cases for low level API functions.
Code
public function testAdapterLoad() {
// Loads a valid adapter.
$adapter1 = facetapi_adapter_load('facetapi_test');
$value = $adapter1 instanceof FacetapiAdapter;
$this
->assertTrue($value, t('FacetapiAdapter object loaded via facetapi_adapter_load().'), 'Facet API');
// Loads an invalid adapter.
$adapter_bad = facetapi_adapter_load('nonsense');
$this
->assertFalse($adapter_bad, t('FacetapiAdapter object loaded via facetapi_adapter_load().'), 'Facet API');
// Sets a semaphore to see if singleton pattern is implemented.\
$adapter1->semaphore = 'test';
$adapter2 = facetapi_adapter_load('facetapi_test');
$value = isset($adapter2->semaphore) && 'test' == $adapter2->semaphore;
$this
->assertTrue($value, t('Singleton pattern implemented by facetapi_adapter_load().'), 'Facet API');
}