You are here

function PrivateTest::checkSearchResults in Private 8

Same name and namespace in other branches
  1. 8.2 src/Tests/PrivateTest.php \Drupal\private_content\Tests\PrivateTest::checkSearchResults()

On the search page, search for a string and assert the expected number of results.

Parameters

$search_query: String to search for

$expected_result_count: Expected result count

1 call to PrivateTest::checkSearchResults()
PrivateTest::testNodeAccessBasic in src/Tests/PrivateTest.php
Test the "private" node access.

File

src/Tests/PrivateTest.php, line 156

Class

PrivateTest
Tests the private module.

Namespace

Drupal\private_content\Tests

Code

function checkSearchResults($search_query, $expected_result_count) {
  $this
    ->drupalPostForm('search/node', array(
    'keys' => $search_query,
  ), 'Search');
  $search_results = $this
    ->xpath("//ol[contains(@class, 'search-results')]/li");
  $this
    ->assertEqual(count($search_results), $expected_result_count, t('Found the expected number of search results'));
}