public function MessageTest::testCollection in JSON:API 8
Same name and namespace in other branches
- 8.2 tests/src/Functional/MessageTest.php \Drupal\Tests\jsonapi\Functional\MessageTest::testCollection()
Tests GETting a collection of resources.
Overrides ResourceTestBase::testCollection
File
- tests/
src/ Functional/ MessageTest.php, line 166
Class
- MessageTest
- JSON API integration test for the "Message" content entity type.
Namespace
Drupal\Tests\jsonapi\FunctionalCode
public function testCollection() {
$collection_url = Url::fromRoute(sprintf('jsonapi.%s.collection', static::$resourceTypeName))
->setAbsolute(TRUE);
$request_options = [];
$request_options[RequestOptions::HEADERS]['Accept'] = 'application/vnd.api+json';
$request_options = NestedArray::mergeDeep($request_options, $this
->getAuthenticationRequestOptions());
// 405 because Message entities are not stored, so they cannot be retrieved,
// yet the same URL can be used to POST them.
$response = $this
->request('GET', $collection_url, $request_options);
$this
->assertResourceErrorResponse(405, 'No route found for "GET /jsonapi/contact_message/camelids": Method Not Allowed (Allow: POST)', $response);
}