| @@ 17-40 (lines=24) @@ | ||
| 14 | ||
| 15 | use Graze\GuzzleHttp\JsonRpc\Test\UnitTestCase; |
|
| 16 | ||
| 17 | class RequestFactoryMiddlewareTest extends UnitTestCase |
|
| 18 | { |
|
| 19 | public function setUp() |
|
| 20 | { |
|
| 21 | $this->request = $this->mockRequest(); |
|
| 22 | $this->response = $this->mockResponse(); |
|
| 23 | $this->factory = $this->mockMessageFactory(); |
|
| 24 | ||
| 25 | $this->middleware = new RequestFactoryMiddleware($this->factory); |
|
| 26 | } |
|
| 27 | ||
| 28 | public function testApplyRequest() |
|
| 29 | { |
|
| 30 | $newRequest = clone $this->request; |
|
| 31 | $this->factory->shouldReceive('fromRequest')->once()->with($this->request)->andReturn($newRequest); |
|
| 32 | ||
| 33 | $this->assertSame($newRequest, $this->middleware->applyRequest($this->request, [])); |
|
| 34 | } |
|
| 35 | ||
| 36 | public function testApplyResponse() |
|
| 37 | { |
|
| 38 | $this->assertSame($this->response, $this->middleware->applyResponse($this->request, $this->response, [])); |
|
| 39 | } |
|
| 40 | } |
|
| 41 | ||
| @@ 17-40 (lines=24) @@ | ||
| 14 | ||
| 15 | use Graze\GuzzleHttp\JsonRpc\Test\UnitTestCase; |
|
| 16 | ||
| 17 | class ResponseFactoryMiddlewareTest extends UnitTestCase |
|
| 18 | { |
|
| 19 | public function setUp() |
|
| 20 | { |
|
| 21 | $this->request = $this->mockRequest(); |
|
| 22 | $this->response = $this->mockResponse(); |
|
| 23 | $this->factory = $this->mockMessageFactory(); |
|
| 24 | ||
| 25 | $this->middleware = new ResponseFactoryMiddleware($this->factory); |
|
| 26 | } |
|
| 27 | ||
| 28 | public function testApplyRequest() |
|
| 29 | { |
|
| 30 | $this->assertSame($this->request, $this->middleware->applyRequest($this->request, [])); |
|
| 31 | } |
|
| 32 | ||
| 33 | public function testApplyResponse() |
|
| 34 | { |
|
| 35 | $newResponse = clone $this->response; |
|
| 36 | $this->factory->shouldReceive('fromResponse')->once()->with($this->response)->andReturn($newResponse); |
|
| 37 | ||
| 38 | $this->assertSame($newResponse, $this->middleware->applyResponse($this->request, $this->response, [])); |
|
| 39 | } |
|
| 40 | } |
|
| 41 | ||