public function CollectRoutesTest::testRoutesRequirements in Drupal 9
Same name and namespace in other branches
- 8 core/modules/rest/tests/src/Unit/CollectRoutesTest.php \Drupal\Tests\rest\Unit\CollectRoutesTest::testRoutesRequirements()
- 10 core/modules/rest/tests/src/Unit/CollectRoutesTest.php \Drupal\Tests\rest\Unit\CollectRoutesTest::testRoutesRequirements()
Tests if adding a requirement to a route only modify one route.
File
- core/
modules/ rest/ tests/ src/ Unit/ CollectRoutesTest.php, line 146
Class
- CollectRoutesTest
- Tests the REST export view plugin.
Namespace
Drupal\Tests\rest\UnitCode
public function testRoutesRequirements() {
$this->restExport
->collectRoutes($this->routes);
$requirements_1 = $this->routes
->get('test_1')
->getRequirements();
$requirements_2 = $this->routes
->get('view.test_view.page_1')
->getRequirements();
$this
->assertCount(0, $requirements_1, 'First route has no requirement.');
$this
->assertCount(1, $requirements_2, 'Views route with rest export had the format requirement added.');
// Check auth options.
$auth = $this->routes
->get('view.test_view.page_1')
->getOption('_auth');
$this
->assertCount(1, $auth, 'View route with rest export has an auth option added');
$this
->assertEquals('basic_auth', $auth[0], 'View route with rest export has the correct auth option added');
}