You are here

public function FacetapiApiFunctions::testHierarchicalRequirements in Facet API 7

Same name and namespace in other branches
  1. 7.2 tests/facetapi.test \FacetapiApiFunctions::testHierarchicalRequirements()

Tests the requirements system for hierarchies.

See also

facetapi_check_requirements()

facetapi_requirement_facet_property_set()

facetapi_requirement_facet_hierarchical()

File

tests/facetapi.test, line 557
Tests for the Facet API module.

Class

FacetapiApiFunctions
Test cases for low level API functions.

Code

public function testHierarchicalRequirements() {
  list($e_facet, $realm, $adapter) = $this
    ->facetapiLoadObjects();
  $h_facet = facetapi_facet_load('hierarchical', 'facetapi_test');

  // Tests facetapi_requirement_facet_hierarchical(). Builds the requirements
  // array for the TRUE and FALSE checks.
  $requirements_t = array(
    'facetapi_requirement_facet_hierarchical' => TRUE,
  );
  $requirements_f = array(
    'facetapi_requirement_facet_hierarchical' => FALSE,
  );
  $passed = facetapi_check_requirements($requirements_t, $realm, $h_facet);
  $this
    ->assertTrue($passed, t('Requirements pass when checking if a hierarchical facet is hierarchical.'), 'Facet API');
  $passed = facetapi_check_requirements($requirements_f, $realm, $h_facet);
  $this
    ->assertFalse($passed, t('Requirements fail when checking if a hierarchical facet is not hierarchical.'), 'Facet API');
  $passed = facetapi_check_requirements($requirements_f, $realm, $e_facet);
  $this
    ->assertTrue($passed, t('Requirements pass when checking if a non-hierarchical facet is not hierarchical.'), 'Facet API');
  $passed = facetapi_check_requirements($requirements_t, $realm, $e_facet);
  $this
    ->assertFalse($passed, t('Requirements fail when checking if a non-hierarchical facet is hierarchical.'), 'Facet API');
}