You are here

public function FacetapiTestCase::facetapiEnableFacetBlock in Facet API 7

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

Enables a facet block via the UI.

2 calls to FacetapiTestCase::facetapiEnableFacetBlock()
FacetapiAdminInterfaceTestCase::testEnableFacet in tests/facetapi.test
Tests enabling a facet via the UI.
FacetapiSearchPageInterfaceTestCase::testFormAccess in tests/facetapi.test

File

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

Class

FacetapiTestCase
Base class for all Facet API test cases.

Code

public function facetapiEnableFacetBlock($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);
  }

  // Generates the "key" via the facetapi_hash_delta() function.
  module_load_include('inc', 'facetapi', 'facetapi.block');
  $detla = facetapi_build_delta($searcher, $realm_name, $facet_name);
  $key = 'facetapi_' . facetapi_hash_delta($detla);

  // Enables the facet in the "sidebar_first" region.
  $edit = array(
    'blocks[' . $key . '][region]' => 'sidebar_first',
  );
  $this
    ->drupalPost('admin/structure/block', $edit, t('Save blocks'));

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