コード例 #1
0
 public function testPaymentCancelled()
 {
     $this->expectsOrderModelCanBeloaded();
     $this->datahelper->expects($this->once())->method("getStatusById")->with(self::TRANSACTION_ID)->will($this->returnValue(array('bank_status' => Mollie_Mpm_Model_Api::STATUS_CANCELLED, 'updated_at' => '2014-04-26')));
     $this->controller->expects($this->once())->method("_restoreCart");
     $this->controller->expects($this->once())->method("_redirect")->with('checkout/onepage/failure', array('_secure' => true));
     $this->controller->_construct();
     $this->controller->returnAction();
 }
コード例 #2
0
 public function testOrderLoadedByIncrementIdIfNoOrderIdInPost()
 {
     $this->expectOrderIdInRequestPresent(FALSE);
     $checkout = $this->getMock("stdClass", array("getLastRealOrderId"));
     $checkout->expects($this->once())->method("getLastRealOrderId")->will($this->returnValue(self::ORDER_INCREMENT_ID));
     $this->controller->expects($this->atLeastOnce())->method("_getCheckout")->will($this->returnValue($checkout));
     $this->order_model->expects($this->once())->method("loadByIncrementId")->with(self::ORDER_INCREMENT_ID)->will($this->throwException(new Test_Exception("STOP", 400)));
     // Stop testing from here on.
     $this->setExpectedException("Test_Exception", "STOP", 400);
     $this->controller->_construct();
     $this->controller->paymentAction();
 }
コード例 #3
0
 public function setUp()
 {
     parent::setUp();
     $this->controller = $this->getMock("Mollie_Mpm_ApiController", array("getRequest", "_showException", "_saveInvoice"), array());
     /**
      * id is passed in from Mollie, must be checked in this code.
      */
     $this->request = $this->getMock("stdClass", array("getParam"));
     $this->request->expects($this->atLeastOnce())->method("getParam")->will($this->onConsecutiveCalls(0, self::TRANSACTION_ID));
     $this->controller->expects($this->any())->method("getRequest")->will($this->returnValue($this->request));
     $this->api_helper = $this->getMock("Mollie_Mpm_Helper_Api", array("getErrorMessage", "checkPayment", "getPaidStatus", "getAmount", "getBankStatus"), array(), "", FALSE);
     $this->data_helper = $this->getMock("stdClass", array("getOrderIdByTransactionId", "getConfig"));
     $this->directory = $this->getMock("stdClass", array("currencyConvert"));
     $this->store = $this->getMock("stdClass", array("getBaseCurrencyCode", "getCurrentCurrencyCode"));
     $this->transaction = $this->getMock("stdClass", array("setTxnType", "setIsClosed", "save"));
     /*
      * Mage::helper() method
      */
     $this->mage->expects($this->any())->method("Helper")->will($this->returnValueMap(array(array("mpm", $this->data_helper), array("mpm/api", $this->api_helper), array("directory", $this->directory))));
     /*
      * Mage::getStore()
      */
     $this->mage->expects($this->any())->method("app")->will($this->returnValue($this->mage));
     $this->mage->expects($this->any())->method("getStore")->will($this->returnValue($this->store));
     $this->store->expects($this->any())->method('getBaseCurrencyCode')->will($this->returnValue('EUR'));
     $this->store->expects($this->any())->method('getCurrentCurrencyCode')->will($this->returnValue('EUR'));
     /*
      * Models.
      */
     $this->payment_model = $this->getMock("Mage_Sales_Model_Order_Payment", array("setMethod", "setTransactionId", "setIsTransactionClosed", "addTransaction", "getTransaction"));
     $this->api_model = $this->getMock("Mollie_Mpm_Model_Api", array("updatePayment"), array(), "", FALSE);
     $this->order_model = $this->getMock("stdClass", array("load"));
     /*
      * Mage::getModel() method
      */
     $this->mage->expects($this->any())->method("getModel")->will($this->returnValueMap(array(array("mpm/api", $this->api_model), array("sales/order", $this->order_model), array("sales/order_payment", $this->payment_model))));
     $this->order = $this->getMock("Mage_Sales_Model_Order", array("getData", "setPayment", "setTotalPaid", "setBaseTotalPaid", "getGrandTotal", "getAllItems", "setState", "sendNewOrderEmail", "setEmailSent", "cancel", "save"));
     $this->order->expects($this->any())->method("setState")->will($this->returnValue($this->order));
 }