You are here

public function DefaultHtmlRouteProviderTest::testGetCanonicalRoute in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 core/tests/Drupal/Tests/Core/Entity/Routing/DefaultHtmlRouteProviderTest.php \Drupal\Tests\Core\Entity\Routing\DefaultHtmlRouteProviderTest::testGetCanonicalRoute()

@covers ::getCanonicalRoute @dataProvider providerTestGetCanonicalRoute

File

core/tests/Drupal/Tests/Core/Entity/Routing/DefaultHtmlRouteProviderTest.php, line 65
Contains \Drupal\Tests\Core\Entity\Routing\DefaultHtmlRouteProviderTest.

Class

DefaultHtmlRouteProviderTest
@coversDefaultClass \Drupal\Core\Entity\Routing\DefaultHtmlRouteProvider @group Entity

Namespace

Drupal\Tests\Core\Entity\Routing

Code

public function testGetCanonicalRoute($entity_type_prophecy, $expected, $field_storage_definition = NULL) {
  $entity_manager = $this
    ->prophesize(EntityManagerInterface::class);
  $route_provider = new TestDefaultHtmlRouteProvider($entity_manager
    ->reveal());
  $entity_type = $entity_type_prophecy
    ->reveal();
  if ($field_storage_definition) {
    $entity_manager
      ->getFieldStorageDefinitions($entity_type
      ->id())
      ->willReturn([
      $entity_type
        ->getKey('id') => $field_storage_definition,
    ]);
  }
  $route = $route_provider
    ->getCanonicalRoute($entity_type);
  $this
    ->assertEquals($expected, $route);
}