@@ -56,7 +56,7 @@ public function testDoesNothingWhenMediaTypeIsSupported(): void
5656 $ request = new Request ();
5757 $ request ->attributes ->set ('supported_media_types ' , ['json ' , 'xml ' ]);
5858 $ request ->headers = new HeaderBag ([
59- 'Content-Type ' => 'application/vnd.ibexa.api.ContentCreate+json ' ,
59+ 'Accept ' => 'application/vnd.ibexa.api.ContentCreate+json ' ,
6060 ]);
6161
6262 $ subscriber = new SupportedMediaTypesSubscriber ();
@@ -67,12 +67,12 @@ public function testDoesNothingWhenMediaTypeIsSupported(): void
6767 self ::expectNotToPerformAssertions ();
6868 }
6969
70- public function testThrowsExceptionWhenContentTypeHeaderTypeIsNotSupported (): void
70+ public function testThrowsExceptionWhenHeaderTypeIsNotSupported (): void
7171 {
7272 $ request = new Request ();
7373 $ request ->attributes ->set ('supported_media_types ' , ['json ' ]);
7474 $ request ->headers = new HeaderBag ([
75- 'Content-Type ' => 'application/vnd.ibexa.api.ContentCreate+xml ' ,
75+ 'Accept ' => 'application/vnd.ibexa.api.ContentCreate+xml ' ,
7676 ]);
7777
7878 $ subscriber = new SupportedMediaTypesSubscriber ();
@@ -87,7 +87,7 @@ public function testThrowsExceptionWhenUnknownMediaTypeIsUsed(): void
8787 $ request = new Request ();
8888 $ request ->attributes ->set ('supported_media_types ' , ['yaml ' ]);
8989 $ request ->headers = new HeaderBag ([
90- 'Content-Type ' => 'application/vnd.ibexa.api.ContentCreate+unknown ' ,
90+ 'Accept ' => 'application/vnd.ibexa.api.ContentCreate+unknown ' ,
9191 ]);
9292
9393 $ subscriber = new SupportedMediaTypesSubscriber ();
@@ -96,4 +96,20 @@ public function testThrowsExceptionWhenUnknownMediaTypeIsUsed(): void
9696 $ this ->expectException (UnsupportedMediaTypeHttpException::class);
9797 $ subscriber ->allowOnlySupportedMediaTypes ($ event );
9898 }
99+
100+ public function testApplicationJsonHeaderIsSupported (): void
101+ {
102+ $ request = new Request ();
103+ $ request ->attributes ->set ('supported_media_types ' , ['json ' ]);
104+ $ request ->headers = new HeaderBag ([
105+ 'Accept ' => 'application/json ' ,
106+ ]);
107+
108+ $ subscriber = new SupportedMediaTypesSubscriber ();
109+ $ event = new RequestEvent ($ this ->kernel , $ request , HttpKernelInterface::MAIN_REQUEST );
110+
111+ $ subscriber ->allowOnlySupportedMediaTypes ($ event );
112+
113+ self ::expectNotToPerformAssertions ();
114+ }
99115}
0 commit comments