public function setUp()
 {
     parent::setUp();
     $this->_store = $this->getModelMockBuilder('core/store')->disableOriginalConstructor()->setMethods(array('getId'))->getMock();
     $this->_store->expects($this->any())->method('getId')->will($this->returnValue(0));
     $this->_stores = array(0 => $this->_store);
     $this->_collection = $this->getResourceModelMock('catalog/product_collection', array('load', 'addFieldToFilter'));
     $this->_batchContainer = $this->getModelMock('ebayenterprise_catalog/pim_batch_container', array('addBatch'));
     $this->_langHelper = $this->getHelperMock('eb2ccore/languages', array('getStores'));
     $this->_langHelper->expects($this->any())->method('getStores')->will($this->returnValue($this->_stores));
     $this->_prodHelper = $this->getHelperMock('ebayenterprise_catalog/data', array('getDefaultStoreViewId'));
     $this->_prodHelper->expects($this->any())->method('getDefaultStoreViewId')->will($this->returnValue(0));
 }
 /**
  * Create feed data set from product collection.
  * Create XML from feed data.
  * Write out file.
  * Return path to file created.
  */
 public function testBuildFeed()
 {
     $pathToFile = $this->_outboundPath . DS . $this->_tmpFileName;
     $this->_prodHelper->expects($this->once())->method('generateFileName')->will($this->returnValue($this->_tmpFileName));
     $this->_pimProductCollection->expects($this->once())->method('count')->will($this->returnValue(1));
     $this->_coreFeed->expects($this->any())->method('getLocalDirectory')->will($this->returnValue($this->_outboundPath));
     $pim = $this->getModelMockBuilder('ebayenterprise_catalog/pim')->setMethods(array('_createFeedDataSet', '_createDomFromFeedData'))->getMock();
     $pim->expects($this->any())->method('_createFeedDataSet')->will($this->returnValue($this->_pimProductCollection));
     $pim->expects($this->any())->method('_createDomFromFeedData')->will($this->returnValueMap(array(array($this->_pimProductCollection, $this->_docMock))));
     $this->_docMock->expects($this->once())->method('save')->with($this->identicalTo($pathToFile))->will($this->returnValue(12));
     // inject mocks
     $this->replaceByMock('helper', 'ebayenterprise_catalog', $this->_prodHelper);
     EcomDev_Utils_Reflection::setRestrictedPropertyValue($pim, '_coreFeed', $this->_coreFeed);
     EcomDev_Utils_Reflection::setRestrictedPropertyValue($pim, '_batch', $this->_batch);
     $this->assertSame($pathToFile, $pim->buildFeed($this->_batch));
 }