function DefaultHtmlRouteProviderTest::providerTestGetCanonicalRoute

Same name and namespace in other branches
  1. 9 core/tests/Drupal/Tests/Core/Entity/Routing/DefaultHtmlRouteProviderTest.php \Drupal\Tests\Core\Entity\Routing\DefaultHtmlRouteProviderTest::providerTestGetCanonicalRoute()
  2. 10 core/tests/Drupal/Tests/Core/Entity/Routing/DefaultHtmlRouteProviderTest.php \Drupal\Tests\Core\Entity\Routing\DefaultHtmlRouteProviderTest::providerTestGetCanonicalRoute()
  3. 11.x core/tests/Drupal/Tests/Core/Entity/Routing/DefaultHtmlRouteProviderTest.php \Drupal\Tests\Core\Entity\Routing\DefaultHtmlRouteProviderTest::providerTestGetCanonicalRoute()

File

core/tests/Drupal/Tests/Core/Entity/Routing/DefaultHtmlRouteProviderTest.php, line 214

Class

DefaultHtmlRouteProviderTest
@coversDefaultClass <a href="/api/drupal/core%21lib%21Drupal%21Core%21Entity%21Routing%21DefaultHtmlRouteProvider.php/class/DefaultHtmlRouteProvider/8.9.x" title="Provides HTML routes for entities." class="local">\Drupal\Core\Entity\Routing\DefaultHtmlRouteProvider</a> @group Entity

Namespace

Drupal\Tests\Core\Entity\Routing

Code

public function providerTestGetCanonicalRoute() {
    $data = [];
    $entity_type1 = $this->getEntityType();
    $entity_type1->hasLinkTemplate('canonical')
        ->willReturn(FALSE);
    $data['no_canonical_link_template'] = [
        NULL,
        $entity_type1->reveal(),
    ];
    $entity_type2 = $this->getEntityType();
    $entity_type2->hasLinkTemplate('canonical')
        ->willReturn(TRUE);
    $entity_type2->hasViewBuilderClass()
        ->willReturn(FALSE);
    $data['no_view_builder'] = [
        NULL,
        $entity_type2->reveal(),
    ];
    $entity_type3 = $this->getEntityType($entity_type2);
    $entity_type3->hasViewBuilderClass()
        ->willReturn(TRUE);
    $entity_type3->id()
        ->willReturn('the_entity_type_id');
    $entity_type3->getLinkTemplate('canonical')
        ->willReturn('/the/canonical/link/template');
    $entity_type3->entityClassImplements(FieldableEntityInterface::class)
        ->willReturn(FALSE);
    $route = (new Route('/the/canonical/link/template'))->setDefaults([
        '_entity_view' => 'the_entity_type_id.full',
        '_title_callback' => '\\Drupal\\Core\\Entity\\Controller\\EntityController::title',
    ])
        ->setRequirements([
        '_entity_access' => 'the_entity_type_id.view',
    ])
        ->setOptions([
        'parameters' => [
            'the_entity_type_id' => [
                'type' => 'entity:the_entity_type_id',
            ],
        ],
    ]);
    $data['id_key_type_null'] = [
        clone $route,
        $entity_type3->reveal(),
    ];
    $entity_type4 = $this->getEntityType($entity_type3);
    $entity_type4->entityClassImplements(FieldableEntityInterface::class)
        ->willReturn(TRUE);
    $entity_type4->getKey('id')
        ->willReturn('id');
    $route->setRequirement('the_entity_type_id', '\\d+');
    $field_storage_definition = $this->prophesize(FieldStorageDefinitionInterface::class);
    $field_storage_definition->getType()
        ->willReturn('integer');
    $data['id_key_type_integer'] = [
        clone $route,
        $entity_type4->reveal(),
        $field_storage_definition->reveal(),
    ];
    return $data;
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.