function InternalEntitiesTest::testRoutes

Same name in other branches
  1. 9 core/modules/jsonapi/tests/src/Functional/InternalEntitiesTest.php \Drupal\Tests\jsonapi\Functional\InternalEntitiesTest::testRoutes()
  2. 8.9.x core/modules/jsonapi/tests/src/Functional/InternalEntitiesTest.php \Drupal\Tests\jsonapi\Functional\InternalEntitiesTest::testRoutes()
  3. 11.x 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 106

Class

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

Namespace

Drupal\Tests\jsonapi\Functional

Code

public function testRoutes() : void {
    // 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());
    }
}

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