Commit 1260662b authored by Ivan Chepurnyi's avatar Ivan Chepurnyi

! Imporved speed of fixtures loading by adding transaction wrapper

parent 66fca00f
...@@ -525,6 +525,7 @@ class EcomDev_PHPUnit_Model_Fixture ...@@ -525,6 +525,7 @@ class EcomDev_PHPUnit_Model_Fixture
$ignoreCleanUp = array_keys($this->getStorageData(self::STORAGE_KEY_TABLES, self::SCOPE_SHARED)); $ignoreCleanUp = array_keys($this->getStorageData(self::STORAGE_KEY_TABLES, self::SCOPE_SHARED));
} }
$this->getResource()->beginTransaction();
foreach ($tables as $tableEntity => $data) { foreach ($tables as $tableEntity => $data) {
if (!in_array($tableEntity, $ignoreCleanUp)) { if (!in_array($tableEntity, $ignoreCleanUp)) {
$this->getResource()->cleanTable($tableEntity); $this->getResource()->cleanTable($tableEntity);
...@@ -534,7 +535,7 @@ class EcomDev_PHPUnit_Model_Fixture ...@@ -534,7 +535,7 @@ class EcomDev_PHPUnit_Model_Fixture
$this->getResource()->loadTableData($tableEntity, $data); $this->getResource()->loadTableData($tableEntity, $data);
} }
} }
$this->getResource()->commit();
$this->setStorageData(self::STORAGE_KEY_TABLES, $tables); $this->setStorageData(self::STORAGE_KEY_TABLES, $tables);
} }
...@@ -558,6 +559,7 @@ class EcomDev_PHPUnit_Model_Fixture ...@@ -558,6 +559,7 @@ class EcomDev_PHPUnit_Model_Fixture
if ($this->isScopeLocal() && $this->getStorageData(self::STORAGE_KEY_TABLES, self::SCOPE_SHARED)) { if ($this->isScopeLocal() && $this->getStorageData(self::STORAGE_KEY_TABLES, self::SCOPE_SHARED)) {
$restoreTableData = $this->getStorageData(self::STORAGE_KEY_TABLES, self::SCOPE_SHARED); $restoreTableData = $this->getStorageData(self::STORAGE_KEY_TABLES, self::SCOPE_SHARED);
} }
$this->getResource()->beginTransaction();
foreach (array_keys($tables) as $tableEntity) { foreach (array_keys($tables) as $tableEntity) {
$this->getResource()->cleanTable($tableEntity); $this->getResource()->cleanTable($tableEntity);
...@@ -567,6 +569,7 @@ class EcomDev_PHPUnit_Model_Fixture ...@@ -567,6 +569,7 @@ class EcomDev_PHPUnit_Model_Fixture
} }
} }
$this->getResource()->commit();
$this->setStorageData(self::STORAGE_KEY_TABLES, null); $this->setStorageData(self::STORAGE_KEY_TABLES, null);
} }
...@@ -640,6 +643,8 @@ class EcomDev_PHPUnit_Model_Fixture ...@@ -640,6 +643,8 @@ class EcomDev_PHPUnit_Model_Fixture
throw new InvalidArgumentException('EAV part should be an associative list with rows as value and entity type as key'); throw new InvalidArgumentException('EAV part should be an associative list with rows as value and entity type as key');
} }
$this->getResource()->beginTransaction();
foreach ($entities as $entityType => $values) { foreach ($entities as $entityType => $values) {
$this->_getEavLoader($entityType) $this->_getEavLoader($entityType)
->setFixture($this) ->setFixture($this)
...@@ -647,6 +652,8 @@ class EcomDev_PHPUnit_Model_Fixture ...@@ -647,6 +652,8 @@ class EcomDev_PHPUnit_Model_Fixture
->loadEntity($entityType, $values); ->loadEntity($entityType, $values);
} }
$this->getResource()->commit();
$this->setStorageData(self::STORAGE_KEY_ENTITIES, array_keys($entities)); $this->setStorageData(self::STORAGE_KEY_ENTITIES, array_keys($entities));
return $this; return $this;
...@@ -667,6 +674,7 @@ class EcomDev_PHPUnit_Model_Fixture ...@@ -667,6 +674,7 @@ class EcomDev_PHPUnit_Model_Fixture
$ignoreCleanUp = $this->getStorageData(self::STORAGE_KEY_ENTITIES, self::SCOPE_SHARED); $ignoreCleanUp = $this->getStorageData(self::STORAGE_KEY_ENTITIES, self::SCOPE_SHARED);
} }
$this->getResource()->beginTransaction();
foreach (array_keys($entities) as $entityType) { foreach (array_keys($entities) as $entityType) {
if (in_array($entityType, $ignoreCleanUp)) { if (in_array($entityType, $ignoreCleanUp)) {
continue; continue;
...@@ -675,6 +683,8 @@ class EcomDev_PHPUnit_Model_Fixture ...@@ -675,6 +683,8 @@ class EcomDev_PHPUnit_Model_Fixture
->cleanEntity($entityType); ->cleanEntity($entityType);
} }
$this->getResource()->commit();
return $this; return $this;
} }
......
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