You are here

public function DefaultHtmlRouteProviderTest::providerTestGetAddPageRoute in Drupal 9

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

File

core/tests/Drupal/Tests/Core/Entity/Routing/DefaultHtmlRouteProviderTest.php, line 71
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 providerTestGetAddPageRoute() {
  $data = [];
  $entity_type1 = $this
    ->getEntityType();
  $entity_type1
    ->hasLinkTemplate('add-page')
    ->willReturn(FALSE);
  $data['no_add_page_link_template'] = [
    NULL,
    $entity_type1
      ->reveal(),
  ];
  $entity_type2 = $this
    ->getEntityType();
  $entity_type2
    ->hasLinkTemplate('add-page')
    ->willReturn(TRUE);
  $entity_type2
    ->getKey('bundle')
    ->willReturn(NULL);
  $data['no_bundle'] = [
    NULL,
    $entity_type2
      ->reveal(),
  ];
  $entity_type3 = $this
    ->getEntityType();
  $entity_type3
    ->hasLinkTemplate('add-page')
    ->willReturn(TRUE);
  $entity_type3
    ->getLinkTemplate('add-page')
    ->willReturn('/the/add/page/link/template');
  $entity_type3
    ->id()
    ->willReturn('the_entity_type_id');
  $entity_type3
    ->getKey('bundle')
    ->willReturn('type');
  $route = new Route('/the/add/page/link/template');
  $route
    ->setDefaults([
    '_controller' => 'Drupal\\Core\\Entity\\Controller\\EntityController::addPage',
    '_title_callback' => 'Drupal\\Core\\Entity\\Controller\\EntityController::addTitle',
    'entity_type_id' => 'the_entity_type_id',
  ]);
  $route
    ->setRequirement('_entity_create_any_access', 'the_entity_type_id');
  $data['add_page'] = [
    clone $route,
    $entity_type3
      ->reveal(),
  ];
  return $data;
}