You are here

function SearchCommentTest::assertCommentAccess in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 core/modules/search/src/Tests/SearchCommentTest.php \Drupal\search\Tests\SearchCommentTest::assertCommentAccess()

Update search index and search for comment.

1 call to SearchCommentTest::assertCommentAccess()
SearchCommentTest::testSearchResultsCommentAccess in core/modules/search/src/Tests/SearchCommentTest.php
Verify access rules for comment indexing with different permissions.

File

core/modules/search/src/Tests/SearchCommentTest.php, line 294
Contains \Drupal\search\Tests\SearchCommentTest.

Class

SearchCommentTest
Tests integration searching comments.

Namespace

Drupal\search\Tests

Code

function assertCommentAccess($assume_access, $message) {

  // Invoke search index update.
  search_mark_for_reindex('node_search', $this->node
    ->id());
  $this
    ->cronRun();

  // Search for the comment subject.
  $edit = array(
    'keys' => "'" . $this->commentSubject . "'",
  );
  $this
    ->drupalPostForm('search/node', $edit, t('Search'));
  if ($assume_access) {
    $expected_node_result = $this
      ->assertText($this->node
      ->label());
    $expected_comment_result = $this
      ->assertText($this->commentSubject);
  }
  else {
    $expected_node_result = $this
      ->assertText(t('Your search yielded no results.'));
    $expected_comment_result = $this
      ->assertText(t('Your search yielded no results.'));
  }
  $this
    ->assertTrue($expected_node_result && $expected_comment_result, $message);
}