public function SearchPageRepositoryTest::testGetIndexableSearchPages in Drupal 8
Same name and namespace in other branches
- 9 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  - Contains \Drupal\Tests\search\Unit\SearchPageRepositoryTest.
 
Class
- SearchPageRepositoryTest
 - @coversDefaultClass \Drupal\search\SearchPageRepository @group search
 
Namespace
Drupal\Tests\search\UnitCode
public function testGetIndexableSearchPages() {
  $this->query
    ->expects($this
    ->once())
    ->method('condition')
    ->with('status', TRUE)
    ->will($this
    ->returnValue($this->query));
  $this->query
    ->expects($this
    ->once())
    ->method('execute')
    ->will($this
    ->returnValue([
    'test' => 'test',
    'other_test' => 'other_test',
  ]));
  $entities = [];
  $entities['test'] = $this
    ->createMock('Drupal\\search\\SearchPageInterface');
  $entities['test']
    ->expects($this
    ->once())
    ->method('isIndexable')
    ->will($this
    ->returnValue(TRUE));
  $entities['other_test'] = $this
    ->createMock('Drupal\\search\\SearchPageInterface');
  $entities['other_test']
    ->expects($this
    ->once())
    ->method('isIndexable')
    ->will($this
    ->returnValue(FALSE));
  $this->storage
    ->expects($this
    ->once())
    ->method('loadMultiple')
    ->with([
    'test' => 'test',
    'other_test' => 'other_test',
  ])
    ->will($this
    ->returnValue($entities));
  $result = $this->searchPageRepository
    ->getIndexableSearchPages();
  $this
    ->assertCount(1, $result);
  $this
    ->assertSame($entities['test'], reset($result));
}