Commit baa95258 authored by Ivan Chepurnyi's avatar Ivan Chepurnyi

! Merge latest dev branch changes to refactor branch. Remove temporary...

! Merge latest dev branch changes to refactor branch. Remove temporary attribute loader, for later refactor by another developer
parents 358b1a68 25eb67c4
...@@ -76,7 +76,7 @@ class EcomDev_PHPUnit_Controller_Request_Http ...@@ -76,7 +76,7 @@ class EcomDev_PHPUnit_Controller_Request_Http
* *
* @param string|array $name * @param string|array $name
* @param string|null $value * @param string|null $value
* @return EcomDev_PHPUnit_Controller_Request_Http_Test * @return EcomDev_PHPUnit_Controller_Request_Http
*/ */
public function setCookie($name, $value) public function setCookie($name, $value)
{ {
...@@ -88,7 +88,7 @@ class EcomDev_PHPUnit_Controller_Request_Http ...@@ -88,7 +88,7 @@ class EcomDev_PHPUnit_Controller_Request_Http
* Sets more than one cookie * Sets more than one cookie
* *
* @param array $cookies * @param array $cookies
* @return EcomDev_PHPUnit_Controller_Request_Http_Test * @return EcomDev_PHPUnit_Controller_Request_Http
*/ */
public function setCookies(array $cookies) public function setCookies(array $cookies)
{ {
...@@ -99,7 +99,7 @@ class EcomDev_PHPUnit_Controller_Request_Http ...@@ -99,7 +99,7 @@ class EcomDev_PHPUnit_Controller_Request_Http
/** /**
* Resets all cookies for the test request * Resets all cookies for the test request
* *
* @return EcomDev_PHPUnit_Controller_Request_Http_Test * @return EcomDev_PHPUnit_Controller_Request_Http
*/ */
public function resetCookies() public function resetCookies()
{ {
...@@ -110,7 +110,7 @@ class EcomDev_PHPUnit_Controller_Request_Http ...@@ -110,7 +110,7 @@ class EcomDev_PHPUnit_Controller_Request_Http
/** /**
* Resets query for the current request * Resets query for the current request
* *
* @return EcomDev_PHPUnit_Controller_Request_Http_Test * @return EcomDev_PHPUnit_Controller_Request_Http
*/ */
public function resetQuery() public function resetQuery()
{ {
...@@ -121,7 +121,7 @@ class EcomDev_PHPUnit_Controller_Request_Http ...@@ -121,7 +121,7 @@ class EcomDev_PHPUnit_Controller_Request_Http
/** /**
* Resets $_POST superglobal for test request * Resets $_POST superglobal for test request
* *
* @return EcomDev_PHPUnit_Controller_Request_Http_Test * @return EcomDev_PHPUnit_Controller_Request_Http
*/ */
public function resetPost() public function resetPost()
{ {
...@@ -132,7 +132,7 @@ class EcomDev_PHPUnit_Controller_Request_Http ...@@ -132,7 +132,7 @@ class EcomDev_PHPUnit_Controller_Request_Http
/** /**
* Resets user defined request params for test request * Resets user defined request params for test request
* *
* @return EcomDev_PHPUnit_Controller_Request_Http_Test * @return EcomDev_PHPUnit_Controller_Request_Http
*/ */
public function resetParams() public function resetParams()
{ {
...@@ -143,7 +143,7 @@ class EcomDev_PHPUnit_Controller_Request_Http ...@@ -143,7 +143,7 @@ class EcomDev_PHPUnit_Controller_Request_Http
/** /**
* Resets internal properties to its default values * Resets internal properties to its default values
* *
* @return EcomDev_PHPUnit_Controller_Request_Http_Test * @return EcomDev_PHPUnit_Controller_Request_Http
*/ */
public function resetInternalProperties() public function resetInternalProperties()
{ {
...@@ -183,7 +183,7 @@ class EcomDev_PHPUnit_Controller_Request_Http ...@@ -183,7 +183,7 @@ class EcomDev_PHPUnit_Controller_Request_Http
* *
* @param string $name * @param string $name
* @param string $value * @param string $value
* @return EcomDev_PHPUnit_Controller_Request_Http_Test * @return EcomDev_PHPUnit_Controller_Request_Http
*/ */
public function setHeader($name, $value) public function setHeader($name, $value)
{ {
...@@ -199,7 +199,7 @@ class EcomDev_PHPUnit_Controller_Request_Http ...@@ -199,7 +199,7 @@ class EcomDev_PHPUnit_Controller_Request_Http
* headers list is an associative array * headers list is an associative array
* *
* @param array $headers * @param array $headers
* @return EcomDev_PHPUnit_Controller_Request_Http_Test * @return EcomDev_PHPUnit_Controller_Request_Http
*/ */
public function setHeaders(array $headers) public function setHeaders(array $headers)
{ {
...@@ -229,7 +229,7 @@ class EcomDev_PHPUnit_Controller_Request_Http ...@@ -229,7 +229,7 @@ class EcomDev_PHPUnit_Controller_Request_Http
/** /**
* Resets headers in test request * Resets headers in test request
* *
* @return EcomDev_PHPUnit_Controller_Request_Http_Test * @return EcomDev_PHPUnit_Controller_Request_Http
*/ */
public function resetHeaders() public function resetHeaders()
{ {
...@@ -255,7 +255,7 @@ class EcomDev_PHPUnit_Controller_Request_Http ...@@ -255,7 +255,7 @@ class EcomDev_PHPUnit_Controller_Request_Http
* *
* @param string $name * @param string $name
* @param string $value * @param string $value
* @return EcomDev_PHPUnit_Controller_Request_Http_Test * @return EcomDev_PHPUnit_Controller_Request_Http
*/ */
public function setServer($name, $value) public function setServer($name, $value)
{ {
...@@ -272,7 +272,7 @@ class EcomDev_PHPUnit_Controller_Request_Http ...@@ -272,7 +272,7 @@ class EcomDev_PHPUnit_Controller_Request_Http
* Sets multiple values for $_SERVER superglobal in test request * Sets multiple values for $_SERVER superglobal in test request
* *
* @param array $values * @param array $values
* @return EcomDev_PHPUnit_Controller_Request_Http_Test * @return EcomDev_PHPUnit_Controller_Request_Http
*/ */
public function setServers(array $values) public function setServers(array $values)
{ {
...@@ -285,7 +285,7 @@ class EcomDev_PHPUnit_Controller_Request_Http ...@@ -285,7 +285,7 @@ class EcomDev_PHPUnit_Controller_Request_Http
/** /**
* Resets $_SERVER superglobal to previous state * Resets $_SERVER superglobal to previous state
* *
* @return EcomDev_PHPUnit_Controller_Request_Http_Test * @return EcomDev_PHPUnit_Controller_Request_Http
*/ */
public function resetServer() public function resetServer()
{ {
...@@ -307,7 +307,7 @@ class EcomDev_PHPUnit_Controller_Request_Http ...@@ -307,7 +307,7 @@ class EcomDev_PHPUnit_Controller_Request_Http
* Sets request method for test request * Sets request method for test request
* *
* @param string $requestMethod * @param string $requestMethod
* @return EcomDev_PHPUnit_Controller_Request_Http_Test * @return EcomDev_PHPUnit_Controller_Request_Http
*/ */
public function setMethod($requestMethod) public function setMethod($requestMethod)
{ {
...@@ -320,7 +320,7 @@ class EcomDev_PHPUnit_Controller_Request_Http ...@@ -320,7 +320,7 @@ class EcomDev_PHPUnit_Controller_Request_Http
* accepts boolean flag for HTTPS * accepts boolean flag for HTTPS
* *
* @param boolean $flag * @param boolean $flag
* @return EcomDev_PHPUnit_Controller_Request_Http_Test * @return EcomDev_PHPUnit_Controller_Request_Http
*/ */
public function setIsSecure($flag = true) public function setIsSecure($flag = true)
{ {
...@@ -365,7 +365,7 @@ class EcomDev_PHPUnit_Controller_Request_Http ...@@ -365,7 +365,7 @@ class EcomDev_PHPUnit_Controller_Request_Http
/** /**
* Resets all request data for test * Resets all request data for test
* *
* @return EcomDev_PHPUnit_Controller_Request_Http_Test * @return EcomDev_PHPUnit_Controller_Request_Http
*/ */
public function reset() public function reset()
{ {
......
...@@ -48,6 +48,14 @@ class EcomDev_PHPUnit_Model_Config extends Mage_Core_Model_Config ...@@ -48,6 +48,14 @@ class EcomDev_PHPUnit_Model_Config extends Mage_Core_Model_Config
*/ */
protected $_replaceInstanceCreation = array(); protected $_replaceInstanceCreation = array();
/**
* No cache sections should be cached,
* in favor to get rid of buggy config set options
*
* @var array
*/
protected $_cacheSections = array();
/** /**
* Load config data from DB * Load config data from DB
* *
......
...@@ -34,6 +34,9 @@ class EcomDev_PHPUnit_Model_Fixture ...@@ -34,6 +34,9 @@ class EcomDev_PHPUnit_Model_Fixture
// Processors configuration path // Processors configuration path
const XML_PATH_FIXTURE_PROCESSORS = 'phpunit/suite/fixture/processors'; const XML_PATH_FIXTURE_PROCESSORS = 'phpunit/suite/fixture/processors';
// Configuration path for attribute loaders
const XML_PATH_FIXTURE_ATTRIBUTE_LOADERS = 'phpunit/suite/fixture/attribute';
// Default eav loader class node in loaders configuration // Default eav loader class node in loaders configuration
/* @deprecated since 0.3.0 */ /* @deprecated since 0.3.0 */
const DEFAULT_EAV_LOADER_NODE = EcomDev_PHPUnit_Model_Fixture_Processor_Eav::DEFAULT_EAV_LOADER_NODE; const DEFAULT_EAV_LOADER_NODE = EcomDev_PHPUnit_Model_Fixture_Processor_Eav::DEFAULT_EAV_LOADER_NODE;
...@@ -289,7 +292,7 @@ class EcomDev_PHPUnit_Model_Fixture ...@@ -289,7 +292,7 @@ class EcomDev_PHPUnit_Model_Fixture
} }
/** /**
* Check that current fixture scope is equal to SCOPE_LOCAL * Check that current fixture scope is equal to SCOPE_DEFAULT
* *
* @return boolean * @return boolean
*/ */
...@@ -450,7 +453,7 @@ class EcomDev_PHPUnit_Model_Fixture ...@@ -450,7 +453,7 @@ class EcomDev_PHPUnit_Model_Fixture
} }
} }
// Clear fixture for getting rid of duoble processing // Clear fixture for getting rid of double processing
$this->_fixture = array(); $this->_fixture = array();
return $this; return $this;
} }
...@@ -510,6 +513,7 @@ class EcomDev_PHPUnit_Model_Fixture ...@@ -510,6 +513,7 @@ class EcomDev_PHPUnit_Model_Fixture
* @param array $configuration * @param array $configuration
* @return EcomDev_PHPUnit_Model_Fixture * @return EcomDev_PHPUnit_Model_Fixture
* @deprecated since 0.3.0 * @deprecated since 0.3.0
* @throws InvalidArgumentException in case if wrong configuration array supplied
*/ */
protected function _applyConfig($configuration) protected function _applyConfig($configuration)
{ {
...@@ -522,6 +526,7 @@ class EcomDev_PHPUnit_Model_Fixture ...@@ -522,6 +526,7 @@ class EcomDev_PHPUnit_Model_Fixture
* @param array $configuration * @param array $configuration
* @return EcomDev_PHPUnit_Model_Fixture * @return EcomDev_PHPUnit_Model_Fixture
* @deprecated since 0.3.0 * @deprecated since 0.3.0
* @throws InvalidArgumentException in case of wrong configuration data passed
*/ */
protected function _applyConfigXml($configuration) protected function _applyConfigXml($configuration)
{ {
...@@ -607,7 +612,36 @@ class EcomDev_PHPUnit_Model_Fixture ...@@ -607,7 +612,36 @@ class EcomDev_PHPUnit_Model_Fixture
*/ */
protected function _getEavLoader($entityType) protected function _getEavLoader($entityType)
{ {
return false; return $this->_getComplexLoader($entityType, 'EAV');
}
/**
* Retrieves the loader for a particular entity type and data type
*
* @throws InvalidArgumentException
* @param string $entityType
* @param string $dataType
* @return EcomDev_PHPUnit_Model_Mysql4_Fixture
*/
protected function _getComplexLoader($entityType, $dataType)
{
if(!$dataType) {
throw new InvalidArgumentException('Must specify a data type for the loader');
}
$reflection = EcomDev_Utils_Reflection::getRelflection($this);
$loaders = Mage::getConfig()->getNode($reflection->getConstant("XML_PATH_FIXTURE_{$dataType}_LOADERS"));
if (isset($loaders->$entityType)) {
$classAlias = (string)$loaders->$entityType;
} elseif (isset($loaders->{self::DEFAULT_EAV_LOADER_NODE})) {
$classAlias = (string)$loaders->{self::DEFAULT_EAV_LOADER_NODE};
} else {
$classAlias = self::DEFAULT_EAV_LOADER_CLASS;
}
return Mage::getResourceSingleton($classAlias);
} }
/** /**
...@@ -747,7 +781,6 @@ class EcomDev_PHPUnit_Model_Fixture ...@@ -747,7 +781,6 @@ class EcomDev_PHPUnit_Model_Fixture
*/ */
protected function _discardVfs() protected function _discardVfs()
{ {
$this->getVfs()->discard();
return $this; return $this;
} }
} }
...@@ -25,8 +25,12 @@ ...@@ -25,8 +25,12 @@
*/ */
interface EcomDev_PHPUnit_Model_Fixture_Interface extends EcomDev_PHPUnit_Model_Test_Loadable_Interface interface EcomDev_PHPUnit_Model_Fixture_Interface extends EcomDev_PHPUnit_Model_Test_Loadable_Interface
{ {
/** Local scope - used for fixtures that apply only to the current test */
const SCOPE_LOCAL = 'local'; const SCOPE_LOCAL = 'local';
/** Shared scope - used for fixtures that apply to the current test class */
const SCOPE_SHARED = 'shared'; const SCOPE_SHARED = 'shared';
/** Default scope - used for storing data that exists in database before tests are run */
const SCOPE_DEFAULT = 'default';
/** /**
* Sets fixture options * Sets fixture options
...@@ -91,6 +95,14 @@ interface EcomDev_PHPUnit_Model_Fixture_Interface extends EcomDev_PHPUnit_Model_ ...@@ -91,6 +95,14 @@ interface EcomDev_PHPUnit_Model_Fixture_Interface extends EcomDev_PHPUnit_Model_
*/ */
public function setScope($scope); public function setScope($scope);
/**
* Check that current fixture scope is equal to SCOPE_DEFAULT
*
* @abstract
* @return boolean
*/
public function isScopeDefault();
/** /**
* Check that current fixture scope is equal to SCOPE_SHARED * Check that current fixture scope is equal to SCOPE_SHARED
* *
......
<?php
/**
* PHP Unit test suite for Magento
*
* NOTICE OF LICENSE
*
* This source file is subject to the Open Software License (OSL 3.0)
* that is bundled with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://opensource.org/licenses/osl-3.0.php
*
* @category EcomDev
* @package EcomDev_PHPUnit
* @copyright Copyright (c) 2012 EcomDev BV (http://www.ecomdev.org)
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
* @author Ivan Chepurnyi <ivan.chepurnyi@ecomdev.org>
* @author Steve Rice <srice@endertech.com>
*/
abstract class EcomDev_PHPUnit_Model_Mysql4_Fixture_Attribute_Abstract
extends EcomDev_PHPUnit_Model_Mysql4_Fixture_Complex_Abstract
{
protected $_setupModel = 'Mage_Eav_Model_Entity_Setup';
/**
* @param string $entityType
* @return array
*/
public function loadDefaultAttributes($entityType)
{
/** @var $eavConfig Mage_Eav_Model_Config */
$eavConfig = Mage::getSingleton('eav/config');
$attributeCodes = $eavConfig->getEntityAttributeCodes($entityType);
return $attributeCodes;
}
/**
* Loads EAV attribute into DB tables
*
* @throws UnexpectedValueException
* @throws InvalidArgumentException
* @param string $entityType
* @param array $values
*/
public function loadAttribute($entityType, $values)
{
/** @var $eavConfig Mage_Eav_Model_Config */
$eavConfig = Mage::getSingleton('eav/config');
/** @var $entityTypeModel Mage_Eav_Model_Entity_Type */
$entityTypeModel = $eavConfig->getEntityType($entityType);
$entityModel = $entityTypeModel->getEntity();
//use entity model to figure out setup class
$entityReflection = EcomDev_Utils_Reflection::getRelflection($entityModel);
$classArray = explode('_', $entityReflection->getName());
$moduleName = $classArray[0] . '_' . $classArray[1];
$eavSetupModel = $this->_getSetupModelForModule($moduleName);
foreach ($values as $value) {
if (!isset($value['attribute_code'])) {
throw new InvalidArgumentException('Attribute definition must contain attribute_code');
}
/** @var $eavSetupModel Mage_Eav_Model_Entity_Setup */
$eavSetupModel->addAttribute($entityTypeModel->getEntityTypeCode(), $value['attribute_code'], $value);
}
}
/**
* Remove fixture-generated attributes from database
*
* @param string $entityType
* @param array $attributeCodes
* @return EcomDev_PHPUnit_Model_Mysql4_Fixture_Attribute_Abstract
* @throws EcomDev_PHPUnit_Model_Mysql4_Fixture_Exception
*/
public function cleanAttributes($entityType, array $attributeCodes)
{
$eavSetup = new Mage_Eav_Model_Entity_Setup('core_setup');
try {
//delete entry from eav/attribute and allow FK cascade to delete all related values
$this->_getWriteAdapter()
->delete(
$this->getTable('eav/attribute'),
array(
'entity_type_id = ?' => $eavSetup->getEntityTypeId($entityType),
'attribute_code IN (?)' => $attributeCodes,
)
);
$this->_getWriteAdapter()->commit();
} catch (Exception $e) {
throw new EcomDev_PHPUnit_Model_Mysql4_Fixture_Exception(
sprintf('Unable to clear records for a table "%s"', 'eav/attribute'),
$e
);
}
return $this;
}
/**
* Reset autoincrement value of all EAV attribute tables or those associated with an entity type
*
* @throws EcomDev_PHPUnit_Model_Mysql4_Fixture_Exception
* @param string $entityType
* @return EcomDev_PHPUnit_Model_Mysql4_Fixture_Attribute_Abstract
*/
public function resetAttributesAutoIncrement($entityType = null)
{
//@TODO track which tables are altered
if ($entityType !== null) {
/** @var $eavConfig Mage_Eav_Model_Config */
$eavConfig = Mage::getSingleton('eav/config');
/** @var $entityTypeModel Mage_Eav_Model_Entity_Type */
$entityTypeModel = $eavConfig->getEntityType($entityType);
$this->resetTableAutoIncrement($entityTypeModel->getAdditionalAttributeTable());
} else {
//@TODO don't hardcode these
$this->resetTableAutoIncrement('eav/attribute');
$this->resetTableAutoIncrement('eav/attribute_set');
$this->resetTableAutoIncrement('eav/attribute_group');
$this->resetTableAutoIncrement('eav/attribute_label');
$this->resetTableAutoIncrement('eav/attribute_option');
$this->resetTableAutoIncrement('eav/attribute_option_value');
}
return $this;
}
/**
* Reset autoincrement value of a table
*
* @param string $table
* @return EcomDev_PHPUnit_Model_Mysql4_Fixture_Attribute_Abstract
* @throws EcomDev_PHPUnit_Model_Mysql4_Fixture_Exception
*/
public function resetTableAutoIncrement($table)
{
try {
//reset table auto_increment to maximum value in table
$this->_getWriteAdapter()->query("ALTER TABLE `{$this->getTable($table)}` AUTO_INCREMENT = 1");
} catch (Exception $e) {
throw new EcomDev_PHPUnit_Model_Mysql4_Fixture_Exception(
sprintf('Unable to reset autoincrement for table "%s"', $table),
$e
);
}
return $this;
}
/**
* Get the setup model used by a Magento module
*
* @param $moduleName
* @return mixed
* @throws UnexpectedValueException
*/
protected function _getSetupModelForModule($moduleName)
{
$resources = Mage::getConfig()->getNode('global/resources')->children();
$resourceName = 'eav_setup';
$className = 'Mage_Eav_Model_Entity_Setup';
foreach ($resources as $resName => $resource) {
if (!$resource->setup) {
continue;
}
if (isset($resource->setup->module) && $resource->setup->module == $moduleName
&& isset($resource->setup->class)) {
$className = $resource->setup->getClassName();
$resourceName = $resName;
break;
}
}
$setupModel = new $className($resourceName);
$setupReflection = EcomDev_Utils_Reflection::getRelflection($setupModel);
if (!$setupReflection->hasMethod('addAttribute')) {
throw new UnexpectedValueException('Problem loading EAV setup model');
}
return $setupModel;
}
}
<?php
/**
* PHP Unit test suite for Magento
*
* NOTICE OF LICENSE
*
* This source file is subject to the Open Software License (OSL 3.0)
* that is bundled with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://opensource.org/licenses/osl-3.0.php
*
* @category EcomDev
* @package EcomDev_PHPUnit
* @copyright Copyright (c) 2012 EcomDev BV (http://www.ecomdev.org)
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
* @author Ivan Chepurnyi <ivan.chepurnyi@ecomdev.org>
* @author Steve Rice <srice@endertech.com>
*/
class EcomDev_PHPUnit_Model_Mysql4_Fixture_Attribute_Default
extends EcomDev_PHPUnit_Model_Mysql4_Fixture_Attribute_Abstract
{
}
<?php
/**
* PHP Unit test suite for Magento
*
* NOTICE OF LICENSE
*
* This source file is subject to the Open Software License (OSL 3.0)
* that is bundled with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://opensource.org/licenses/osl-3.0.php
*
* @category EcomDev
* @package EcomDev_PHPUnit
* @copyright Copyright (c) 2012 EcomDev BV (http://www.ecomdev.org)
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
* @author Ivan Chepurnyi <ivan.chepurnyi@ecomdev.org>
* @author Steve Rice <srice@endertech.com>
*/
abstract class EcomDev_PHPUnit_Model_Mysql4_Fixture_Complex_Abstract extends EcomDev_PHPUnit_Model_Mysql4_Fixture
{
/**
* Fixture options
*
* @var array
*/
protected $_options = array();
/**
* Fixture model
*
* @var EcomDev_PHPUnit_Model_Fixture_Interface
*/
protected $_fixture = null;
/**
* Inject fixture model into complex loader
*
* @param EcomDev_PHPUnit_Model_Fixture_Interface $fixture
* @return EcomDev_PHPUnit_Model_Mysql4_Fixture_Complex_Abstract
*/
public function setFixture($fixture)
{
$this->_fixture = $fixture;
return $this;
}
/**
* Set fixture options
*
* @param array $options
* @return EcomDev_PHPUnit_Model_Mysql4_Fixture_Complex_Abstract
*/
public function setOptions(array $options)
{
$this->_options = $options;
return $this;
}
}
...@@ -20,7 +20,8 @@ ...@@ -20,7 +20,8 @@
* Base implementation of EAV fixtures loader * Base implementation of EAV fixtures loader
* *
*/ */
abstract class EcomDev_PHPUnit_Model_Mysql4_Fixture_Eav_Abstract extends EcomDev_PHPUnit_Model_Mysql4_Fixture abstract class EcomDev_PHPUnit_Model_Mysql4_Fixture_Eav_Abstract
extends EcomDev_PHPUnit_Model_Mysql4_Fixture_Complex_Abstract
{ {
/** /**
* List of indexers required to build * List of indexers required to build
...@@ -29,20 +30,6 @@ abstract class EcomDev_PHPUnit_Model_Mysql4_Fixture_Eav_Abstract extends EcomDev ...@@ -29,20 +30,6 @@ abstract class EcomDev_PHPUnit_Model_Mysql4_Fixture_Eav_Abstract extends EcomDev
*/ */
protected $_requiredIndexers = array(); protected $_requiredIndexers = array();
/**
* Fixture options
*
* @var array
*/
protected $_options = array();
/**
* Fixture model
*
* @var EcomDev_PHPUnit_Model_Fixture_Interface
*/
protected $_fixture = null;
/** /**
* Retrieve required indexers for re-building * Retrieve required indexers for re-building
* *
...@@ -53,29 +40,6 @@ abstract class EcomDev_PHPUnit_Model_Mysql4_Fixture_Eav_Abstract extends EcomDev ...@@ -53,29 +40,6 @@ abstract class EcomDev_PHPUnit_Model_Mysql4_Fixture_Eav_Abstract extends EcomDev
return $this->_requiredIndexers; return $this->_requiredIndexers;
} }
/**
* Sets fixture model to EAV loader
*
* @param EcomDev_PHPUnit_Model_Fixture_Interface $fixture
*/
public function setFixture($fixture)
{
$this->_fixture = $fixture;
return $this;
}
/**
* Set fixture options
*
* @param array $options
* @return EcomDev_PHPUnit_Model_Mysql4_Fixture_Eav_Abstract
*/
public function setOptions(array $options)
{
$this->_options = $options;
return $this;
}
/** /**
* Add indexer by specific code to required indexers list * Add indexer by specific code to required indexers list
* *
...@@ -98,6 +62,7 @@ abstract class EcomDev_PHPUnit_Model_Mysql4_Fixture_Eav_Abstract extends EcomDev ...@@ -98,6 +62,7 @@ abstract class EcomDev_PHPUnit_Model_Mysql4_Fixture_Eav_Abstract extends EcomDev
*/ */
public function cleanEntity($entityType) public function cleanEntity($entityType)
{ {
/** @var $entityTypeModel Mage_Eav_Model_Entity_Type */
$entityTypeModel = Mage::getSingleton('eav/config')->getEntityType($entityType); $entityTypeModel = Mage::getSingleton('eav/config')->getEntityType($entityType);
$this->cleanTable($entityTypeModel->getEntityTable()); $this->cleanTable($entityTypeModel->getEntityTable());
return $this; return $this;
...@@ -123,6 +88,7 @@ abstract class EcomDev_PHPUnit_Model_Mysql4_Fixture_Eav_Abstract extends EcomDev ...@@ -123,6 +88,7 @@ abstract class EcomDev_PHPUnit_Model_Mysql4_Fixture_Eav_Abstract extends EcomDev
} }
} }
/** @var $entityTypeModel Mage_Eav_Model_Entity_Type */
$entityTypeModel = Mage::getSingleton('eav/config')->getEntityType($entityType); $entityTypeModel = Mage::getSingleton('eav/config')->getEntityType($entityType);
...@@ -160,12 +126,13 @@ abstract class EcomDev_PHPUnit_Model_Mysql4_Fixture_Eav_Abstract extends EcomDev ...@@ -160,12 +126,13 @@ abstract class EcomDev_PHPUnit_Model_Mysql4_Fixture_Eav_Abstract extends EcomDev
// Preparing simple attributes records // Preparing simple attributes records
foreach ($entityTypeModel->getAttributeCollection() as $attribute) { foreach ($entityTypeModel->getAttributeCollection() as $attribute) {
/** @var $attribute Mage_Eav_Model_Entity_Attribute */
$attributeBackendTable = $attribute->getBackendTable(); $attributeBackendTable = $attribute->getBackendTable();
if (!$attribute->isStatic() if (!$attribute->isStatic()
&& $attributeBackendTable && $attributeBackendTable
&& isset($attributeTableColumns[$attributeBackendTable])) { && isset($attributeTableColumns[$attributeBackendTable])) {
// Prepearing data for insert per attribute table // Preparing data for insert per attribute table
$attributeRecords = $this->_getAttributeRecords( $attributeRecords = $this->_getAttributeRecords(
$row, $row,
$attribute, $attribute,
......
...@@ -87,6 +87,12 @@ ...@@ -87,6 +87,12 @@
<tables>ecomdev_phpunit/fixture_processor_tables</tables> <tables>ecomdev_phpunit/fixture_processor_tables</tables>
<vfs>ecomdev_phpunit/fixture_processor_vfs</vfs> <vfs>ecomdev_phpunit/fixture_processor_vfs</vfs>
</processors> </processors>
<attribute>
<!-- Fixture loaders for EAV attributes
Default can be used but does not support extra attribute table configuration -->
<default>ecomdev_phpunit/fixture_attribute_default</default>
<!--<catalog_product>ecomdev_phpunit/fixture_attribute_catalog_product</catalog_product>-->
</attribute>
<eav> <eav>
<!-- Here goes the list of fixture loaders for EAV <!-- Here goes the list of fixture loaders for EAV
If no fixture loader is specified for entity, then default will be used If no fixture loader is specified for entity, then default will be used
......
{
"name": "ivanchepurnyi/ecomdev_phpunit",
"license": "OSL-3.0",
"type": "magento-module",
"description": "Magento PHPUnit Integration",
"homepage": "http://www.ecomdev.org/shop/code-testing/php-unit-test-suite.html",
"require": {
"magento-hackathon/magento-composer-installer": "dev-master",
"phpunit/phpunit": "3.6.*"
},
"authors":[
{
"name":"Ivan Chepurnyi"
}
]
}
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