function DefaultHtmlRouteProviderTest::providerTestGetAddPageRoute

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

Class

DefaultHtmlRouteProviderTest
@coversDefaultClass \Drupal\Core\Entity\Routing\DefaultHtmlRouteProvider @group Entity

Namespace

Drupal\Tests\Core\Entity\Routing

Code

public static function providerTestGetAddPageRoute() {
    $data = [];
    $entity_type1 = static::getEntityType();
    $entity_type1->hasLinkTemplate('add-page')
        ->willReturn(FALSE);
    $data['no_add_page_link_template'] = [
        NULL,
        $entity_type1->reveal(),
    ];
    $entity_type2 = static::getEntityType();
    $entity_type2->hasLinkTemplate('add-page')
        ->willReturn(TRUE);
    $entity_type2->getKey('bundle')
        ->willReturn(NULL);
    $data['no_bundle'] = [
        NULL,
        $entity_type2->reveal(),
    ];
    $entity_type3 = static::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.