function SearchPageRepositoryTest::testGetDefaultSearchPageWithActiveDefault

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

Tests the getDefaultSearchPage() method when the default is active.

File

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

Class

SearchPageRepositoryTest
@coversDefaultClass \Drupal\search\SearchPageRepository @group search

Namespace

Drupal\Tests\search\Unit

Code

public function testGetDefaultSearchPageWithActiveDefault() {
    $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',
    ]);
    $config = $this->getMockBuilder('Drupal\\Core\\Config\\Config')
        ->disableOriginalConstructor()
        ->getMock();
    $config->expects($this->once())
        ->method('get')
        ->with('default_page')
        ->willReturn('test');
    $this->configFactory
        ->expects($this->once())
        ->method('get')
        ->with('search.settings')
        ->willReturn($config);
    $this->assertSame('test', $this->searchPageRepository
        ->getDefaultSearchPage());
}

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