Example #1
0
 public function process()
 {
     $this->handleCheckout();
     $redirect = $this->handlePayment();
     $shopModeResponse = new ShopModeResponse(ShopModeResponse::VIEW_MODE_CHECKOUT);
     if (!empty($redirect)) {
         $shopModeResponse->setRedirectUrl($redirect);
     }
     return $shopModeResponse;
 }
Example #2
0
 public function test_exception_occurred()
 {
     // ARRANGE
     $uniqueString = __CLASS__ . '::' . __METHOD__ . '::' . __LINE__;
     $expectedExceptionMsg = 'TEST-CASE-EXCEPTION-' . $uniqueString;
     $expectedException = new TestCaseException($expectedExceptionMsg);
     $errorShopModeStrategy = $this->getErrorShopModeStrategy(array('process' => array($this->once(), $this->throwException($expectedException))));
     /** @var rz_shop_cart_ModuleTest_TestModule $module */
     $module = $this->getModuleMock(null, null, array('getStrategy' => array($this->once(), $errorShopModeStrategy)));
     // ACT
     $actualResponse = $this->callProcessAction($module);
     // ASSERT
     $expectedShopResponse = new ShopModeResponse('showCart');
     $expectedShopResponse->addError($expectedExceptionMsg);
     $this->assertEquals($expectedShopResponse, $actualResponse);
 }
Example #3
0
 public function test_provideUnitData_setValuesFromResponseToUnitContext()
 {
     // ARRANGE
     $uniqueString = __CLASS__ . '::' . __METHOD__ . '::' . __LINE__;
     $expectedViewMode = 'THE-NEW-VIEW-MODE-' . $uniqueString;
     $expectedErrorMsg = 'THE-ERROR-MESSAGE-' . $uniqueString;
     $expectedRedirectUrl = 'THE-REDIRECT-URL-' . $uniqueString;
     $unitId = 'UNIT-ID-' . $uniqueString;
     $unit = $this->createUnit(array('id' => $unitId));
     $shopModeResponse = new ShopModeResponse($expectedViewMode, $expectedRedirectUrl);
     $shopModeResponse->addError($expectedErrorMsg);
     $moduleMock = $this->getModuleMock(null, null, array('processAction' => array($this->once(), $shopModeResponse)));
     // ACT
     $actualProvidedData = $this->provideUnitData($moduleMock, null, $unit);
     // ASSERT
     $expectedUnixContext = array($unitId => array('view' => $expectedViewMode, 'errors' => array($expectedErrorMsg), 'alreadyProcessed' => true));
     $this->assertEquals($expectedUnixContext, $moduleMock->phpunit_getUnitContext());
     $this->assertEquals(array('url' => $expectedRedirectUrl), $actualProvidedData['redirect']);
 }
Example #4
0
 /**
  * @param HeadAPI          $api
  * @param Unit             $unit
  * @param ShopModeResponse $shopModeResponse
  */
 protected function handleShopModeResponse($api, $unit, $shopModeResponse)
 {
     $this->setUnitContext($api, $unit, 'alreadyProcessed', true);
     $this->setUnitContext($api, $unit, 'view', $shopModeResponse->getViewMode());
     $this->addErrorMessageToUnitContext($api, $unit, $shopModeResponse->getErrors());
 }