コード例 #1
0
 /**
  * @test
  */
 public function shouldRecoverAfterTimeout()
 {
     $model = array('location' => 'theLocation', 'cart' => array('items' => array(array('foo'), array('bar'))));
     $connector = $this->createConnectorMock();
     $connector->expects($this->at(0))->method('apply')->with('POST')->will($this->throwException(new \Klarna_Checkout_ConnectionErrorException()));
     $connector->expects($this->at(1))->method('apply')->with('POST')->will($this->returnCallback(function ($method, $order, $options) use($model) {
         $this->assertInternalType('array', $options);
         $this->assertArrayHasKey('data', $options);
         $this->assertEquals(array('cart' => $model['cart']), $options['data']);
     }));
     $action = new UpdateOrderAction($connector);
     $action->setApi(new Config());
     $action->execute($request = new UpdateOrder($model));
     $this->assertInstanceOf('Klarna_Checkout_Order', $request->getOrder());
 }
コード例 #2
0
 /**
  * @test
  */
 public function shouldReturnSameOrderUsedWhileFetchAndUpdateCallsOnExecute()
 {
     $model = array('location' => 'theKlarnaOrderLocation', 'cart' => array('items' => array(array('foo'), array('bar'))));
     $request = new UpdateOrder($model);
     $testCase = $this;
     $expectedOrder = null;
     $connector = $this->createConnectorMock();
     $connector->expects($this->at(1))->method('apply')->with('GET')->will($this->returnCallback(function ($method, $order, $options) use($testCase, &$expectedOrder) {
         $expectedOrder = $order;
     }));
     $action = new UpdateOrderAction();
     $action->setApi($connector);
     $action->execute($request);
     $this->assertSame($expectedOrder, $request->getOrder());
 }