/** * Make sure an unknown status code response results in an exception. * * @return void */ public function testTriggerSendoutInvalidStatusCode() { $this->connector->expects($this->once())->method('createRequest')->with('/orders/1/captures/2/trigger-send-out', 'POST', [])->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->triggerSendout(); }
/** * Fetches the specified capture. * * @param string $captureId Capture ID * * @see Capture::fetch() For more information on how to fetch a capture * * @throws ConnectorException When the API replies with an error response * @throws RequestException When an error is encountered * @throws \RuntimeException On an unexpected API response * @throws \RuntimeException If the response content type is not JSON * @throws \InvalidArgumentException If the JSON cannot be parsed * @throws \LogicException When Guzzle cannot populate the response * * @return Capture */ public function fetchCapture($captureId) { if ($this->offsetExists('captures')) { foreach ($this['captures'] as $capture) { if ($capture->getId() !== $captureId) { continue; } return $capture->fetch(); } } $capture = new Capture($this->connector, $this->getLocation(), $captureId); $capture->fetch(); $this['captures'][] = $capture; return $capture; }
/** * Make sure that the request sent is correct when triggering a send-out. * * @return void */ public function testTriggerSendout() { $this->mock->addResponse(new Response(204)); $capture = new Capture($this->connector, '/order/0002', '1002'); $capture->triggerSendout(); $request = $this->history->getLastRequest(); $this->assertEquals('POST', $request->getMethod()); $this->assertEquals('/order/0002/captures/1002/trigger-send-out', $request->getPath()); $this->assertAuthorization($request); }