function DefaultHtmlRouteProviderTest::providerTestGetAddPageRoute

Same name in other branches
  1. 8.9.x core/tests/Drupal/Tests/Core/Entity/Routing/DefaultHtmlRouteProviderTest.php \Drupal\Tests\Core\Entity\Routing\DefaultHtmlRouteProviderTest::providerTestGetAddPageRoute()
  2. 10 core/tests/Drupal/Tests/Core/Entity/Routing/DefaultHtmlRouteProviderTest.php \Drupal\Tests\Core\Entity\Routing\DefaultHtmlRouteProviderTest::providerTestGetAddPageRoute()
  3. 11.x 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

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;
}

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