protected function _mockTransport() { $stubMock = $this->mockModel('xcom_stub/transport_stub', array('send')); $stubMock->expects($this->any())->method('send')->will($this->returnValue($stubMock)); $transportClassName = Mage::getConfig()->getModelClassName('xcom_xfabric/transport_xfabric'); $xfabricMock = $this->getMock($transportClassName, array('send'), array(), '', FALSE); $xfabricMock->expects($this->any())->method('send')->will($this->returnValue($xfabricMock)); Mage::registerMockModel('xcom_xfabric/transport_xfabric', $xfabricMock); }
/** * Mock Magento model * * @param string $factoryString Class name or class path * @param array $methods * @return PHPUnit_Framework_MockObject_MockObject * @throws PHPUnit_Framework_Exception */ public function mockModel($factoryString, $methods = array(), $callOriginalConstructor = TRUE, $params = array()) { $class = Mage::getConfig()->getModelClassName($factoryString); if (!$class) { throw new PHPUnit_Framework_Exception(sprintf('Model "%s" not found.', $factoryString)); } $modelMock = $this->getMock($class, $methods, $params, '', $callOriginalConstructor); Mage::registerMockModel($factoryString, $modelMock); return $modelMock; }
public function setUp() { parent::setUp(); $this->_object = $this->getMockBuilder('Xcom_Xfabric_Model_Debug_Simple')->setMethods(array('save'))->getMock(); Mage::registerMockModel('xcom_xfabric/debug_simple', $this->_object); }
public function testGetSchema() { $schemaUri = 'http://test.loc/message'; $schemaVersion = '1.0.0'; $schemaRecordName = 'RecordName'; $this->_object->setSchemaUri($schemaUri); $this->_object->setSchemaVersion($schemaVersion); $this->_object->setSchemaRecordName($schemaRecordName); $class = Mage::getConfig()->getModelClassName('xcom_xfabric/schema'); $options = array('schema_uri' => $schemaUri); $modelMock = $this->getMock($class, array('_loadProtocol'), array($options)); Mage::registerMockModel('xcom_xfabric/schema', $modelMock); $this->assertEquals($schemaUri, $this->_object->getSchema()->getSchemaUri()); }