You are here

public function CollectRoutesTest::testRoutesRequirements in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 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 132
Contains \Drupal\Tests\rest\Unit\CollectRoutesTest.

Class

CollectRoutesTest
Tests the REST export view plugin.

Namespace

Drupal\Tests\rest\Unit

Code

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
    ->assertEquals(count($requirements_1), 0, 'First route has no requirement.');
  $this
    ->assertEquals(count($requirements_2), 2, 'Views route with rest export had the format and method requirements added.');
}