You are here

public function FacetapiTestCase::facetapiEnableFacet in Facet API 7.2

Same name and namespace in other branches
  1. 7 tests/facetapi.test \FacetapiTestCase::facetapiEnableFacet()

Enables a facet via the UI.

3 calls to FacetapiTestCase::facetapiEnableFacet()
FacetapiAdminInterfaceTestCase::testEnableFacet in tests/facetapi.test
Tests enabling a facet via the UI.
FacetapiBugFixTestCase::testEnableFacetWithColon in tests/facetapi.test
Tests bug fixed at http://drupal.org/node/1209490.
FacetapiSearchPageInterfaceTestCase::testFormAccess in tests/facetapi.test

File

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

Class

FacetapiTestCase
Base class for all Facet API test cases.

Code

public function facetapiEnableFacet($facet_name = 'enabled', $realm_name = 'block', $searcher = 'facetapi_test') {

  // Capture current user, switch to admin user if necessary.
  $account = $this->loggedInUser;
  if ($account != $this->adminUser) {
    $this
      ->drupalLogin($this->adminUser);
  }

  // Posts the form, ensures it was successfully submitted.
  $path = 'admin/config/search/facetapi_test/facets/' . $realm_name;
  $values = array(
    'enabled_facets[' . $facet_name . ']' => $facet_name,
  );
  $this
    ->drupalPost($path, $values, t('Save configuration'));
  $this
    ->assertRaw(t('The configuration options have been saved.'), t('Facet form successfully submitted.'), 'Facet API');

  // Test that the facet was successfully enabled.
  $value = facetapi_facet_enabled($searcher, $realm_name, $facet_name);
  $this
    ->assertTrue($value, t('Facet enabled via the interface.'), 'Facet API');

  // Log back in as original user if necessary.
  if ($account != $this->adminUser) {
    if ($account) {
      $this
        ->drupalLogin($account);
    }
    else {
      $this
        ->drupalLogout();
    }
  }
}