|
3 | 3 |
|
4 | 4 | namespace Lcobucci\ContentNegotiation\Tests;
|
5 | 5 |
|
6 |
| -use AssertionError; |
7 | 6 | use Fig\Http\Message\StatusCodeInterface;
|
8 | 7 | use Lcobucci\ContentNegotiation\ContentTypeMiddleware;
|
9 | 8 | use Lcobucci\ContentNegotiation\Formatter;
|
10 | 9 | use Lcobucci\ContentNegotiation\Tests\Formatter\NaiveTemplateEngine;
|
11 | 10 | use Lcobucci\ContentNegotiation\UnformattedResponse;
|
12 |
| -use PHPUnit\Framework\Error\Warning; |
13 | 11 | use PHPUnit\Framework\TestCase;
|
14 | 12 | use Psr\Http\Message\ResponseInterface;
|
15 | 13 | use Psr\Http\Message\ServerRequestInterface;
|
16 | 14 | use Psr\Http\Server\RequestHandlerInterface;
|
17 | 15 | use Zend\Diactoros\Response;
|
18 | 16 | use Zend\Diactoros\Response\EmptyResponse;
|
19 | 17 | use Zend\Diactoros\ServerRequest;
|
| 18 | +use Zend\Diactoros\StreamFactory; |
20 | 19 | use function array_map;
|
21 |
| -use function ini_set; |
22 | 20 |
|
23 | 21 | /**
|
24 | 22 | * @coversDefaultClass \Lcobucci\ContentNegotiation\ContentTypeMiddleware
|
@@ -170,61 +168,6 @@ public function processShouldReturnAResponseWithFormattedContentEvenWithoutForci
|
170 | 168 | self::assertJsonStringEqualsJsonString('{"id":1,"name":"Testing"}', (string) $response->getBody());
|
171 | 169 | }
|
172 | 170 |
|
173 |
| - /** |
174 |
| - * @test |
175 |
| - * |
176 |
| - * @covers ::__construct() |
177 |
| - * @covers ::fromRecommendedSettings() |
178 |
| - * @covers ::process() |
179 |
| - * @covers ::extractContentType() |
180 |
| - * @covers ::formatResponse() |
181 |
| - * |
182 |
| - * @uses \Lcobucci\ContentNegotiation\UnformattedResponse |
183 |
| - * @uses \Lcobucci\ContentNegotiation\Formatter\Json |
184 |
| - */ |
185 |
| - public function processShouldRaiseExceptionWhenInvalidStreamWasCreatedInDevelopmentMode(): void |
186 |
| - { |
187 |
| - ini_set('assert.exception', '1'); |
188 |
| - |
189 |
| - $this->expectException(AssertionError::class); |
190 |
| - $this->processWithInvalidStreamFactory(); |
191 |
| - } |
192 |
| - |
193 |
| - /** |
194 |
| - * @test |
195 |
| - * |
196 |
| - * @covers ::__construct() |
197 |
| - * @covers ::fromRecommendedSettings() |
198 |
| - * @covers ::process() |
199 |
| - * @covers ::extractContentType() |
200 |
| - * @covers ::formatResponse() |
201 |
| - * |
202 |
| - * @uses \Lcobucci\ContentNegotiation\UnformattedResponse |
203 |
| - * @uses \Lcobucci\ContentNegotiation\Formatter\Json |
204 |
| - */ |
205 |
| - public function processShouldRaiseAWarningWhenInvalidStreamWasCreatedInDevelopmentMode(): void |
206 |
| - { |
207 |
| - ini_set('assert.exception', '0'); |
208 |
| - |
209 |
| - $this->expectException(Warning::class); |
210 |
| - $this->processWithInvalidStreamFactory(); |
211 |
| - } |
212 |
| - |
213 |
| - private function processWithInvalidStreamFactory(): void |
214 |
| - { |
215 |
| - $middleware = $this->createMiddleware( |
216 |
| - true, |
217 |
| - static function () { |
218 |
| - return false; |
219 |
| - } |
220 |
| - ); |
221 |
| - |
222 |
| - $middleware->process( |
223 |
| - new ServerRequest(), |
224 |
| - $this->createRequestHandler($this->createResponse()) |
225 |
| - ); |
226 |
| - } |
227 |
| - |
228 | 171 | /**
|
229 | 172 | * @param mixed[] $attributes
|
230 | 173 | */
|
@@ -261,15 +204,15 @@ public function handle(ServerRequestInterface $request): ResponseInterface
|
261 | 204 | };
|
262 | 205 | }
|
263 | 206 |
|
264 |
| - private function createMiddleware(bool $forceCharset = true, ?callable $streamFactory = null): ContentTypeMiddleware |
| 207 | + private function createMiddleware(bool $forceCharset = true): ContentTypeMiddleware |
265 | 208 | {
|
266 | 209 | return ContentTypeMiddleware::fromRecommendedSettings(
|
267 | 210 | $this->configureCharset($forceCharset),
|
268 | 211 | [
|
269 | 212 | 'application/json' => new Formatter\Json(),
|
270 | 213 | 'text/html' => new NaiveTemplateEngine(),
|
271 | 214 | ],
|
272 |
| - $streamFactory |
| 215 | + new StreamFactory() |
273 | 216 | );
|
274 | 217 | }
|
275 | 218 |
|
|
0 commit comments