/** * Contructor adds test groups defined on global level * and adds additional logic for test names retrieval * * (non-PHPdoc) * @see PHPUnit_Framework_TestSuite::__construct() */ public function __construct($theClass = '', $groups = array()) { if (!$theClass instanceof ReflectionClass) { $theClass = Mage_Utils_Reflection::getRelflection($theClass); } // Check annotations for test case name $annotations = PHPUnit_Util_Test::parseTestMethodAnnotations($theClass->getName()); if (isset($annotations['name'])) { $this->suiteName = $annotations['name']; } // Creates all test instances parent::__construct($theClass); // Just sort-out them by our internal groups foreach ($groups as $group) { $this->groups[$group] = $this->tests(); } foreach ($this->tests() as $test) { if ($test instanceof PHPUnit_Framework_TestSuite) { /* @todo * Post an issue into PHPUnit bugtracker for * impossiblity for specifying group by parent test case * Becuase it is a very dirty hack :( **/ $testGroups = array(); foreach ($groups as $group) { $testGroups[$group] = $test->tests(); } Mage_Utils_Reflection::setRestrictedPropertyValue($test, 'groups', $testGroups); } } // Remove ungrouped tests group, if it exists if (isset($this->groups[self::NO_GROUP_KEYWORD])) { unset($this->groups[self::NO_GROUP_KEYWORD]); } }
/** * Resets translator data * * @return Mage_Test_Model_App_Area */ public function resetTranslate() { $translator = $this->_application->getTranslator(); Mage_Utils_Reflection::setRestrictedPropertyValue($translator, '_config', null); Mage_Utils_Reflection::setRestrictedPropertyValue($translator, '_locale', null); Mage_Utils_Reflection::setRestrictedPropertyValue($translator, '_cacheId', null); Mage_Utils_Reflection::setRestrictedPropertyValue($translator, '_translateInline', null); Mage_Utils_Reflection::setRestrictedPropertyValue($translator, '_dataScope', null); Mage_Utils_Reflection::setRestrictedPropertyValue($translator, '_data', array()); return $this; }
/** * Overridden to fix issue with flat tables existance mark * (non-PHPdoc) * @see Mage_Test_Model_Mysql4_Fixture_Eav_Abstract::loadEntity() */ public function loadEntity($entityType, $values) { // Fix of Product Flat Indexer Mage_Utils_Reflection::setRestrictedPropertyValue(Mage::getResourceSingleton('catalog/product_flat_indexer'), '_existsFlatTables', array()); return parent::loadEntity($entityType, $values); }
/** * Discard test scope for application, returns all the objects from live version * */ public static function discardTestScope() { // Setting environment variables for unit tests Mage_Utils_Reflection::setRestrictedPropertyValue('Mage', '_app', self::$_oldApplication); Mage_Utils_Reflection::setRestrictedPropertyValue('Mage', '_config', self::$_oldConfig); Mage_Utils_Reflection::setRestrictedPropertyValue('Mage', '_events', self::$_oldEventCollection); Mage_Utils_Reflection::setRestrictedPropertyValue('Mage', '_registry', self::$_oldRegistry); }
/** * Setting config value with applying the values to stores and websites * * @param string $path * @param string $value * @return Mage_Test_Model_Fixture */ protected function _setConfigNodeValue($path, $value) { $pathArray = explode('/', $path); $scope = array_shift($pathArray); switch ($scope) { case 'stores': $storeCode = array_shift($pathArray); Mage::app()->getStore($storeCode)->setConfig(implode('/', $pathArray), $value); break; case 'websites': $websiteCode = array_shift($pathArray); $website = Mage::app()->getWebsite($websiteCode); Mage_Utils_Reflection::setRestrictedPropertyValue($website, '_configCache', array()); // Should change value // Should change value default: Mage::getConfig()->setNode($path, $value); break; } return $this; }