/** * Initializes cache options * * @param EcomDev_PHPUnit_Model_FixtureInterface $fixture * @return EcomDev_PHPUnit_Model_Fixture_Processor_Cache */ public function initialize(EcomDev_PHPUnit_Model_FixtureInterface $fixture) { $options = $fixture->getOptions(); if (isset($options['cache'])) { $cacheOptions = array(); foreach ($options['cache'] as $annotation) { list($action, $cacheType) = preg_split('/\\s+/', trim($annotation)); $flag = $action === 'off' ? 0 : 1; if ($cacheType === 'all') { foreach (Mage::app()->getCacheInstance()->getTypes() as $type) { $cacheOptions[$type->getId()] = $flag; } } else { $cacheOptions[$cacheType] = $flag; } } $fixture->setFixtureValue('cache_options', $cacheOptions); } return $this; }
/** * Initializes fixture processor before applying data * * @param EcomDev_PHPUnit_Model_FixtureInterface $fixture * @return EcomDev_PHPUnit_Model_Fixture_Processor_Registry */ public function initialize(EcomDev_PHPUnit_Model_FixtureInterface $fixture) { $options = $fixture->getOptions(); $registry = array(); foreach (array('singleton', 'resource', 'helper', 'registry') as $type) { if (!isset($options[$type])) { continue; } foreach ($options[$type] as $name) { $registry[$type][] = $name; } } if ($registry) { $fixture->setFixtureValue('registry', $registry); } return $this; }
/** * Initializes fixture processor before applying data * * @param EcomDev_PHPUnit_Model_Fixture_Interface $fixture * @return EcomDev_PHPUnit_Model_Fixture_Processor_Interface */ public function initialize(EcomDev_PHPUnit_Model_FixtureInterface $fixture) { $generateData = $fixture->getFixtureValue('generate'); $fixtureData = array(); foreach ($generateData as $generateByTypes) { foreach ($generateByTypes as $type => $data) { if (!isset($this->fixtures[$type]['path'])) { continue; } $path = $this->fixtures[$type]['path']; $fixtureType = isset($this->fixtures[$type]['type']) ? $this->fixtures[$type]['type'] : 'tables'; if (!isset($fixtureData[$fixtureType][$path])) { $fixtureData[$fixtureType][$path] = array(); } $fixtureData[$fixtureType][$path] = array_merge($fixtureData[$fixtureType][$path], Mage::getSingleton($this->fixtures[$type]['model'])->process($data)); } } foreach ($fixtureData as $type => $entities) { $fixtureValue = $fixture->getFixtureValue($type); foreach ($entities as $path => $records) { Mage::helper('hackathon_fixturegenerator')->updatePathValue($path, $records, $fixtureValue); } $fixture->setFixtureValue($type, $fixtureValue); } return $this; }