Commit 0ed8142e authored by Colin Mollenhour's avatar Colin Mollenhour

Delete from tables in reverse order to avoid foreign key constraint errors.

parent 43ea8433
...@@ -389,7 +389,7 @@ class EcomDev_PHPUnit_Model_Fixture ...@@ -389,7 +389,7 @@ class EcomDev_PHPUnit_Model_Fixture
->resolveFilePath($className, EcomDev_PHPUnit_Model_Yaml_Loader::TYPE_FIXTURE, $fixture); ->resolveFilePath($className, EcomDev_PHPUnit_Model_Yaml_Loader::TYPE_FIXTURE, $fixture);
if (!$filePath) { if (!$filePath) {
throw new RuntimeException('Unable to load fixture for test'); throw new RuntimeException('Unable to load fixture for test: '.$fixture);
} }
$this->loadYaml($filePath); $this->loadYaml($filePath);
......
...@@ -66,11 +66,12 @@ class EcomDev_PHPUnit_Model_Fixture_Processor_Tables ...@@ -66,11 +66,12 @@ class EcomDev_PHPUnit_Model_Fixture_Processor_Tables
} }
$this->getResource()->beginTransaction(); $this->getResource()->beginTransaction();
foreach ($data as $tableEntity => $tableData) { foreach (array_reverse(array_keys($data)) as $tableEntity) {
if (!in_array($tableEntity, $ignoreCleanUp)) { if (!in_array($tableEntity, $ignoreCleanUp)) {
$this->getResource()->cleanTable($tableEntity); $this->getResource()->cleanTable($tableEntity);
} }
}
foreach ($data as $tableEntity => $tableData) {
if (!empty($tableData)) { if (!empty($tableData)) {
$this->getResource()->loadTableData($tableEntity, $tableData); $this->getResource()->loadTableData($tableEntity, $tableData);
} }
...@@ -102,9 +103,10 @@ class EcomDev_PHPUnit_Model_Fixture_Processor_Tables ...@@ -102,9 +103,10 @@ class EcomDev_PHPUnit_Model_Fixture_Processor_Tables
} }
$this->getResource()->beginTransaction(); $this->getResource()->beginTransaction();
foreach (array_keys($data) as $tableEntity) { foreach (array_reverse(array_keys($data)) as $tableEntity) {
$this->getResource()->cleanTable($tableEntity); $this->getResource()->cleanTable($tableEntity);
}
foreach (array_keys($data) as $tableEntity) {
if (isset($restoreTableData[$tableEntity])) { if (isset($restoreTableData[$tableEntity])) {
$this->getResource()->loadTableData($tableEntity, $restoreTableData[$tableEntity]); $this->getResource()->loadTableData($tableEntity, $restoreTableData[$tableEntity]);
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment