You are here

public function SearchApiSortsManagerTest::testGetActiveSort in Search API sorts 8

Tests getActiveSort.

@dataProvider provideSortOrders

@covers ::getActiveSort

File

tests/src/Unit/SearchApiSortsManagerTest.php, line 97

Class

SearchApiSortsManagerTest
Tests the sorts manager.

Namespace

Drupal\Tests\search_api_sorts\Unit

Code

public function testGetActiveSort($order_argument, $expected) {
  $this->request->query = new ParameterBag([
    'sort' => 'sort_field',
    'order' => $order_argument,
  ]);
  $this->requestStack
    ->push($this->request);
  $manager = $this->entityTypeManagerProphecy
    ->reveal();
  $searchApiSortsManager = new SearchApiSortsManager($this->requestStack, $manager, $this->moduleHandler, $this->searchApiDisplayManager);
  $sorts = $searchApiSortsManager
    ->getActiveSort($this->display);
  $this
    ->assertEquals('sort_field', $sorts
    ->getFieldName());
  $this
    ->assertEquals($expected, $sorts
    ->getOrder());
}