/** * Set up dependent systems for the tests */ public function setUp() { parent::setUp(); $this->doc = Mage::helper('eb2ccore')->getNewDomDocument(); $this->product = Mage::getModel('catalog/product'); // setup parent config and used simple products $configId = 1; $configSku = sprintf('%s-%s', $this->catalogId, $this->styleId); $simpleId = 2; $simpleSku = sprintf('%s-%s', $this->catalogId, 'SIMPLE1'); $this->configProduct = Mage::getModel('catalog/product', array('type_id' => Mage_Catalog_Model_Product_Type::TYPE_CONFIGURABLE, 'sku' => $configSku, 'entity_id' => $configId)); $this->simpleProduct = Mage::getModel('catalog/product', array('type_id' => Mage_Catalog_Model_Product_Type::TYPE_SIMPLE, 'sku' => $simpleSku, 'entity_id' => $simpleId)); // mock out the resource model used to lookup the config to simple // product relationships so lookups can be avoided and made reliable $this->configTypeResource = $this->getResourceModelMock('catalog/product_type_configurable', array('getParentIdsByChild')); // script out lookup behavior - when called with the simple product's id, // return array containing config product's id and an empty array otherwise $this->configTypeResource->expects($this->any())->method('getParentIdsByChild')->will($this->returnCallback(function ($childId) use($configId, $simpleId) { return $childId === $simpleId ? array($configId) : array(); })); // mock out catalog id config $this->coreConfig = $this->buildCoreConfigRegistry(array('catalogId' => $this->catalogId)); $this->coreHelper = $this->getHelperMock('eb2ccore/data', array('getConfigModel')); $this->coreHelper->expects($this->any())->method('getConfigModel')->will($this->returnValue($this->coreConfig)); }
/** * Set up mock and test objects used throughout the tests. */ public function setUp() { parent::setUp(); $this->product = Mage::getModel('catalog/product'); $configId = 1; $configSku = sprintf('%s-%s', $this->catalogId, $this->styleId); $simpleId = 2; $simpleSku = sprintf('%s-%s', $this->catalogId, 'SIMPLE1'); $this->configProduct = Mage::getModel('catalog/product', array('type_id' => Mage_Catalog_Model_Product_Type::TYPE_CONFIGURABLE, 'sku' => $configSku, 'name' => sprintf($this->styleName), 'entity_id' => $configId)); $this->simpleProduct = Mage::getModel('catalog/product', array('type_id' => Mage_Catalog_Model_Product_Type::TYPE_SIMPLE, 'sku' => $simpleSku, 'name' => 'Simple Product', 'entity_id' => $simpleId)); // mock out the resource model used to lookup the config to simple // product relationships so lookups can be avoided and made reliable $this->configTypeResource = $this->getResourceModelMock('catalog/product_type_configurable', array('getParentIdsByChild')); // script out lookup behavior - when called with the simple product's id, // return array containing config product's id and an empty array otherwise $this->configTypeResource->expects($this->any())->method('getParentIdsByChild')->will($this->returnCallback(function ($childId) use($configId, $simpleId) { return $childId === $simpleId ? array($configId) : array(); })); $this->colorOption = Mage::getModel('eav/entity_attribute_option'); $this->colorOption->setData($this->colorData); $this->colorOptionCollection = $this->getResourceModelMockBuilder('eav/entity_attribute_option_collection')->disableOriginalConstructor()->setMethods(array('getItemById'))->getMock(); $this->colorOptionCollection->expects($this->any())->method('getItemById')->will($this->returnValueMap(array(array($this->colorData['id'], $this->colorOption)))); $this->doc = new EbayEnterprise_Dom_Document(); $this->coreConfig = $this->buildCoreConfigRegistry(array('catalogId' => $this->catalogId)); $this->coreHelper = $this->getHelperMock('eb2ccore/data', array('getConfigModel')); $this->coreHelper->expects($this->any())->method('getConfigModel')->will($this->returnValue($this->coreConfig)); $this->itemmasterHelper = $this->getHelperMock('ebayenterprise_catalog/itemmaster', array('_getColorAttributeOptionsCollection')); $this->itemmasterHelper->expects($this->any())->method('_getColorAttributeOptionsCollection')->will($this->returnValue($this->colorOptionCollection)); }