You are here

public function JsonApiParamEnhancerTest::testApplies in JSON:API 8

@covers ::applies

File

tests/src/Unit/Routing/JsonApiParamEnhancerTest.php, line 31

Class

JsonApiParamEnhancerTest
@coversDefaultClass \Drupal\jsonapi\Routing\JsonApiParamEnhancer @group jsonapi @group jsonapi_param_enhancer @group legacy

Namespace

Drupal\Tests\jsonapi\Unit\Routing

Code

public function testApplies() {
  list($filter_normalizer, $sort_normalizer, $page_normalizer) = $this
    ->getMockNormalizers();
  $object = new JsonApiParamEnhancer($filter_normalizer, $sort_normalizer, $page_normalizer);
  $this
    ->assertTrue($object
    ->applies(new Route('/jsonapi/foo/bar', [
    RouteObjectInterface::CONTROLLER_NAME => Routes::FRONT_CONTROLLER,
    Routes::JSON_API_ROUTE_FLAG_KEY => TRUE,
    Routes::RESOURCE_TYPE_KEY => 'foo--bar',
  ])));
  $this
    ->assertFalse($object
    ->applies(new Route('/llama/foo/bar', [
    RouteObjectInterface::CONTROLLER_NAME => 'failing',
  ])));
}