function DefaultHtmlRouteProviderTest::providerTestGetCollectionRoute

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

File

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

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 providerTestGetCollectionRoute() {
    $data = [];
    $entity_type1 = $this->getEntityType();
    $entity_type1->hasLinkTemplate('collection')
        ->willReturn(FALSE);
    $data['no_collection_link_template'] = [
        NULL,
        $entity_type1->reveal(),
    ];
    $entity_type2 = $this->getEntityType();
    $entity_type2->hasLinkTemplate('collection')
        ->willReturn(TRUE);
    $entity_type2->hasListBuilderClass()
        ->willReturn(FALSE);
    $data['no_list_builder'] = [
        NULL,
        $entity_type2->reveal(),
    ];
    $entity_type3 = $this->getEntityType($entity_type2);
    $entity_type3->hasListBuilderClass()
        ->willReturn(TRUE);
    $entity_type3->getAdminPermission()
        ->willReturn(FALSE);
    $data['no_admin_permission'] = [
        NULL,
        $entity_type3->reveal(),
    ];
    $entity_type4 = $this->getEntityType($entity_type3);
    $entity_type4->getAdminPermission()
        ->willReturn('administer the entity type');
    $entity_type4->id()
        ->willReturn('the_entity_type_id');
    $entity_type4->getLabel()
        ->willReturn('The entity type');
    $entity_type4->getCollectionLabel()
        ->willReturn(new TranslatableMarkup('Test entities'));
    $entity_type4->getLinkTemplate('collection')
        ->willReturn('/the/collection/link/template');
    $entity_type4->entityClassImplements(FieldableEntityInterface::class)
        ->willReturn(FALSE);
    $route = (new Route('/the/collection/link/template'))->setDefaults([
        '_entity_list' => 'the_entity_type_id',
        '_title' => 'Test entities',
        '_title_arguments' => [],
        '_title_context' => '',
    ])
        ->setRequirements([
        '_permission' => 'administer the entity type',
    ]);
    $data['collection_route'] = [
        clone $route,
        $entity_type4->reveal(),
    ];
    return $data;
}

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