You are here

public function FacetapiAdminInterfaceTestCase::testWidgetSelect in Facet API 7.2

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

Tests that an admin can selet a valid widget.

In addition to checking that a valid widget can be selected, it also tests that an invalid widget cannot be selected by choosing one that does not support the "term" query type.

File

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

Class

FacetapiAdminInterfaceTestCase
Test cases for operations taken through the admin UI.

Code

public function testWidgetSelect() {
  $this
    ->drupalLogin($this->adminUser);
  list($facet, $realm, $adapter, $base_path) = $this
    ->facetapiLoadObjects();
  $path = "{$base_path}/edit";

  // Ensure that a valid widget can be selected.
  $this
    ->drupalGet($path);
  $values = array(
    'widget' => 'facetapi_checkbox_links',
  );
  $this
    ->drupalPost($path, $values, t('Save configuration'));
  $settings = $adapter
    ->getFacetSettings($facet, $realm);
  $this
    ->assertEqual($settings->settings['widget'], 'facetapi_checkbox_links', t('The facetapi_checkbox_links widget was successfully selected.'), 'Facet API');

  // Ensure that an invalid widget cannot be selected.
  $this
    ->drupalGet($path);
  $values = array(
    'widget' => 'facetapi_nonterm',
  );
  $this
    ->drupalPost($path, $values, t('Save configuration'));
  $validation_message = t('The widget does not support the %type query type', array(
    '%type' => 'term',
  ));
  $this
    ->assertRaw($validation_message, t('An invalid widget cannot be selected.'), 'Facet API');
  $settings = $adapter
    ->getFacetSettings($facet, $realm);
  $this
    ->assertNotEqual($settings->settings['widget'], 'facetapi_nonterm', t('An invalid widget does not get saved.'), 'Facet API');
}