Example #1
0
    /**
     * Make sure that the request sent and retrieved data is correct when fetching
     * a capture that is not already in the captures list.
     *
     * @return void
     */
    public function testFetchCaptureNew()
    {
        $json = <<<JSON
{
    "capture_id": "1003",
    "updated": "from json"
}
JSON;
        $this->mock->addResponse(new Response(200, ['Content-Type' => 'application/json'], Stream::factory($json)));
        $order = new Order($this->connector, '0002');
        $capture = new Capture($this->connector, $order->getLocation(), '1002');
        $capture['capture_id'] = '1002';
        $capture['updated'] = 'not from json';
        $order['captures'][] = $capture;
        $capture = $order->fetchCapture('1003');
        $this->assertInstanceOf('Klarna\\Rest\\OrderManagement\\Capture', $capture);
        $this->assertEquals('/ordermanagement/v1/orders/0002/captures/1003', $capture->getLocation());
        $this->assertEquals('from json', $capture['updated']);
        $this->assertEquals('1003', $capture->getId());
        $this->assertEquals($capture->getId(), $capture['capture_id']);
    }
Example #2
0
 /**
  * Make sure the identifier is retrievable.
  *
  * @return void
  */
 public function testGetId()
 {
     $order = new Order($this->connector, '12345');
     $this->assertEquals('12345', $order->getId());
     $this->assertEquals('/ordermanagement/v1/orders/12345', $order->getLocation());
 }