public function setUp() { parent::setUp(); $this->_payloadFactory = new PayloadFactory(); $this->_payload = $this->_payloadFactory->buildPayload('\\eBayEnterprise\\RetailOrderManagement\\Payload\\OrderEvents\\OrderShipped'); $this->_payload->setCustomerOrderId(static::PAYLOAD_CUSTOMER_ORDER_ID)->setStoreId(static::PAYLOAD_STORE_ID); // suppressing the real session from starting $session = $this->getModelMockBuilder('core/session')->disableOriginalConstructor()->setMethods(null)->getMock(); $this->replaceByMock('singleton', 'core/session', $session); $this->_shipmentHelper = $this->getHelperMock('ebayenterprise_order/event_shipment', ['process']); $this->_ordershipped = Mage::getModel('ebayenterprise_order/ordershipped', ['payload' => $this->_payload, 'shipment_event_helper' => $this->_shipmentHelper]); }
/** * Testing 'EbayEnterprise_Order_Helper_Event_Shipment::process' method * taking a sales/order instance and an array of shipment data, then expects * the save method on the 'core/resource_transaction' model to be called once in order * not to save the shipment data to the database. * @param array $itemData * @param bool $isException Flag for the mock save method to throw or not throw exception * @dataProvider dataProvider */ public function testProcess(array $itemData, $isException) { $this->_payload->deserialize(file_get_contents(__DIR__ . '/ShipmentTest/fixtures/Process-OrderShipped.xml')); $order = Mage::getModel('sales/order'); $this->_addItemsToOrder($order, $itemData, 'sku', 'sku', 'item_id'); $exceptionMsg = 'Simulating throwing exception when saving shipment.'; $transaction = $this->getModelMock('core/resource_transaction', ['save']); $transaction->expects($this->once())->method('save')->will($isException ? $this->throwException(Mage::exception('Mage_Core', $exceptionMsg)) : $this->returnSelf()); $this->replaceByMock('model', 'core/resource_transaction', $transaction); $this->assertSame($this->_shipmentHelper, $this->_shipmentHelper->process($order, $this->_payload)); }