diff --git a/core/modules/rest/tests/modules/rest_test/rest_test.services.yml b/core/modules/rest/tests/modules/rest_test/rest_test.services.yml new file mode 100644 index 0000000..40b5002 --- /dev/null +++ b/core/modules/rest/tests/modules/rest_test/rest_test.services.yml @@ -0,0 +1,5 @@ +services: + rest_test.format_provider: + class: Drupal\rest_test\EventSubscriber\FormatProvider + tags: + - { name: event_subscriber } diff --git a/core/modules/rest/tests/modules/rest_test/src/EventSubscriber/FormatProvider.php b/core/modules/rest/tests/modules/rest_test/src/EventSubscriber/FormatProvider.php new file mode 100644 index 0000000..ac6f237 --- /dev/null +++ b/core/modules/rest/tests/modules/rest_test/src/EventSubscriber/FormatProvider.php @@ -0,0 +1,31 @@ +getRequest()->setFormat('foobar', ['text/foobar']); + } + + /** + * {@inheritdoc} + */ + static function getSubscribedEvents() { + $events[KernelEvents::REQUEST][] = ['onKernelRequest']; + return $events; + } +} diff --git a/core/modules/rest/tests/src/Functional/EntityResource/EntityResourceTestBase.php b/core/modules/rest/tests/src/Functional/EntityResource/EntityResourceTestBase.php index 483923e..f2ed502 100644 --- a/core/modules/rest/tests/src/Functional/EntityResource/EntityResourceTestBase.php +++ b/core/modules/rest/tests/src/Functional/EntityResource/EntityResourceTestBase.php @@ -601,15 +601,15 @@ public function testPost() { $this->assertAuthenticationEdgeCases('POST', $url, $request_options); - // $request_options[RequestOptions::HEADERS]['Content-Type'] = 'text/xml'; + $request_options[RequestOptions::HEADERS]['Content-Type'] = 'text/foobar'; // DX: 415 when request body in existing but not allowed format. - // $response = $this->request('POST', $url, $request_options); + $response = $this->request('POST', $url, $request_options); // @todo Update this in https://www.drupal.org/node/2826407. Also move it // higher, before the "no request body" test. That's impossible right now, // because the format validation happens too late. - // $this->assertResourceErrorResponse(415, '', $response); + $this->assertResourceErrorResponse(415, '', $response); $request_options[RequestOptions::HEADERS]['Content-Type'] = static::$mimeType; @@ -809,15 +809,15 @@ public function testPatch() { $this->assertAuthenticationEdgeCases('PATCH', $url, $request_options); - // $request_options[RequestOptions::HEADERS]['Content-Type'] = 'text/xml'; + $request_options[RequestOptions::HEADERS]['Content-Type'] = 'text/foobar'; // DX: 415 when request body in existing but not allowed format. - // $response = $this->request('PATCH', $url, $request_options); + $response = $this->request('PATCH', $url, $request_options); // @todo Update this in https://www.drupal.org/node/2826407. Also move it // higher, before the "no request body" test. That's impossible right now, // because the format validation happens too late. - // $this->assertResourceErrorResponse(415, '', $response); + $this->assertResourceErrorResponse(415, '', $response); $request_options[RequestOptions::HEADERS]['Content-Type'] = static::$mimeType;