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 9ffeac99 authored by Ivan Chepurnyi's avatar Ivan Chepurnyi

Merge pull request #96 from aligent/issues/78_configurable_fixtures

Issues/78 configurable fixtures
parents ad62b444 9264db77
......@@ -42,7 +42,7 @@ class EcomDev_PHPUnit_Model_Mysql4_Fixture extends Mage_Core_Model_Mysql4_Abstra
->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),
sprintf('Unable to clear records for a table "%s" - "%s"', $tableEntity, $e->getMessage()),
$e
);
}
......@@ -72,7 +72,7 @@ class EcomDev_PHPUnit_Model_Mysql4_Fixture extends Mage_Core_Model_Mysql4_Abstra
);
} catch (Exception $e) {
throw new EcomDev_PHPUnit_Model_Mysql4_Fixture_Exception(
sprintf('Unable to insert/update records for a table "%s"', $tableEntity),
sprintf('Unable to insert/update records for a table "%s" - "%s"', $tableEntity, $e->getMessage()),
$e
);
}
......
......@@ -59,6 +59,7 @@ class EcomDev_PHPUnit_Model_Mysql4_Fixture_Eav_Catalog_Product extends EcomDev_P
$records += $this->_getTierPriceRecords($row, $entityTypeModel);
$records += $this->_getCategoryAssociationRecords($row, $entityTypeModel);
$records += $this->_getProductStockRecords($row, $entityTypeModel);
$records += $this->_getProductSuperRelations($row, $entityTypeModel);
return $records;
}
......@@ -79,6 +80,50 @@ class EcomDev_PHPUnit_Model_Mysql4_Fixture_Eav_Catalog_Product extends EcomDev_P
return parent::_getAttributeRecords($row, $attribute, $tableColumns);
}
/**
* Generates records for catalog_product_super_attribute and catalog_product_super_link tables
*
* @param array $row
* @param Mage_Eav_Model_Entity_Type $entityTypeModel
* @return array
* @throws RuntimeException
*/
protected function _getProductSuperRelations($row, $entityTypeModel)
{
$result = array();
if (isset($row['super_attributes']) && is_array($row['super_attributes'])) {
$records = array();
$attributeCodes = $entityTypeModel->getAttributeCollection();
foreach ($row['super_attributes'] as $attributeCode) {
$attributeId = $attributeCodes->getItemByColumnValue('attribute_code',$attributeCode)->getId();
$records[] = array(
'product_id' => $row[$this->_getEntityIdField($entityTypeModel)],
'attribute_id' => $attributeId
);
}
if ($records) {
$result += array('catalog/product_super_attribute' => $records);
}
}
if (isset($row['configurable_children']) && is_array($row['configurable_children'])) {
$records = array();
foreach ($row['configurable_children'] as $childId) {
$records[] = array(
'parent_id' => $row[$this->_getEntityIdField($entityTypeModel)],
'product_id' => $childId
);
}
if ($records) {
$result += array('catalog/product_super_link' => $records);
}
}
return $result;
}
/**
* Generates records for catalog_product_website table
*
......
......@@ -9,7 +9,7 @@ class EcomDev_PHPUnit_Helper
/**
* Helpers container
*
* @var EcomDev_PHPunit_Helper_Interface[]
* @var EcomDev_PHPUnit_Helper_Interface[]
*/
protected static $helpers = array();
......@@ -19,12 +19,12 @@ class EcomDev_PHPUnit_Helper
* If $position is specified, it will use value
* from before or after key as related helper
*
* @param EcomDev_PHPunit_Helper_Interface $helper
* @param EcomDev_PHPUnit_Helper_Interface $helper
* @param bool|array $position
*
* @throws RuntimeException
*/
public static function add(EcomDev_PHPunit_Helper_Interface $helper, $position = false)
public static function add(EcomDev_PHPUnit_Helper_Interface $helper, $position = false)
{
if ($position === false) {
self::$helpers[] = $helper;
......@@ -82,7 +82,7 @@ class EcomDev_PHPUnit_Helper
* if helper for action was not found it returns false
*
* @param $action
* @return bool|EcomDev_PHPunit_Helper_Interface
* @return bool|EcomDev_PHPUnit_Helper_Interface
*/
public static function getByAction($action)
{
......
......@@ -19,7 +19,7 @@
/**
* Base helper implementation
*/
abstract class EcomDev_PHPUnit_Helper_Abstract implements EcomDev_PHPunit_Helper_Interface
abstract class EcomDev_PHPUnit_Helper_Abstract implements EcomDev_PHPUnit_Helper_Interface
{
/**
* @var PHPUnit_Framework_TestCase
......
......@@ -19,7 +19,7 @@
/**
* Interface for PHPUnit Test Helpers
*/
interface EcomDev_PHPunit_Helper_Interface
interface EcomDev_PHPUnit_Helper_Interface
{
/**
* Checks if helper has action for invocation
......
......@@ -7,7 +7,7 @@
* These methods are invoked when test setUp() or tearDown() is executed
*
*/
interface EcomDev_PHPUnit_Helper_Listener_Interface extends EcomDev_PHPunit_Helper_Interface
interface EcomDev_PHPUnit_Helper_Listener_Interface extends EcomDev_PHPUnit_Helper_Interface
{
public function setUp();
......
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