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
*/
public function cleanTable($tableEntity)
{
try {
$this->_getWriteAdapter()
->truncate($this->getTable($tableEntity));
->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;
}
......@@ -58,10 +65,17 @@ class EcomDev_PHPUnit_Model_Mysql4_Fixture extends Mage_Core_Model_Mysql4_Abstra
$records[] = $this->_getTableRecord($row, $tableColumns);
}
try {
$this->_getWriteAdapter()->insertOnDuplicate(
$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;
}
......
<?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