diff --git a/app/code/community/EcomDev/PHPUnit/Model/Fixture.php b/app/code/community/EcomDev/PHPUnit/Model/Fixture.php index b5dd07dc..b00d8eea 100644 --- a/app/code/community/EcomDev/PHPUnit/Model/Fixture.php +++ b/app/code/community/EcomDev/PHPUnit/Model/Fixture.php @@ -389,7 +389,7 @@ protected function _loadFixtureFiles(array $fixtures, $classOrInstance) ->resolveFilePath($className, EcomDev_PHPUnit_Model_Yaml_Loader::TYPE_FIXTURE, $fixture); if (!$filePath) { - throw new RuntimeException('Unable to load fixture for test'); + throw new RuntimeException('Unable to load fixture for test: '.$fixture); } $this->loadYaml($filePath); diff --git a/app/code/community/EcomDev/PHPUnit/Model/Fixture/Processor/Tables.php b/app/code/community/EcomDev/PHPUnit/Model/Fixture/Processor/Tables.php index 10fa0ea3..a3929611 100644 --- a/app/code/community/EcomDev/PHPUnit/Model/Fixture/Processor/Tables.php +++ b/app/code/community/EcomDev/PHPUnit/Model/Fixture/Processor/Tables.php @@ -66,11 +66,12 @@ public function apply(array $data, $key, EcomDev_PHPUnit_Model_Fixture_Interface } $this->getResource()->beginTransaction(); - foreach ($data as $tableEntity => $tableData) { + foreach (array_reverse(array_keys($data)) as $tableEntity) { if (!in_array($tableEntity, $ignoreCleanUp)) { $this->getResource()->cleanTable($tableEntity); } - + } + foreach ($data as $tableEntity => $tableData) { if (!empty($tableData)) { $this->getResource()->loadTableData($tableEntity, $tableData); } @@ -102,9 +103,10 @@ public function discard(array $data, $key, EcomDev_PHPUnit_Model_Fixture_Interfa } $this->getResource()->beginTransaction(); - foreach (array_keys($data) as $tableEntity) { + 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]); } @@ -114,4 +116,4 @@ public function discard(array $data, $key, EcomDev_PHPUnit_Model_Fixture_Interfa $fixture->setStorageData(self::STORAGE_KEY, null); return $this; } -} \ No newline at end of file +} diff --git a/app/code/community/EcomDev/PHPUnit/Model/Mysql4/Fixture.php b/app/code/community/EcomDev/PHPUnit/Model/Mysql4/Fixture.php index d10834c4..f3ca3c7a 100644 --- a/app/code/community/EcomDev/PHPUnit/Model/Mysql4/Fixture.php +++ b/app/code/community/EcomDev/PHPUnit/Model/Mysql4/Fixture.php @@ -27,6 +27,7 @@ class EcomDev_PHPUnit_Model_Mysql4_Fixture extends Mage_Core_Model_Mysql4_Abstra protected function _construct() { $this->_setResource('ecomdev_phpunit'); + $this->_resourceModel = NULL; } /** @@ -129,6 +130,6 @@ protected function _getTableRecordValue($value) return serialize($value['serialized']); } - throw new InvalidArgumentException('Unrecognized type for DB column'); + throw new InvalidArgumentException('Unrecognized type for DB column: '.print_r($value, 1)); } -} \ No newline at end of file +} diff --git a/app/code/community/EcomDev/PHPUnit/Model/Mysql4/Fixture/Eav/Abstract.php b/app/code/community/EcomDev/PHPUnit/Model/Mysql4/Fixture/Eav/Abstract.php index 4f547ca7..c767258d 100644 --- a/app/code/community/EcomDev/PHPUnit/Model/Mysql4/Fixture/Eav/Abstract.php +++ b/app/code/community/EcomDev/PHPUnit/Model/Mysql4/Fixture/Eav/Abstract.php @@ -57,10 +57,11 @@ public function runRequiredIndexers() if (empty($this->_options['doNotIndexAll'])) { $indexer = Mage::getSingleton('index/indexer'); foreach ($this->getRequiredIndexers() as $indexerCode) { - if (empty($this->_options['doNotIndex']) - || !in_array($indexerCode, $this->_options['doNotIndex'])) { - $indexer->getProcessByCode($indexerCode) - ->reindexAll(); + if (empty($this->_options['doNotIndex']) || !in_array($indexerCode, $this->_options['doNotIndex'])) { + $process = $indexer->getProcessByCode($indexerCode); + if ($process) { + $process->reindexAll(); + } } } }