public function MessageTest::testCollection in Drupal 9
Same name and namespace in other branches
- 8 core/modules/jsonapi/tests/src/Functional/MessageTest.php \Drupal\Tests\jsonapi\Functional\MessageTest::testCollection()
Tests GETting a collection of resources.
Overrides ResourceTestBase::testCollection
File
- core/
modules/ jsonapi/ tests/ src/ Functional/ MessageTest.php, line 176
Class
- MessageTest
- JSON:API integration test for the "Message" content entity type.
Namespace
Drupal\Tests\jsonapi\FunctionalCode
public function testCollection() {
$collection_url = Url::fromRoute('jsonapi.contact_message--camelids.collection.post')
->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
->assertSame(405, $response
->getStatusCode());
$this
->assertSame([
'POST',
], $response
->getHeader('Allow'));
}