You are here

function SearchByPageNodesTest::testSearchExclude in Search by Page 8

Tests that the excluded tag is excluded from search.

File

tests/src/Functional/search_by_page.test, line 341
Tests for the Search by Page module. By Jennifer Hodgdon of Poplar ProductivityWare, www.poplarware.com

Class

SearchByPageNodesTest
Functionality tests for Search by Page Nodes.

Namespace

Drupal\Tests\search_by_page\Functional

Code

function testSearchExclude() {

  // Make sure to use environment 1, since that has the exclude tags.
  $search_path = $this->envinfo1['page_path'];
  $excluded = search_by_page_setting_get('exclude_tags', $this->envid1, '');
  $this
    ->assertEqual($excluded, 'tagtoexclude', 'Correct tag is marked excluded');
  $this
    ->drupalLogin($this->privuser);

  // Search for the word 'walk'.
  $this
    ->drupalPostForm($search_path, array(
    'keys' => 'walk',
  ), t('Search pages'));

  // Verify that the "excluded" page doesn't show up.
  $this
    ->assertNoText($this->exclnodetitle, "Excluded node was not found in search for walk");
  $this
    ->assertNoText('gobble', "Gobble is not shown on the page in search for walk");

  // Search for the word 'gobble'
  $this
    ->drupalPostForm($search_path, array(
    'keys' => 'gobble',
  ), t('Search pages'));

  // Verify that the "excluded" page does show up, but not with the word walk showing.
  $this
    ->assertText($this->exclnodetitle, "Excluded node was found in search for gobble");
  $this
    ->assertNoText('walk', "Walk is not shown on the page");
}