function SearchPageRepositoryTest::testGetIndexableSearchPages

Same name and namespace in other branches
  1. 9 core/modules/search/tests/src/Unit/SearchPageRepositoryTest.php \Drupal\Tests\search\Unit\SearchPageRepositoryTest::testGetIndexableSearchPages()
  2. 8.9.x core/modules/search/tests/src/Unit/SearchPageRepositoryTest.php \Drupal\Tests\search\Unit\SearchPageRepositoryTest::testGetIndexableSearchPages()
  3. 11.x core/modules/search/tests/src/Unit/SearchPageRepositoryTest.php \Drupal\Tests\search\Unit\SearchPageRepositoryTest::testGetIndexableSearchPages()

Tests the getIndexableSearchPages() method.

File

core/modules/search/tests/src/Unit/SearchPageRepositoryTest.php, line 116

Class

SearchPageRepositoryTest
@coversDefaultClass \Drupal\search\SearchPageRepository[[api-linebreak]] @group search

Namespace

Drupal\Tests\search\Unit

Code

public function testGetIndexableSearchPages() : void {
  $this->query
    ->expects($this->once())
    ->method('condition')
    ->with('status', TRUE)
    ->willReturn($this->query);
  $this->query
    ->expects($this->once())
    ->method('execute')
    ->willReturn([
    'test' => 'test',
    'other_test' => 'other_test',
  ]);
  $entities = [];
  $entities['test'] = $this->createMock('Drupal\\search\\SearchPageInterface');
  $entities['test']->expects($this->once())
    ->method('isIndexable')
    ->willReturn(TRUE);
  $entities['other_test'] = $this->createMock('Drupal\\search\\SearchPageInterface');
  $entities['other_test']->expects($this->once())
    ->method('isIndexable')
    ->willReturn(FALSE);
  $this->storage
    ->expects($this->once())
    ->method('loadMultiple')
    ->with([
    'test' => 'test',
    'other_test' => 'other_test',
  ])
    ->willReturn($entities);
  $result = $this->searchPageRepository
    ->getIndexableSearchPages();
  $this->assertCount(1, $result);
  $this->assertSame($entities['test'], reset($result));
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.