function AdminRouteSubscriberTest::providerTestAlterRoutes

Same name in other branches
  1. 8.9.x core/modules/system/tests/src/Unit/Routing/AdminRouteSubscriberTest.php \Drupal\Tests\system\Unit\Routing\AdminRouteSubscriberTest::providerTestAlterRoutes()
  2. 10 core/modules/system/tests/src/Unit/Routing/AdminRouteSubscriberTest.php \Drupal\Tests\system\Unit\Routing\AdminRouteSubscriberTest::providerTestAlterRoutes()
  3. 11.x core/modules/system/tests/src/Unit/Routing/AdminRouteSubscriberTest.php \Drupal\Tests\system\Unit\Routing\AdminRouteSubscriberTest::providerTestAlterRoutes()

File

core/modules/system/tests/src/Unit/Routing/AdminRouteSubscriberTest.php, line 31

Class

AdminRouteSubscriberTest
@coversDefaultClass \Drupal\system\EventSubscriber\AdminRouteSubscriber @group system

Namespace

Drupal\Tests\system\Unit\Routing

Code

public function providerTestAlterRoutes() {
    $data = [];
    $data['non-admin'] = [
        new Route('/foo'),
        NULL,
    ];
    $data['admin prefix'] = [
        new Route('/admin/foo'),
        TRUE,
    ];
    $data['admin only'] = [
        new Route('/admin'),
        TRUE,
    ];
    $data['admin in part of a word'] = [
        new Route('/administration/foo'),
        NULL,
    ];
    $data['admin in part of a word with admin_route option'] = [
        (new Route('/administration/foo'))->setOption('_admin_route', TRUE),
        TRUE,
    ];
    $data['admin not at the start of the path'] = [
        new Route('/foo/admin/bar'),
        NULL,
    ];
    $data['admin in part of a word not at the start of the path'] = [
        new Route('/foo/administration/bar'),
        NULL,
    ];
    $data['admin option'] = [
        (new Route('/foo'))->setOption('_admin_route', TRUE),
        TRUE,
    ];
    $data['admin prefix, non-HTML format'] = [
        (new Route('/admin/foo'))->setRequirement('_format', 'json'),
        NULL,
    ];
    $data['admin option, non-HTML format'] = [
        (new Route('/foo'))->setRequirement('_format', 'json')
            ->setOption('_admin_route', TRUE),
        TRUE,
    ];
    $data['admin prefix, HTML format'] = [
        (new Route('/admin/foo'))->setRequirement('_format', 'html'),
        TRUE,
    ];
    $data['admin prefix, multi-format including HTML'] = [
        (new Route('/admin/foo'))->setRequirement('_format', 'json|html'),
        TRUE,
    ];
    return $data;
}

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