We will work on Apr 26th (Saturday) and will be off from Apr 30th (Wednesday) until May 2nd (Friday) for public holiday in our country

Commit 66fca00f authored by Ivan Chepurnyi's avatar Ivan Chepurnyi

! Add wrapper exception for fixture database query failures

parent 77932a42
...@@ -37,8 +37,15 @@ class EcomDev_PHPUnit_Model_Mysql4_Fixture extends Mage_Core_Model_Mysql4_Abstra ...@@ -37,8 +37,15 @@ class EcomDev_PHPUnit_Model_Mysql4_Fixture extends Mage_Core_Model_Mysql4_Abstra
*/ */
public function cleanTable($tableEntity) public function cleanTable($tableEntity)
{ {
$this->_getWriteAdapter() try {
->truncate($this->getTable($tableEntity)); $this->_getWriteAdapter()
->delete($this->getTable($tableEntity));
} catch (Exception $e) {
throw new EcomDev_PHPUnit_Model_Mysql4_Fixture_Exception(
sprintf('Unable to clear records for a table "%s"', $tableEntity),
$e
);
}
return $this; return $this;
} }
...@@ -58,11 +65,18 @@ class EcomDev_PHPUnit_Model_Mysql4_Fixture extends Mage_Core_Model_Mysql4_Abstra ...@@ -58,11 +65,18 @@ class EcomDev_PHPUnit_Model_Mysql4_Fixture extends Mage_Core_Model_Mysql4_Abstra
$records[] = $this->_getTableRecord($row, $tableColumns); $records[] = $this->_getTableRecord($row, $tableColumns);
} }
$this->_getWriteAdapter()->insertOnDuplicate( try {
$this->getTable($tableEntity), $this->_getWriteAdapter()->insertOnDuplicate(
$records $this->getTable($tableEntity),
); $records
);
} catch (Exception $e) {
throw new EcomDev_PHPUnit_Model_Mysql4_Fixture_Exception(
sprintf('Unable to insert/update records for a table "%s"', $tableEntity),
$e
);
}
return $this; return $this;
} }
......
<?php
class EcomDev_PHPUnit_Model_Mysql4_Fixture_Exception extends RuntimeException
{
public function __construct($message, Exception $previous)
{
parent::__construct($message, 0, $previous);
}
}
\ No newline at end of file
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