Example #1
0
 public function testGetAliasWithAdditionalInformation()
 {
     $quote = new Varien_Object();
     $payment = new Varien_Object();
     $payment->setAdditionalInformation(array('alias' => 'testAlias'));
     $quote->setPayment($payment);
     $aliasHelperMock = $this->getHelperMock('ops/alias', array('isAdminSession'));
     $aliasHelperMock->expects($this->any())->method('isAdminSession')->will($this->returnValue(false));
     $this->assertEquals('testAlias', $aliasHelperMock->getAlias($quote));
 }
 private function setUpHelperMock($returnStatus, $setStoreId = true)
 {
     $paymentHelperMock = $this->getHelperMock('ops/payment', array('applyStateForOrder', 'shaCryptValidation'));
     $paymentHelperMock->expects($this->any())->method('applyStateForOrder')->will($this->returnValue($returnStatus));
     $paymentHelperMock->expects($this->any())->method('shaCryptValidation')->will($this->returnValue(true));
     $this->replaceByMock('helper', 'ops/payment', $paymentHelperMock);
     $fakePayment = new Varien_Object();
     $fakePayment->setMethodInstance(Mage::getModel('ops/payment_cc'));
     $fakeOrder = new Varien_Object();
     $fakeOrder->setPayment($fakePayment);
     $fakeOrder->setId(1);
     if ($setStoreId) {
         $fakeOrder->setStoreId(1);
     }
     $orderHelperMock = $this->getHelperMock('ops/order', array('getOrder'));
     $orderHelperMock->expects($this->any())->method('getOrder')->will($this->returnValue($fakeOrder));
     $this->replaceByMock('helper', 'ops/order', $orderHelperMock);
 }
Example #3
0
 public function testGetFormFieldsWithTPParam()
 {
     $this->markTestIncomplete('Depends on PCI release');
     $paymentModel = $this->getModelMock('ops/payment_abstract', array('getMethodDependendFormFields'));
     $configMock = $this->getModelMock('ops/config', array('getPSPID', 'getconfigData'));
     $configMock->expects($this->once())->method('getPSPID')->with(null)->will($this->returnValue('NRMAGENTO'));
     $configMock->expects($this->any())->method('getConfigData')->will($this->returnValue('spo'));
     $this->replaceByMock('model', 'ops/config', $configMock);
     $helperMock = $this->getHelperMock('ops/payment', array('getShaSign'));
     $helperMock->expects($this->any())->method('getSHASign')->with($this->anything(), $this->anything(), null)->will($this->returnValue('SHA123'));
     $this->replaceByMock('helper', 'ops/payment', $helperMock);
     $order = new Varien_Object();
     $payment = new Varien_Object();
     $payment->setMethodInstance(Mage::getModel('ops/payment_cc'));
     $order->setPayment($payment);
     $formFields = $paymentModel->getFormFields($order, array());
     $this->assertArrayHasKey('PSPID', $formFields);
     $this->assertArrayHasKey('SHASIGN', $formFields);
     $this->assertArrayHasKey('TP', $formFields);
     $this->assertEquals('NRMAGENTO', $formFields['PSPID']);
     $this->assertEquals('2d9f92d6f3955847ab2db427be75fe7eb0cde045', $formFields['SHASIGN']);
 }
Example #4
0
 public function testShowWarningForOpenInvoicePayments()
 {
     $transport = new Varien_Object();
     $transport->setHtml('Foo');
     $observer = Mage::getModel('ops/observer');
     $event = new Varien_Event_Observer();
     $event->setBlock('');
     $observer->appendPartialCaptureWarningForOpenInvoice($event);
     $this->assertEquals('Foo', $transport->getHtml());
     $order = new Varien_Object();
     $payment = new Varien_Object();
     $methodInstance = Mage::getModel('ops/payment_openInvoiceNl');
     $payment->setMethodInstance($methodInstance);
     $order->setPayment($payment);
     $invoice = $this->getModelMock('sales/order_invoice', array('getOrder'));
     $invoice->expects($this->any())->method('getOrder')->will($this->returnValue($order));
     Mage::register('current_invoice', $invoice);
     $block = Mage::app()->getLayout()->getBlockSingleton('adminhtml/sales_order_invoice_totals');
     $blockMock = $this->getBlockMock('ops/adminhtml_sales_order_invoice_warning_openInvoice', array('renderView'));
     $blockMock->expects($this->once())->method('renderView')->will($this->returnValue('<b>warning</b>'));
     $this->replaceByMock('block', 'ops/adminhtml_sales_order_invoice_warning_openInvoice', $blockMock);
     $event->setBlock($block);
     $event->setTransport($transport);
     $observer->appendPartialCaptureWarningForOpenInvoice($event);
     $this->assertEquals('Foo<b>warning</b>', $transport->getHtml());
     $this->assertNotEquals('Bar<span>warning</span>', $transport->getHtml());
     Mage::unregister('current_invoice');
 }