public function InternalEntitiesTest::testRoutes in JSON:API 8
Same name and namespace in other branches
- 8.2 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 101
Class
- InternalEntitiesTest
- Makes assertions about the JSON API behavior for internal entities.
Namespace
Drupal\Tests\jsonapi\FunctionalCode
public function testRoutes() {
$this
->skipIfIsInternalIsNotSupported();
// This cannot be in a data provider because it needs values created by the
// setUp method.
$paths = [
'individual' => $this
->getIndividual($this->internalEntity),
'collection' => $this
->jsonapiGet("/jsonapi/{$this->internalEntity->getEntityTypeId()}/{$this->internalEntity->bundle()}"),
'related' => $this
->getRelated($this->referencingEntity, 'field_internal'),
];
foreach ($paths as $type => $document) {
$this
->assertSame(404, $document['errors'][0]['status'], "The '{$type}' route should not be available for internal resource types.'");
}
}