public function setUp()
 {
     parent::setUp();
     $this->data_helper = $this->getMock("stdClass", array("getConfig"));
     $this->api_helper = $this->getMock("Mollie_Mpm_Helper_Api", array("createPayment", "getTransactionId", "getPaymentURL"), array(), "", FALSE);
     /*
      * Mage::helper() method
      */
     $this->mage->expects($this->any())->method("Helper")->will($this->returnValueMap(array(array("mpm/data", $this->data_helper), array("mpm/api", $this->api_helper))));
     $this->controller = $this->getMock("Mollie_Mpm_ApiController", array("getRequest", "_redirectUrl", "_showException", "_getCheckout"), array());
     /**
      * transaction_id is passed in from Mollie, must be checked in this code.
      */
     $this->request = $this->getMock("stdClass", array("getParam", "isPost", "getPost"));
     $this->controller->expects($this->any())->method("getRequest")->will($this->returnValue($this->request));
     $this->request->expects($this->any())->method("isPost")->will($this->returnValue(true));
     /*
      * Models.
      */
     $this->payment_model = $this->getMock("Mage_Sales_Model_Order_Payment", array("setMethod", "setTransactionId", "setIsTransactionClosed", "addTransaction"));
     $this->api_model = $this->getMock("Mollie_Mpm_Model_Api", array("setPayment"), array(), "", FALSE);
     $this->order_model = $this->getMock("Mage_Sales_Model_Order", array("load", "loadByIncrementId", "save", "setState", "getId", "getIncrementId", "setPayment", "getBaseGrandTotal", "getGrandTotal", "getBaseCurrencyCode", "getOrderCurrencyCode"));
     $this->order_model->expects($this->any())->method("getId")->will($this->returnValue(self::ORDER_ID));
     $this->order_model->expects($this->any())->method("getIncrementId")->will($this->returnValue(self::ORDER_INCREMENT_ID));
     $this->order_model->expects($this->any())->method("getOrderCurrencyCode")->will($this->returnValue('EUR'));
     /*
      * 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))));
 }
Exemple #2
0
 public function setUp()
 {
     parent::setUp();
     $this->datahelper = $this->getMock("Mollie_Mpm_Helper_Data", array("getConfig"));
     $this->apihelper = $this->getMock("Mollie_Mpm_Helper_Api", array("createPayment", "getTransactionId", "getPaymentURL"), array(), "", FALSE);
     /*
      * Mage::Helper() method
      */
     $this->mage->expects($this->any())->method("Helper")->will($this->returnValueMap(array(array("mpm", $this->datahelper), array("mpm/api", $this->apihelper))));
     $this->resource = $this->getMock("stdClass", array("getConnection", "getTableName"));
     $this->mage->expects($this->any())->method("getSingleton")->will($this->returnValueMap(array(array("core/resource", $this->resource))));
     $this->resource->expects($this->any())->method("getTableName")->will($this->returnArgument(0));
     $this->readconn = $this->getMock("stdClass", array("fetchAll", "quote", "update", "insert"));
     $this->writeconn = $this->getMock("stdClass", array("fetchAll", "quote", "update", "insert"));
     $this->resource->expects($this->any())->method("getConnection")->will($this->returnValueMap(array(array("core_read", $this->readconn), array("core_write", $this->writeconn))));
     /*
      * Stubs that are fake quote-ers, does not really escape but just quote.
      */
     $this->readconn->expects($this->any())->method("quote")->will($this->returnCallback(function ($arg) {
         return "'{$arg}'";
     }));
     $this->writeconn->expects($this->any())->method("quote")->will($this->returnCallback(function ($arg) {
         return "'{$arg}'";
     }));
 }
 public function setUp()
 {
     parent::setUp();
     $this->controller = $this->getMock("Mollie_Mpm_ApiController", array("getRequest", "_redirect", "_restoreCart", "loadLayout", "_showException"), array());
     /**
      * transaction_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")->with("order_id")->will($this->returnValue(self::ORDER_ID));
     $this->controller->expects($this->any())->method("getRequest")->will($this->returnValue($this->request));
     $this->datahelper = $this->getMock("stdClass", array("getOrderIdByTransactionId", "getTransactionIdByOrderId", "getStatusById"));
     /*
      * Mage::Helper() method
      */
     $this->mage->expects($this->any())->method("Helper")->will($this->returnValueMap(array(array("mpm", $this->datahelper))));
     $this->order = $this->getMock("Mage_Sales_Model_Order", array("getData", "setPayment", "getGrandTotal", "getAllItems", "setState", "sendNewOrderEmail", "setEmailSent", "cancel", "save"));
     $this->order_model = $this->getMock("stdClass", array("load"));
     /*
      * Mage::getModel() method
      */
     $this->mage->expects($this->any())->method("getModel")->will($this->returnValueMap(array(array("sales/order", $this->order_model))));
     $this->session = $this->getMock("stdClass", array("getQuote", "getMollieQuoteId"));
     $this->quote = $this->getMock("stdClass");
     $this->session->expects($this->any())->method("getQuote")->will($this->returnValue($this->quote));
     /*
      * Mage::getSingleton() method
      */
     $this->mage->expects($this->any())->method("getSingleton")->will($this->returnValueMap(array(array("checkout/session", $this->session))));
 }
Exemple #4
0
 protected function setUp()
 {
     parent::setUp();
     $this->data = $this->getMock("stdClass", array("getApiKey", "getBankTransferDueDateDays"), array());
     $this->data->expects($this->any())->method("getApiKey")->will($this->returnValue("test_decafbad"));
     $this->mage->expects($this->any())->method("Helper")->will($this->returnValueMap(array(array('mpm', $this->data), array('core', new Mage_Core_Helper_Data()))));
     $this->api_client = $this->getMock("stdClass", array(), array());
     $this->payment = $this->getMock("stdClass", array("isPaid"), array());
     $this->api_client->payments = $this->getMock("stdClass", array("get"), array());
     $this->api_client->methods = $this->getMock("stdClass", array("all"), array());
     $this->api_client->payments->expects($this->any())->method("get")->will($this->returnValue($this->payment));
     $this->api = $this->getMock("Test_Mollie_Mpm_Helper_Api", array("_getMollieAPI", "__construct"), array(), '', false);
     $this->api->expects($this->any())->method("_getMollieAPI")->will($this->returnValue($this->api_client));
 }
Exemple #5
0
 protected function setUp()
 {
     parent::setUp();
     $this->HelperData = $this->getMock("Mollie_Mpm_Helper_Data", array("getCurrentStore"));
     $this->HelperData->expects($this->any())->method("getCurrentStore")->will($this->returnValue(self::STORE_ID));
     $this->mage->expects($this->any())->method("Helper")->with("mpm")->will($this->returnValue($this->HelperData));
     $this->resource = $this->getMock("stdClass", array("getConnection", "getTableName"));
     $this->mage->expects($this->any())->method("getSingleton")->will($this->returnValueMap(array(array("core/resource", $this->resource))));
     $this->readconn = $this->getMock("stdClass", array("fetchAll", "quote"));
     $this->writeconn = $this->getMock("stdClass", array("fetchAll", "quote"));
     $this->resource->expects($this->any())->method("getConnection")->will($this->returnValueMap(array(array("core_read", $this->readconn), array("core_write", $this->writeconn))));
     /*
      * Stubs that are fake quote-ers, does not really escape but just quote.
      */
     $this->readconn->expects($this->any())->method("quote")->will($this->returnCallback(function ($arg) {
         return "'{$arg}'";
     }));
     $this->writeconn->expects($this->any())->method("quote")->will($this->returnCallback(function ($arg) {
         return "'{$arg}'";
     }));
     $this->resource->expects($this->any())->method("getTableName")->will($this->returnArgument(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));
 }