You are here

function SearchByPageNodesTest::testTeaserDisplay in Search by Page 8

Tests that the teaser display option works.

File

tests/src/Functional/search_by_page.test, line 289
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 testTeaserDisplay() {
  $this
    ->drupalLogin($this->superuser);

  // Set display output to display teasers
  $this
    ->drupalPostForm('admin/config/search/search_by_page/edit/' . $this->envid1, array(
    'search_by_page_nodes_display_type' => 'teasers',
  ), 'Save configuration');
  \Drupal::service('cache.bootstrap')
    ->invalidateAll();
  variable_initialize();

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

  // Verify that teasers are displayed instead of excerpts
  $this
    ->assertText('walk', "Walk appears in search results for walk");
  $this
    ->assertNoText('streets', "First page excerpt not displayed");
  $this
    ->assertText('path', "First page teaser displayed");

  // Set display output to display excerpts
  $this
    ->drupalLogin($this->superuser);
  $this
    ->drupalPostForm('admin/config/search/search_by_page/edit/' . $this->envid1, array(
    'search_by_page_nodes_display_type' => 'excerpts',
  ), 'Save configuration');
  \Drupal::service('cache.bootstrap')
    ->invalidateAll();
  variable_initialize();

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

  // Verify that excerpts are displayed instead of teasers
  $this
    ->assertText('walk', "Walk appears in search results for walk");
  $this
    ->assertText('streets', "First page excerpt displayed");
  $this
    ->assertNoText('path', "First page teaser not displayed");
}