Commit 5ab89309 authored by Ivan Chepurnyi's avatar Ivan Chepurnyi

Merge pull request #146 from colinmollenhour/fixes

Fixes for foreign key checks, arbitrary tables and disabled indexers
parents 43ea8433 59d0ccaf
...@@ -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]);
} }
...@@ -114,4 +116,4 @@ class EcomDev_PHPUnit_Model_Fixture_Processor_Tables ...@@ -114,4 +116,4 @@ class EcomDev_PHPUnit_Model_Fixture_Processor_Tables
$fixture->setStorageData(self::STORAGE_KEY, null); $fixture->setStorageData(self::STORAGE_KEY, null);
return $this; return $this;
} }
} }
\ No newline at end of file
...@@ -27,6 +27,7 @@ class EcomDev_PHPUnit_Model_Mysql4_Fixture extends Mage_Core_Model_Mysql4_Abstra ...@@ -27,6 +27,7 @@ class EcomDev_PHPUnit_Model_Mysql4_Fixture extends Mage_Core_Model_Mysql4_Abstra
protected function _construct() protected function _construct()
{ {
$this->_setResource('ecomdev_phpunit'); $this->_setResource('ecomdev_phpunit');
$this->_resourceModel = NULL;
} }
/** /**
...@@ -129,6 +130,6 @@ class EcomDev_PHPUnit_Model_Mysql4_Fixture extends Mage_Core_Model_Mysql4_Abstra ...@@ -129,6 +130,6 @@ class EcomDev_PHPUnit_Model_Mysql4_Fixture extends Mage_Core_Model_Mysql4_Abstra
return serialize($value['serialized']); 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
...@@ -57,10 +57,11 @@ abstract class EcomDev_PHPUnit_Model_Mysql4_Fixture_Eav_Abstract ...@@ -57,10 +57,11 @@ abstract class EcomDev_PHPUnit_Model_Mysql4_Fixture_Eav_Abstract
if (empty($this->_options['doNotIndexAll'])) { if (empty($this->_options['doNotIndexAll'])) {
$indexer = Mage::getSingleton('index/indexer'); $indexer = Mage::getSingleton('index/indexer');
foreach ($this->getRequiredIndexers() as $indexerCode) { foreach ($this->getRequiredIndexers() as $indexerCode) {
if (empty($this->_options['doNotIndex']) if (empty($this->_options['doNotIndex']) || !in_array($indexerCode, $this->_options['doNotIndex'])) {
|| !in_array($indexerCode, $this->_options['doNotIndex'])) { $process = $indexer->getProcessByCode($indexerCode);
$indexer->getProcessByCode($indexerCode) if ($process) {
->reindexAll(); $process->reindexAll();
}
} }
} }
} }
......
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