/** * Make sure that the request sent is correct when appending shipping info. * * @return void */ public function testAddShippingInfo() { $this->mock->addResponse(new Response(204)); $capture = new Capture($this->connector, '/order/0002', '1002'); $capture->addShippingInfo(['data' => 'sent in']); $request = $this->history->getLastRequest(); $this->assertEquals('POST', $request->getMethod()); $this->assertEquals('/order/0002/captures/1002/shipping-info', $request->getPath()); $this->assertEquals('application/json', $request->getHeader('Content-Type')); $this->assertEquals('{"data":"sent in"}', strval($request->getBody())); $this->assertAuthorization($request); }
/** * Make sure an unknown status code response results in an exception. * * @return void */ public function testAddShippingInfoInvalidStatusCode() { $data = ['data' => 'goes here']; $this->connector->expects($this->once())->method('createRequest')->with('/orders/1/captures/2/shipping-info', 'POST', ['json' => $data])->will($this->returnValue($this->request)); $this->connector->expects($this->once())->method('send')->with($this->request)->will($this->returnValue($this->response)); $this->response->expects($this->once())->method('getStatusCode')->will($this->returnValue('200')); $capture = new Capture($this->connector, '/orders/1', '2'); $this->setExpectedException('RuntimeException', 'Unexpected response status code: 200'); $capture->addShippingInfo($data); }