public function testAddCCForZeroAmountCheckout() { $block = new Mage_Payment_Block_Form_Container(); $method = new Varien_Object(); $method->setCode('ops_ideal'); $block->setData('methods', array($method)); $quote = Mage::getModel('sales/quote'); $block->setQuote($quote); $featureModelMock = $this->getModelMock('ops/payment_features_zeroAmountAuth', array('isCCAndZeroAmountAuthAllowed')); $featureModelMock->expects($this->any())->method('isCCAndZeroAmountAuthAllowed')->will($this->returnValue(true)); $this->replaceByMock('model', 'ops/payment_features_zeroAmountAuth', $featureModelMock); $this->_helper->addCCForZeroAmountCheckout($block); $methods = $block->getMethods(); $this->assertTrue($methods[1] instanceof Netresearch_OPS_Model_Payment_Cc); $this->assertFalse($methods[0] instanceof Netresearch_OPS_Model_Payment_Cc); }
/** * add ops_cc payment to checkout methods if quote total is zero and zero amount checkout is activated * * @param Mage_Payment_Block_Form_Container $block * * @return $this */ public function addCCForZeroAmountCheckout(Mage_Payment_Block_Form_Container $block) { $methods = $block->getMethods(); if (false === $this->checkIfCCisInCheckoutMethods($methods)) { $ccPayment = Mage::getModel('ops/payment_cc'); if ($ccPayment->getFeatureModel()->isCCAndZeroAmountAuthAllowed($ccPayment, $block->getQuote())) { $ccPayment->setInfoInstance($block->getQuote()->getPayment()); $methods[] = $ccPayment; $block->setData('methods', $methods); } } return $this; }