Пример #1
0
 /**
  * Apply virtual file system structure
  *
  * @param array                                   $data
  * @param string                                  $key
  * @param EcomDev_PHPUnit_Model_FixtureInterface $fixture
  *
  * @return EcomDev_PHPUnit_Model_Fixture_Processor_Cache
  */
 public function apply(array $data, $key, EcomDev_PHPUnit_Model_FixtureInterface $fixture)
 {
     if ($fixture->isScopeLocal() && ($parentData = $fixture->getStorageData(self::STORAGE_KEY, EcomDev_PHPUnit_Model_FixtureInterface::SCOPE_SHARED))) {
         $data = array_merge_recursive($parentData, $data);
     }
     $fixture->getVfs()->apply($data);
     $fixture->setStorageData(self::STORAGE_KEY, $data);
     return $this;
 }
Пример #2
0
 /**
  * Discard applied table records
  *
  * @param array[] $data
  * @param string $key
  * @param EcomDev_PHPUnit_Model_FixtureInterface $fixture
  *
  * @return EcomDev_PHPUnit_Model_Fixture_Processor_Tables
  */
 public function discard(array $data, $key, EcomDev_PHPUnit_Model_FixtureInterface $fixture)
 {
     $restoreTableData = array();
     // Data for tables used in shared fixture
     if ($fixture->isScopeLocal() && $fixture->getStorageData(self::STORAGE_KEY, EcomDev_PHPUnit_Model_FixtureInterface::SCOPE_SHARED)) {
         $restoreTableData = $fixture->getStorageData(self::STORAGE_KEY, EcomDev_PHPUnit_Model_FixtureInterface::SCOPE_SHARED);
     }
     $this->getResource()->beginTransaction();
     foreach (array_reverse(array_keys($data)) as $tableEntity) {
         $this->getResource()->cleanTable($tableEntity);
     }
     foreach (array_keys($data) as $tableEntity) {
         if (isset($restoreTableData[$tableEntity])) {
             $this->getResource()->loadTableData($tableEntity, $restoreTableData[$tableEntity]);
         }
     }
     $this->getResource()->commit();
     $fixture->setStorageData(self::STORAGE_KEY, null);
     return $this;
 }
Пример #3
0
 /**
  * Sets back old singletons after tests
  *
  * @param array[]                                 $data
  * @param string                                  $key
  * @param EcomDev_PHPUnit_Model_FixtureInterface $fixture
  *
  * @return EcomDev_PHPUnit_Model_Fixture_ProcessorInterface
  */
 public function discard(array $data, $key, EcomDev_PHPUnit_Model_FixtureInterface $fixture)
 {
     if ($fixture->getStorageData(self::STORAGE_KEY) === null) {
         return $this;
     }
     $oldRegistry = $fixture->getStorageData(self::STORAGE_KEY);
     foreach ($oldRegistry as $key => $value) {
         // Set old value to registry
         EcomDev_PHPUnit_Test_Case_Util::app()->replaceRegistry($key, $value);
     }
     $fixture->setStorageData(self::STORAGE_KEY, null);
     return $this;
 }
Пример #4
0
 /**
  * Discard applied scope models
  *
  * @param array[] $data
  * @param string $key
  * @param EcomDev_PHPUnit_Model_FixtureInterface $fixture
  *
  * @return EcomDev_PHPUnit_Model_Fixture_Processor_Scope
  */
 public function discard(array $data, $key, EcomDev_PHPUnit_Model_FixtureInterface $fixture)
 {
     if ($fixture->getStorageData(self::STORAGE_KEY) === null) {
         return $this;
     }
     EcomDev_PHPUnit_Test_Case_Util::app()->disableEvents();
     $scope = array_reverse($fixture->getStorageData(self::STORAGE_KEY));
     foreach ($scope as $models) {
         foreach ($models as $model) {
             $model->delete();
         }
     }
     $fixture->setStorageData(self::STORAGE_KEY, null);
     EcomDev_PHPUnit_Test_Case_Util::app()->getCache()->clean(Zend_Cache::CLEANING_MODE_MATCHING_ANY_TAG, array(Mage_Core_Model_Store::CACHE_TAG, Mage_Core_Model_Store_Group::CACHE_TAG, Mage_Core_Model_Website::CACHE_TAG));
     EcomDev_PHPUnit_Test_Case_Util::app()->enableEvents();
     EcomDev_PHPUnit_Test_Case_Util::app()->reinitStores();
     return $this;
 }
Пример #5
0
 /**
  * Discard applied attribute records
  *
  * @param array[] $data
  * @param string $key
  * @param EcomDev_PHPUnit_Model_FixtureInterface $fixture
  *
  * @return EcomDev_PHPUnit_Model_Fixture_Processor_Attributes
  */
 public function discard(array $data, $key, EcomDev_PHPUnit_Model_FixtureInterface $fixture)
 {
     $ignoreCleanUp = array();
     // Ignore cleaning of entities if shared fixture loaded something for them
     if ($fixture->isScopeLocal() && $fixture->getStorageData(self::STORAGE_KEY, EcomDev_PHPUnit_Model_FixtureInterface::SCOPE_SHARED)) {
         $ignoreCleanUp = $fixture->getStorageData(self::STORAGE_KEY, EcomDev_PHPUnit_Model_FixtureInterface::SCOPE_SHARED);
     }
     $this->getResource()->beginTransaction();
     foreach (array_keys($data) as $entityType) {
         if (in_array($entityType, $ignoreCleanUp)) {
             continue;
         }
         $this->_getAttributeLoader($entityType)->cleanAttributes($entityType, $data);
     }
     $this->getResource()->commit();
     EcomDev_PHPUnit_Test_Case_Util::replaceRegistry('_singleton/eav/config', null);
     //clean out the EAV cache
     return $this;
 }
Пример #6
0
 /**
  * Discard applied eav records
  *
  * @param array[] $data
  * @param string $key
  * @param EcomDev_PHPUnit_Model_FixtureInterface $fixture
  *
  * @return EcomDev_PHPUnit_Model_Fixture_Processor_Eav
  */
 public function discard(array $data, $key, EcomDev_PHPUnit_Model_FixtureInterface $fixture)
 {
     $ignoreCleanUp = array();
     // Ignore cleaning of entities if shared fixture loaded something for them
     if ($fixture->isScopeLocal() && $fixture->getStorageData(self::STORAGE_KEY, EcomDev_PHPUnit_Model_FixtureInterface::SCOPE_SHARED)) {
         $ignoreCleanUp = $fixture->getStorageData(self::STORAGE_KEY, EcomDev_PHPUnit_Model_FixtureInterface::SCOPE_SHARED);
     }
     $typesToRestore = array();
     $this->getResource()->beginTransaction();
     foreach (array_keys($data) as $entityType) {
         $eavLoader = $this->_getEavLoader($entityType);
         if (in_array($entityType, $ignoreCleanUp)) {
             if ($eavLoader instanceof EcomDev_PHPUnit_Model_Mysql4_Fixture_RestoreAwareInterface) {
                 $eavLoader->clearData($entityType);
             }
             continue;
         }
         $eavLoader->cleanEntity($entityType);
         if ($eavLoader instanceof EcomDev_PHPUnit_Model_Mysql4_Fixture_RestoreAwareInterface) {
             $typesToRestore[$entityType] = $eavLoader;
         }
     }
     $this->getResource()->commit();
     if ($typesToRestore) {
         $this->getResource()->beginTransaction();
         foreach ($typesToRestore as $entityType => $eavLoader) {
             $eavLoader->restoreData($entityType)->clearData($entityType);
         }
         $this->getResource()->commit();
     }
     return $this;
 }
Пример #7
0
 /**
  * Discard applied cache options
  *
  * @param array[] $data
  * @param string $key
  * @param EcomDev_PHPUnit_Model_FixtureInterface $fixture
  *
  * @return EcomDev_PHPUnit_Model_Fixture_Processor_Cache
  */
 public function discard(array $data, $key, EcomDev_PHPUnit_Model_FixtureInterface $fixture)
 {
     EcomDev_PHPUnit_Test_Case_Util::app()->setCacheOptions($fixture->getStorageData(self::STORAGE_KEY));
     return $this;
 }
Пример #8
0
 /**
  * Discard applied eav records
  *
  * @param array[] $data
  * @param string $key
  * @param EcomDev_PHPUnit_Model_FixtureInterface $fixture
  *
  * @return EcomDev_PHPUnit_Model_Fixture_Processor_Eav
  */
 public function discard(array $data, $key, EcomDev_PHPUnit_Model_FixtureInterface $fixture)
 {
     $ignoreCleanUp = array();
     // Ignore cleaning of entities if shared fixture loaded something for them
     if ($fixture->isScopeLocal() && $fixture->getStorageData(self::STORAGE_KEY, EcomDev_PHPUnit_Model_FixtureInterface::SCOPE_SHARED)) {
         $ignoreCleanUp = $fixture->getStorageData(self::STORAGE_KEY, EcomDev_PHPUnit_Model_FixtureInterface::SCOPE_SHARED);
     }
     $this->getResource()->beginTransaction();
     foreach (array_keys($data) as $entityType) {
         if (in_array($entityType, $ignoreCleanUp)) {
             continue;
         }
         $this->_getEavLoader($entityType)->cleanEntity($entityType);
     }
     $this->getResource()->commit();
     return $this;
 }