Example #1
0
 public function validate(Varien_Object $object)
 {
     if ($object instanceof Rewardpoints_Model_Quote && !$object->getQuote()) {
         $object->setQuote($object);
     }
     $address = $object;
     if (!$address instanceof Mage_Sales_Model_Quote_Address) {
         if ($object->getQuote()->isVirtual()) {
             $address = $object->getQuote()->getBillingAddress();
         } else {
             $address = $object->getQuote()->getShippingAddress();
         }
     }
     $address->setBaseSubtotalIncTax($address->getBaseSubtotal() + $address->getBaseTaxAmount());
     return parent::validate($object);
 }
Example #2
0
 /**
  * @loadFixture ../../../var/fixtures/orders.yaml
  */
 public function testControllerActionCheckoutOnepagePostdispatch()
 {
     $fakeController = new Varien_Object();
     $fakeResponse = new Varien_Object();
     $quotePayment = Mage::getModel('sales/quote_payment')->load(4);
     $pmMock = $this->getModelMock('ops/payment_bankTransfer', array('isAvailable'));
     $pmMock->expects($this->any())->method('isAvailable')->will($this->returnValue(true));
     $quote = $this->getModelMock('sales/quote', array('getPayment'));
     $quote->expects($this->any())->method('getPayment')->will($this->returnValue($quotePayment));
     $quotePayment->setQuote($quote);
     $quote->setPayment($quotePayment);
     $this->replaceByMock('model', 'ops/payment_bankTransfer', $pmMock);
     $fakeOnePage = new Varien_Object();
     $fakeOnePage->setQuote($quote);
     $observerMock = $this->getModelMock('ops/observer', array('getOnepage'));
     $observerMock->expects($this->once())->method('getOnepage')->will($this->returnValue($fakeOnePage));
     $helperMock = $this->getHelperMock('ops/payment_request', array('getOwnerParams', 'extractShipToParameters'));
     $helperMock->expects($this->once())->method('getOwnerParams')->will($this->returnValue(array()));
     $helperMock->expects($this->once())->method('extractShipToParameters')->will($this->returnValue(array()));
     $this->replaceByMock('helper', 'ops/payment_request', $helperMock);
     $validatorMock = $this->getModelMock('ops/validator_parameter_validator', array('isValid', 'getMessages'));
     $validatorMock->expects($this->once())->method('isValid')->will($this->returnValue(false));
     $validatorMock->expects($this->any())->method('getMessages')->will($this->returnValue(array('Foo' => 'Not Valid')));
     $this->replaceByMock('model', 'ops/validator_parameter_validator', $validatorMock);
     $fakeResponse->setBody(Mage::helper('core/data')->jsonEncode(array('error' => false, 'update_section' => 'foo')));
     $fakeController->setResponse($fakeResponse);
     $event = new Varien_Event_Observer();
     $event->setControllerAction($fakeController);
     $observerMock->controllerActionCheckoutOnepagePostdispatch($event);
     $result = Mage::helper('core/data')->jsonDecode($fakeResponse->getBody());
     $this->assertArrayHasKey('error', $result);
     $this->assertArrayHasKey('goto_section', $result);
     $this->assertArrayHasKey('fields', $result);
     $this->assertArrayNotHasKey('update_section', $result);
 }