public function SearchApiSortsManagerTest::testGetEnabledSorts in Search API sorts 8
Tests getEnabledSorts.
@covers ::getEnabledSorts
File
- tests/
src/ Unit/ SearchApiSortsManagerTest.php, line 114
Class
- SearchApiSortsManagerTest
- Tests the sorts manager.
Namespace
Drupal\Tests\search_api_sorts\UnitCode
public function testGetEnabledSorts() {
$this->requestStack
->push($this->request);
$sortsField = new SearchApiSortsField([
'id' => $this
->randomMachineName(),
], 'search_api_sorts_field');
$storage = $this
->getMockBuilder(EntityStorageInterface::class)
->disableOriginalConstructor()
->getMock();
$storage
->expects($this
->once())
->method('loadByProperties')
->willReturn($sortsField);
try {
$this->entityTypeManagerProphecy
->getStorage('search_api_sorts_field')
->willReturn($storage);
} catch (InvalidPluginDefinitionException $e) {
$this
->fail("search_api_sorts storage not found.");
}
$manager = $this->entityTypeManagerProphecy
->reveal();
$searchApiSortsManager = new SearchApiSortsManager($this->requestStack, $manager, $this->moduleHandler, $this->searchApiDisplayManager);
$enabledSorts = $searchApiSortsManager
->getEnabledSorts($this->display);
$this
->assertEquals($sortsField, $enabledSorts);
}