You are here

public function SearchPageRepositoryTest::testSetDefaultSearchPage in Drupal 9

Same name and namespace in other branches
  1. 8 core/modules/search/tests/src/Unit/SearchPageRepositoryTest.php \Drupal\Tests\search\Unit\SearchPageRepositoryTest::testSetDefaultSearchPage()

Tests the setDefaultSearchPage() method.

File

core/modules/search/tests/src/Unit/SearchPageRepositoryTest.php, line 219
Contains \Drupal\Tests\search\Unit\SearchPageRepositoryTest.

Class

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

Namespace

Drupal\Tests\search\Unit

Code

public function testSetDefaultSearchPage() {
  $id = 'bananas';
  $config = $this
    ->getMockBuilder('Drupal\\Core\\Config\\Config')
    ->disableOriginalConstructor()
    ->getMock();
  $config
    ->expects($this
    ->once())
    ->method('set')
    ->with('default_page', $id)
    ->will($this
    ->returnValue($config));
  $config
    ->expects($this
    ->once())
    ->method('save')
    ->will($this
    ->returnValue($config));
  $this->configFactory
    ->expects($this
    ->once())
    ->method('getEditable')
    ->with('search.settings')
    ->will($this
    ->returnValue($config));
  $search_page = $this
    ->createMock('Drupal\\search\\SearchPageInterface');
  $search_page
    ->expects($this
    ->once())
    ->method('id')
    ->will($this
    ->returnValue($id));
  $search_page
    ->expects($this
    ->once())
    ->method('enable')
    ->will($this
    ->returnValue($search_page));
  $search_page
    ->expects($this
    ->once())
    ->method('save')
    ->will($this
    ->returnValue($search_page));
  $this->searchPageRepository
    ->setDefaultSearchPage($search_page);
}