|
10 | 10 | namespace ZendTest\Expressive\Middleware; |
11 | 11 |
|
12 | 12 | use Fig\Http\Message\StatusCodeInterface as StatusCode; |
| 13 | +use InvalidArgumentException; |
13 | 14 | use PHPUnit\Framework\TestCase; |
14 | 15 | use Prophecy\Prophecy\ObjectProphecy; |
15 | 16 | use Psr\Http\Message\ResponseInterface; |
16 | 17 | use Psr\Http\Message\ServerRequestInterface; |
17 | 18 | use Psr\Http\Message\StreamInterface; |
18 | 19 | use RuntimeException; |
| 20 | +use stdClass; |
19 | 21 | use Whoops\Handler\JsonResponseHandler; |
20 | 22 | use Whoops\Handler\PrettyPageHandler; |
21 | 23 | use Whoops\Run; |
@@ -160,4 +162,30 @@ public function testJsonContentTypeResponseWithJsonResponseHandler() |
160 | 162 | $generator($error, $this->request->reveal(), $this->response->reveal()) |
161 | 163 | ); |
162 | 164 | } |
| 165 | + |
| 166 | + public function testThrowsInvalidArgumentExceptionOnNonRunForObject() |
| 167 | + { |
| 168 | + $whoops = new stdClass(); |
| 169 | + |
| 170 | + $this->expectException(InvalidArgumentException::class); |
| 171 | + $this->expectExceptionMessage( |
| 172 | + 'Zend\Expressive\Middleware\WhoopsErrorResponseGenerator expects a Whoops\Run' |
| 173 | + . ' or Whoops\RunInterface instance; received stdClass' |
| 174 | + ); |
| 175 | + |
| 176 | + new WhoopsErrorResponseGenerator($whoops); |
| 177 | + } |
| 178 | + |
| 179 | + public function testThrowsInvalidArgumentExceptionOnNonRunForScalar() |
| 180 | + { |
| 181 | + $whoops = 'foo'; |
| 182 | + |
| 183 | + $this->expectException(InvalidArgumentException::class); |
| 184 | + $this->expectExceptionMessage( |
| 185 | + 'Zend\Expressive\Middleware\WhoopsErrorResponseGenerator expects a Whoops\Run' |
| 186 | + . ' or Whoops\RunInterface instance; received string' |
| 187 | + ); |
| 188 | + |
| 189 | + new WhoopsErrorResponseGenerator($whoops); |
| 190 | + } |
163 | 191 | } |
0 commit comments