You are here

public function InternalEntitiesTest::testRoutes in JSON:API 8.2

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

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

File

tests/src/Functional/InternalEntitiesTest.php, line 99

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());
  }
}