You are here

public function FacetapiApiFunctions::testPropertySetRequirements in Facet API 7

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

Tests the requirements system for property existence.

See also

facetapi_check_requirements()

facetapi_requirement_property_set()

facetapi_requirement_realm_property_set()

facetapi_requirement_facet_property_set()

File

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

Class

FacetapiApiFunctions
Test cases for low level API functions.

Code

public function testPropertySetRequirements() {
  list($facet, $realm, $adapter) = $this
    ->facetapiLoadObjects();
  $requirements = array(
    'facetapi_requirement_facet_property_set' => array(
      'label' => TRUE,
    ),
  );
  $passed = facetapi_check_requirements($requirements, $realm, $facet);
  $this
    ->assertTrue($passed, t('Requirements pass when an existing facet property is required to be set.'), 'Facet API');
  $requirements = array(
    'facetapi_requirement_facet_property_set' => array(
      'label' => FALSE,
    ),
  );
  $passed = facetapi_check_requirements($requirements, $realm, $facet);
  $this
    ->assertFalse($passed, t('Requirements fail when an existing facet property is required to not be set.'), 'Facet API');
  $requirements = array(
    'facetapi_requirement_facet_property_set' => array(
      'nonsense' => FALSE,
    ),
  );
  $passed = facetapi_check_requirements($requirements, $realm, $facet);
  $this
    ->assertTrue($passed, t('Requirements pass when a non-existent facet property is required not to be set.'), 'Facet API');
  $requirements = array(
    'facetapi_requirement_facet_property_set' => array(
      'nonsense' => TRUE,
    ),
  );
  $passed = facetapi_check_requirements($requirements, $realm, $facet);
  $this
    ->assertFalse($passed, t('Requirements fail when a facet property that is not set is required.'), 'Facet API');
  $requirements = array(
    'facetapi_requirement_realm_property_set' => array(
      'label' => TRUE,
    ),
  );
  $passed = facetapi_check_requirements($requirements, $realm, $facet);
  $this
    ->assertTrue($passed, t('Requirements pass when an existing realm property is required to be set.'), 'Facet API');
  $requirements = array(
    'facetapi_requirement_realm_property_set' => array(
      'label' => FALSE,
    ),
  );
  $passed = facetapi_check_requirements($requirements, $realm, $facet);
  $this
    ->assertFalse($passed, t('Requirements fail when an existing realm property is required to not be set.'), 'Facet API');
  $requirements = array(
    'facetapi_requirement_realm_property_set' => array(
      'nonsense' => FALSE,
    ),
  );
  $passed = facetapi_check_requirements($requirements, $realm, $facet);
  $this
    ->assertTrue($passed, t('Requirements pass when a non-existent realm property is required not to be set.'), 'Facet API');
  $requirements = array(
    'facetapi_requirement_realm_property_set' => array(
      'nonsense' => TRUE,
    ),
  );
  $passed = facetapi_check_requirements($requirements, $realm, $facet);
  $this
    ->assertFalse($passed, t('Requirements fail when a realm property that is not set is required.'), 'Facet API');
}