function SearchCommentTest::assertCommentAccess

Update search index and search for comment.

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

File

drupal/core/modules/search/lib/Drupal/search/Tests/SearchCommentTest.php, line 194
Definition of Drupal\search\Tests\SearchCommentTest.

Class

SearchCommentTest
Test integration searching comments.

Namespace

Drupal\search\Tests

Code

function assertCommentAccess($assume_access, $message) {

  // Invoke search index update.
  search_touch_node($this->node->nid);
  $this
    ->cronRun();

  // Search for the comment subject.
  $edit = array(
    'search_block_form' => "'" . $this->comment_subject . "'",
  );
  $this
    ->drupalPost('', $edit, t('Search'));
  if ($assume_access) {
    $expected_node_result = $this
      ->assertText($this->node
      ->label());
    $expected_comment_result = $this
      ->assertText($this->comment_subject);
  }
  else {
    $expected_node_result = $this
      ->assertNoText($this->node
      ->label());
    $expected_comment_result = $this
      ->assertNoText($this->comment_subject);
  }
  $this
    ->assertTrue($expected_node_result && $expected_comment_result, $message);
}