public function testAppendParcelAnnouncementValidationToShipping()
 {
     $sessionMock = $this->getModelMockBuilder('checkout/session')->disableOriginalConstructor()->setMethods(null)->getMock();
     $this->replaceByMock('singleton', 'checkout/session', $sessionMock);
     $sessionMock = $this->getModelMockBuilder('customer/session')->disableOriginalConstructor()->setMethods(null)->getMock();
     $this->replaceByMock('singleton', 'customer/session', $sessionMock);
     $intrashipConfigMock = $this->getModelMock('intraship/config', array('isEnabled'));
     $intrashipConfigMock->expects($this->any())->method('isEnabled')->will($this->returnValue(true));
     $this->replaceByMock('model', 'intraship/config', $intrashipConfigMock);
     $this->store = Mage::app()->getStore(0)->load(0);
     $this->store->setConfig('intraship/dhlaccount/active', true);
     $transport = new Varien_Object();
     $transport->setHtml('Foo');
     $observer = Mage::getModel('dhlaccount/observer');
     $event = new Varien_Object();
     $block = Mage::app()->getLayout()->getBlockSingleton('checkout/onepage_shipping');
     $blockMock = $this->getBlockMock('dhlaccount/checkout_onepage_parcelannouncement', array('renderView'));
     $blockMock->expects($this->once())->method('renderView')->will($this->returnValue('<b>Foo</b>'));
     $this->replaceByMock('block', 'dhlaccount/checkout_onepage_parcelannouncement', $blockMock);
     $event->setBlock($block);
     $event->setTransport($transport);
     $observer->appendParcelAnnouncementValidationToShipping($event);
     $this->assertEquals('Foo<b>Foo</b>', $transport->getHtml());
     $this->assertNotEquals('<b>Foo</b>', $transport->getHtml());
 }
Example #2
0
 public function testShowWarningForClosedTransactions()
 {
     Mage::register('current_creditmemo', null);
     $transport = new Varien_Object();
     $transport->setHtml('Foo');
     $observer = Mage::getModel('ops/observer');
     $event = new Varien_Object();
     $event->setBlock('');
     $this->assertEquals('', $observer->showWarningForClosedTransactions($event));
     $order = new Varien_Object();
     $payment = new Varien_Object();
     $methodInstance = Mage::getModel('ops/payment_cc');
     $payment->setMethodInstance($methodInstance);
     $order->setPayment($payment);
     $invoice = new Varien_Object();
     $invoice->setTransactionId(1);
     $creditMemo = $this->getModelMock('sales/order_creditmemo', array('getOrder', 'getInvoice', 'canRefund', 'getOrderId'));
     $creditMemo->expects($this->any())->method('getOrder')->will($this->returnValue($order));
     $creditMemo->expects($this->any())->method('getInvoice')->will($this->returnValue($invoice));
     $creditMemo->expects($this->any())->method('canRefund')->will($this->returnValue(false));
     $creditMemo->expects($this->any())->method('getOrderId')->will($this->returnValue(1));
     Mage::register('current_creditmemo', $creditMemo);
     $block = Mage::app()->getLayout()->getBlockSingleton('adminhtml/sales_order_creditmemo_create');
     $blockMock = $this->getBlockMock('ops/adminhtml_sales_order_creditmemo_closedTransaction_warning', array('renderView'));
     $blockMock->expects($this->once())->method('renderView')->will($this->returnValue('<b>warning</b>'));
     $this->replaceByMock('block', 'ops/adminhtml_sales_order_creditmemo_closedTransaction_warning', $blockMock);
     $event->setBlock($block);
     $event->setTransport($transport);
     $html = $observer->showWarningForClosedTransactions($event);
     $this->assertEquals('<b>warning</b>Foo', $html);
     $this->assertNotEquals('Bar<span>warning</span>', $html);
     Mage::unregister('current_creditmemo');
 }