function DefaultHtmlRouteProviderTest::providerTestGetCollectionRoute

Same name in other branches
  1. 8.9.x 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 \Drupal\Core\Entity\Routing\DefaultHtmlRouteProvider @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.