Skip to content
This repository was archived by the owner on Jan 29, 2020. It is now read-only.

Commit b061437

Browse files
committed
Test error codes by changing the RuntimeException code
1 parent f3e7b5d commit b061437

File tree

1 file changed

+4
-25
lines changed

1 file changed

+4
-25
lines changed

test/Middleware/WhoopsErrorResponseGeneratorTest.php

Lines changed: 4 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ public function testWritesResultsOfWhoopsExceptionsHandlingToResponse()
7575

7676
public function testAddsRequestMetadataToWhoopsPrettyPageHandler()
7777
{
78-
$error = new RuntimeException();
78+
$error = new RuntimeException('STATUS_INTERNAL_SERVER_ERROR', StatusCode::STATUS_INTERNAL_SERVER_ERROR);
7979

8080
$handler = $this->prophesize(PrettyPageHandler::class);
8181
$handler
@@ -120,7 +120,7 @@ public function testAddsRequestMetadataToWhoopsPrettyPageHandler()
120120

121121
public function testJsonContentTypeResponseWithJsonResponseHandler()
122122
{
123-
$error = new RuntimeException();
123+
$error = new RuntimeException('STATUS_NOT_IMPLEMENTED', StatusCode::STATUS_NOT_IMPLEMENTED);
124124

125125
$handler = $this->prophesize(JsonResponseHandler::class);
126126

@@ -142,8 +142,8 @@ public function testJsonContentTypeResponseWithJsonResponseHandler()
142142
$this->request->getParsedBody()->willReturn([]);
143143

144144
$this->response->withHeader('Content-Type', 'application/json')->will([$this->response, 'reveal']);
145-
$this->response->withStatus(StatusCode::STATUS_IM_A_TEAPOT)->will([$this->response, 'reveal']);
146-
$this->response->getStatusCode()->willReturn(StatusCode::STATUS_IM_A_TEAPOT);
145+
$this->response->withStatus(StatusCode::STATUS_NOT_IMPLEMENTED)->will([$this->response, 'reveal']);
146+
$this->response->getStatusCode()->willReturn(StatusCode::STATUS_NOT_IMPLEMENTED);
147147
$this->response->getBody()->will([$this->stream, 'reveal']);
148148

149149
$this->stream->write('error')->shouldBeCalled();
@@ -155,25 +155,4 @@ public function testJsonContentTypeResponseWithJsonResponseHandler()
155155
$generator($error, $this->request->reveal(), $this->response->reveal())
156156
);
157157
}
158-
159-
public function testNonErrorStatusCodeIsSetTo500()
160-
{
161-
$error = new RuntimeException();
162-
163-
$this->whoops->getHandlers()->willReturn([]);
164-
$this->whoops->handleException($error)->willReturn('WHOOPS');
165-
166-
$this->response->withStatus(StatusCode::STATUS_INTERNAL_SERVER_ERROR)->will([$this->response, 'reveal']);
167-
$this->response->getBody()->will([$this->stream, 'reveal']);
168-
$this->response->getStatusCode()->willReturn(StatusCode::STATUS_MOVED_PERMANENTLY);
169-
170-
$this->stream->write('WHOOPS')->shouldBeCalled();
171-
172-
$generator = new WhoopsErrorResponseGenerator($this->whoops->reveal());
173-
174-
$this->assertSame(
175-
$this->response->reveal(),
176-
$generator($error, $this->request->reveal(), $this->response->reveal())
177-
);
178-
}
179158
}

0 commit comments

Comments
 (0)