You are here

public function InternalEntitiesTest::testRoutes in Drupal 9

Same name and namespace in other branches
  1. 8 core/modules/jsonapi/tests/src/Functional/InternalEntitiesTest.php \Drupal\Tests\jsonapi\Functional\InternalEntitiesTest::testRoutes()
  2. 10 core/modules/jsonapi/tests/src/Functional/InternalEntitiesTest.php \Drupal\Tests\jsonapi\Functional\InternalEntitiesTest::testRoutes()

Ensures that internal resources types aren't present in the routes.

File

core/modules/jsonapi/tests/src/Functional/InternalEntitiesTest.php, line 104

Class

InternalEntitiesTest
Makes assertions about the JSON:API behavior for internal entities.

Namespace

Drupal\Tests\jsonapi\Functional

Code

public function testRoutes() {

  // This cannot be in a data provider because it needs values created by the
  // setUp method.
  $paths = [
    'individual' => "/jsonapi/entity_test_no_label/entity_test_no_label/{$this->internalEntity->uuid()}",
    'collection' => "/jsonapi/entity_test_no_label/entity_test_no_label",
    'related' => "/jsonapi/entity_test_no_label/entity_test_no_label/{$this->internalEntity->uuid()}/field_internal",
  ];
  $this
    ->drupalLogin($this->testUser);
  foreach ($paths as $type => $path) {
    $this
      ->drupalGet($path, [
      'Accept' => 'application/vnd.api+json',
    ]);
    $this
      ->assertSame(404, $this
      ->getSession()
      ->getStatusCode());
  }
}