Esempio n. 1
0
 /**
  * @test
  */
 public function shouldRecoverAfterTimeout()
 {
     $model = array('location' => 'theLocation', 'cart' => array('items' => array(array('foo'), array('bar'))));
     $request = new CreateOrder($model);
     $expectedOrder = null;
     $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(&$expectedOrder) {
         $expectedOrder = $order;
     }));
     $action = new CreateOrderAction($connector);
     $action->setApi(new Config());
     $action->execute($request);
     $this->assertSame($expectedOrder, $request->getOrder());
 }
Esempio n. 2
0
 /**
  * @test
  */
 public function shouldReturnSameOrderUsedWhileCreateAndFetchCallsOnExecute()
 {
     $request = new CreateOrder(array());
     $testCase = $this;
     $expectedOrder = null;
     $connector = $this->createConnectorMock();
     $connector->expects($this->at(0))->method('apply')->with('POST')->will($this->returnCallback(function ($method, $order, $options) use($testCase, &$expectedOrder) {
         $expectedOrder = $order;
     }));
     $action = new CreateOrderAction($connector);
     $action->setApi(new Config());
     $action->execute($request);
     $this->assertSame($expectedOrder, $request->getOrder());
 }