From 93f38e9b3c74fb61df0da2ef5047aeca64a4356a Mon Sep 17 00:00:00 2001 From: mage2-team Date: Thu, 7 Jun 2012 15:01:12 -0700 Subject: [PATCH] Update as of 6/7/2012 * Fixed various crashes of visual design editor * Fixed some layouts that caused visual design editor toolbar disappearing, also fixed some confusing page type labels * Eliminated "after commit callback" workaround from integration tests by implementing "transparent transactions" capability in integration testing framework * Refactored admin authentication/authorization in RSS module. Removed program termination and covered the controllers with tests * Removed HTML-report feature of copy-paste detector which never worked anyway (`dev/tests/static/framework/Inspection/CopyPasteDetector/html_report.xslt` and all related code) * Github requests: ** [#19](https://github.com/magento/magento2/pull/19) Implemented "soft" dependency between modules and performed several improvements in the related code, covered with tests --- CHANGELOG.markdown | 10 + app/Mage.php | 19 +- .../core/Mage/Api2/view/adminhtml/layout.xml | 4 +- .../core/Mage/Catalog/view/frontend/msrp.xml | 9 +- .../Mage/Checkout/view/frontend/layout.xml | 18 +- app/code/core/Mage/Core/Helper/Http.php | 59 +++--- app/code/core/Mage/Core/Model/Config.php | 112 +--------- .../core/Mage/Core/Model/Config/Module.php | 193 ++++++++++++++++++ .../core/Mage/Core/view/frontend/layout.xml | 4 - .../DesignEditor/view/frontend/layout.xml | 2 - .../Model/Export/Entity/Product.php | 4 +- app/code/core/Mage/Install/Model/Observer.php | 7 - app/code/core/Mage/Install/etc/config.xml | 8 - .../core/Mage/Oauth/view/adminhtml/layout.xml | 26 +-- .../core/Mage/Oauth/view/frontend/layout.xml | 16 +- .../core/Mage/Paypal/view/frontend/layout.xml | 3 +- .../Mage/PaypalUk/view/frontend/layout.xml | 3 +- app/code/core/Mage/Review/etc/config.xml | 10 - .../core/Mage/Review/view/frontend/layout.xml | 13 -- app/code/core/Mage/Rss/Block/Catalog/New.php | 4 +- .../Mage/Rss/Block/Catalog/NotifyStock.php | 25 +-- .../core/Mage/Rss/Block/Catalog/Review.php | 25 +-- app/code/core/Mage/Rss/Block/Order/New.php | 20 +- .../Mage/Rss/Controller/AdminhtmlAbstract.php | 59 ------ app/code/core/Mage/Rss/Helper/Data.php | 72 ------- app/code/core/Mage/Rss/Model/Observer.php | 76 ------- app/code/core/Mage/Rss/Model/Session.php | 51 ----- .../Rss/controllers/CatalogController.php | 119 ++++++----- .../Mage/Rss/controllers/IndexController.php | 57 ++---- .../Mage/Rss/controllers/OrderController.php | 59 ++++-- app/code/core/Mage/Rss/etc/config.xml | 18 -- .../core/Mage/Rss/view/frontend/layout.xml | 26 +-- .../core/Mage/Sales/view/frontend/layout.xml | 10 +- .../default/iphone/Mage_Catalog/layout.xml | 2 +- .../iphone/Mage_CatalogSearch/layout.xml | 2 +- .../default/iphone/Mage_Checkout/layout.xml | 4 +- .../default/iphone/Mage_Customer/layout.xml | 2 +- .../default/iphone/Mage_Newsletter/layout.xml | 2 +- .../default/iphone/Mage_Page/layout.xml | 2 +- .../default/iphone/Mage_Review/layout.xml | 12 -- .../default/iphone/Mage_Rss/layout.xml | 20 +- .../default/iphone/Mage_Sales/layout.xml | 42 ++-- .../default/iphone/Mage_Wishlist/layout.xml | 8 +- .../default/modern/Mage_Catalog/layout.xml | 2 +- .../default/modern/Mage_Checkout/layout.xml | 2 +- .../default/modern/Mage_Customer/layout.xml | 2 +- .../default/modern/Mage_Review/layout.xml | 12 -- .../default/modern/Mage_Rss/layout.xml | 26 +-- .../default/modern/Mage_Sales/layout.xml | 10 +- .../integration/etc/local-mysql.xml.dist | 9 + .../Magento/Test/Db/Adapter/Mysql.php | 81 ++++++++ .../Test/Db/Adapter/TransactionInterface.php} | 31 ++- .../Test/Listener/Annotation/Fixture.php | 4 +- .../framework/Magento/Test/Request.php | 35 ++++ .../Test/TestCase/ControllerAbstract.php | 32 ++- .../Db/Adapter/TransactionInterfaceTest.php | 106 ++++++++++ .../testsuite/Magento/Test/RequestTest.php | 26 ++- .../controllers/Sales/OrderControllerTest.php | 4 +- .../_files/product_special_price.php} | 7 +- .../Mage/Catalog/_files/products_new.php | 2 + .../Mage/Catalog/_files/two_products.php | 2 +- .../Mage/Core/Model/_files/_layout_update.xml | 2 +- .../test/default/Mage_Core/layout.xml | 2 +- .../testsuite/Mage/Paypal/Model/IpnTest.php | 4 +- .../controllers/HostedproControllerTest.php | 2 +- .../controllers/PayflowControllerTest.php | 4 +- .../PayflowadvancedControllerTest.php | 2 +- .../controllers/StandardControllerTest.php | 4 +- .../_files/reviews.php} | 17 +- .../testsuite/Mage/Rss/Helper/DataTest.php | 70 ------- .../Rss/controllers/CatalogControllerTest.php | 149 +++++++++++--- .../Rss/controllers/IndexControllerTest.php | 69 +++++++ .../Rss/controllers/OrderControllerTest.php | 82 +++++--- .../Mage/Sales/Model/AbstractTest.php | 2 +- .../Model/Order/Payment/TransactionTest.php | 2 +- .../testsuite/Mage/Sales/_files/order.php | 1 + .../Mage/Wishlist/_files/wishlist.php | 2 +- .../testsuite/integrity/LayoutTest.php | 53 +---- .../integrity/modular/TemplateFilesTest.php | 5 +- .../Inspection/CopyPasteDetector/Command.php | 40 ---- .../CopyPasteDetector/html_report.xslt | 98 --------- .../CopyPasteDetector/CommandTest.php | 24 --- .../static/testsuite/Integrity/LayoutTest.php | 77 ++++--- .../static/testsuite/Legacy/LayoutTest.php | 11 +- .../Legacy/_files/obsolete_classes.php | 2 + .../Legacy/_files/obsolete_constants.php | 3 + .../Legacy/_files/obsolete_methods.php | 5 +- .../testsuite/Php/_files/whitelist/core.txt | 1 + .../testsuite/Mage/Core/Helper/HttpTest.php | 103 ++++++++++ .../Mage/Core/Model/Config/ModuleTest.php | 105 ++++++++++ .../module_dependency_circular_input.xml | 43 ++++ .../module_dependency_circular_soft_input.xml | 43 ++++ .../_files/module_dependency_linear_input.xml | 20 +- .../_files/module_dependency_wrong_input.xml} | 30 ++- .../Model/Config/_files/module_filtered.xml | 44 ++++ .../Core/Model/Config/_files/module_input.xml | 53 +++++ .../Model/Config/_files/module_sorted.xml | 50 +++++ 97 files changed, 1613 insertions(+), 1241 deletions(-) create mode 100644 app/code/core/Mage/Core/Model/Config/Module.php delete mode 100644 app/code/core/Mage/Rss/Controller/AdminhtmlAbstract.php delete mode 100644 app/code/core/Mage/Rss/Model/Observer.php delete mode 100644 app/code/core/Mage/Rss/Model/Session.php create mode 100644 dev/tests/integration/framework/Magento/Test/Db/Adapter/Mysql.php rename dev/tests/integration/{testsuite/Mage/Paypal/_files/order_standard_commit_workaround.php => framework/Magento/Test/Db/Adapter/TransactionInterface.php} (56%) create mode 100644 dev/tests/integration/framework/tests/unit/testsuite/Magento/Test/Db/Adapter/TransactionInterfaceTest.php rename dev/tests/integration/testsuite/Mage/{Sales/_files/transactions_commit_workaround.php => Catalog/_files/product_special_price.php} (89%) rename dev/tests/integration/testsuite/Mage/{Sales/_files/order_commit_workaround.php => Review/_files/reviews.php} (61%) delete mode 100644 dev/tests/integration/testsuite/Mage/Rss/Helper/DataTest.php create mode 100644 dev/tests/integration/testsuite/Mage/Rss/controllers/IndexControllerTest.php delete mode 100644 dev/tests/static/framework/Inspection/CopyPasteDetector/html_report.xslt create mode 100644 dev/tests/unit/testsuite/Mage/Core/Helper/HttpTest.php create mode 100644 dev/tests/unit/testsuite/Mage/Core/Model/Config/ModuleTest.php create mode 100644 dev/tests/unit/testsuite/Mage/Core/Model/Config/_files/module_dependency_circular_input.xml create mode 100644 dev/tests/unit/testsuite/Mage/Core/Model/Config/_files/module_dependency_circular_soft_input.xml rename app/code/core/Mage/Rss/view/frontend/nofeed.phtml => dev/tests/unit/testsuite/Mage/Core/Model/Config/_files/module_dependency_linear_input.xml (74%) rename dev/tests/{integration/testsuite/Mage/Paypal/_files/order_express_commit_workaround.php => unit/testsuite/Mage/Core/Model/Config/_files/module_dependency_wrong_input.xml} (50%) create mode 100644 dev/tests/unit/testsuite/Mage/Core/Model/Config/_files/module_filtered.xml create mode 100644 dev/tests/unit/testsuite/Mage/Core/Model/Config/_files/module_input.xml create mode 100644 dev/tests/unit/testsuite/Mage/Core/Model/Config/_files/module_sorted.xml diff --git a/CHANGELOG.markdown b/CHANGELOG.markdown index 5e6d752d30db7..5bc983f1ff3b8 100644 --- a/CHANGELOG.markdown +++ b/CHANGELOG.markdown @@ -1,3 +1,13 @@ +Update as of 6/7/2012 +===================== +* Fixed various crashes of visual design editor +* Fixed some layouts that caused visual design editor toolbar disappearing, also fixed some confusing page type labels +* Eliminated "after commit callback" workaround from integration tests by implementing "transparent transactions" capability in integration testing framework +* Refactored admin authentication/authorization in RSS module. Removed program termination and covered the controllers with tests +* Removed HTML-report feature of copy-paste detector which never worked anyway (`dev/tests/static/framework/Inspection/CopyPasteDetector/html_report.xslt` and all related code) +* Github requests: +** [#19](https://github.com/magento/magento2/pull/19) Implemented "soft" dependency between modules and performed several improvements in the related code, covered with tests + Update as of 5/31/2012 ====================== * Implemented backend authentication independent of `Mage_Adminhtml` module. Authentication can be disabled diff --git a/app/Mage.php b/app/Mage.php index 144bc3ae19ae3..3c97bd4894f73 100644 --- a/app/Mage.php +++ b/app/Mage.php @@ -659,25 +659,10 @@ public static function run($code = '', $type = 'store', $options = array()) Magento_Profiler::stop('mage'); } catch (Mage_Core_Model_Session_Exception $e) { header('Location: ' . self::getBaseUrl()); - die(); } catch (Mage_Core_Model_Store_Exception $e) { - require_once(self::getBaseDir() . DS . 'pub' . DS . 'errors' . DS . '404.php'); - die(); + require_once(self::getBaseDir() . '/pub/errors/404.php'); } catch (Exception $e) { - if (self::isInstalled() || self::$_isDownloader) { - self::printException($e); - exit(); - } - try { - self::dispatchEvent('mage_run_exception', array('exception' => $e)); - if (!headers_sent()) { - header('Location:' . self::getUrl('install')); - } else { - self::printException($e); - } - } catch (Exception $ne) { - self::printException($ne, $e->getMessage()); - } + self::printException($e); } } diff --git a/app/code/core/Mage/Api2/view/adminhtml/layout.xml b/app/code/core/Mage/Api2/view/adminhtml/layout.xml index 0c8689c2494df..3741713b530be 100644 --- a/app/code/core/Mage/Api2/view/adminhtml/layout.xml +++ b/app/code/core/Mage/Api2/view/adminhtml/layout.xml @@ -92,12 +92,12 @@ - + - + diff --git a/app/code/core/Mage/Catalog/view/frontend/msrp.xml b/app/code/core/Mage/Catalog/view/frontend/msrp.xml index f7c19f36bdd34..e7637a1e26e9f 100644 --- a/app/code/core/Mage/Catalog/view/frontend/msrp.xml +++ b/app/code/core/Mage/Catalog/view/frontend/msrp.xml @@ -74,8 +74,7 @@ Default layout, loads most of the pages - - + Mage_Catalog::msrp.js @@ -83,8 +82,7 @@ Default layout, loads most of the pages - - + msrpMage_Catalog_Block_Product_Price @@ -92,8 +90,7 @@ Default layout, loads most of the pages msrpMage_Catalog_Block_Product_Price - - + msrpMage_Catalog_Block_Product_Price diff --git a/app/code/core/Mage/Checkout/view/frontend/layout.xml b/app/code/core/Mage/Checkout/view/frontend/layout.xml index f48c8c02e234e..d305505866b4f 100644 --- a/app/code/core/Mage/Checkout/view/frontend/layout.xml +++ b/app/code/core/Mage/Checkout/view/frontend/layout.xml @@ -90,10 +90,10 @@ Default layout, loads most of the pages - + - + @@ -104,17 +104,17 @@ Default layout, loads most of the pages - + - + - + @@ -434,12 +434,4 @@ One page checkout order review block - - - - - - - - diff --git a/app/code/core/Mage/Core/Helper/Http.php b/app/code/core/Mage/Core/Helper/Http.php index 7efcc5c6d5bf4..6ab4605718d18 100644 --- a/app/code/core/Mage/Core/Helper/Http.php +++ b/app/code/core/Mage/Core/Helper/Http.php @@ -43,63 +43,60 @@ class Mage_Core_Helper_Http extends Mage_Core_Helper_Abstract protected $_remoteAddr; /** - * Validate and retrieve user and password from HTTP + * Extract "login" and "password" credentials from HTTP-request * + * Returns plain array with 2 items: login and password respectively + * + * @param Zend_Controller_Request_Http $request * @return array */ - public function authValidate($headers = null) + public function getHttpAuthCredentials(Zend_Controller_Request_Http $request) { - if(!is_null($headers)) { - $_SERVER = $headers; - } - + $server = $request->getServer(); $user = ''; $pass = ''; - // moshe's fix for CGI - if (empty($_SERVER['HTTP_AUTHORIZATION'])) { - foreach ($_SERVER as $k=>$v) { - if (substr($k, -18)==='HTTP_AUTHORIZATION' && !empty($v)) { - $_SERVER['HTTP_AUTHORIZATION'] = $v; + if (empty($server['HTTP_AUTHORIZATION'])) { + foreach ($server as $k => $v) { + if (substr($k, -18) === 'HTTP_AUTHORIZATION' && !empty($v)) { + $server['HTTP_AUTHORIZATION'] = $v; break; } } } - if (isset($_SERVER['PHP_AUTH_USER']) && isset($_SERVER['PHP_AUTH_PW'])) { - $user = $_SERVER['PHP_AUTH_USER']; - $pass = $_SERVER['PHP_AUTH_PW']; + if (isset($server['PHP_AUTH_USER']) && isset($server['PHP_AUTH_PW'])) { + $user = $server['PHP_AUTH_USER']; + $pass = $server['PHP_AUTH_PW']; } - // IIS Note:: For HTTP Authentication to work with IIS, - // the PHP directive cgi.rfc2616_headers must be set to 0 (the default value). - elseif (!empty($_SERVER['HTTP_AUTHORIZATION'])) { - $auth = $_SERVER['HTTP_AUTHORIZATION']; + /** + * IIS Note: for HTTP authentication to work with IIS, + * the PHP directive cgi.rfc2616_headers must be set to 0 (the default value). + */ + elseif (!empty($server['HTTP_AUTHORIZATION'])) { + $auth = $server['HTTP_AUTHORIZATION']; list($user, $pass) = explode(':', base64_decode(substr($auth, strpos($auth, " ") + 1))); } - elseif (!empty($_SERVER['Authorization'])) { - $auth = $_SERVER['Authorization']; + elseif (!empty($server['Authorization'])) { + $auth = $server['Authorization']; list($user, $pass) = explode(':', base64_decode(substr($auth, strpos($auth, " ") + 1))); } - if (!$user || !$pass) { - $this->authFailed(); - } - return array($user, $pass); } /** - * Send auth failed Headers and exit + * Set "auth failed" headers to the specified response object * + * @param Zend_Controller_Response_Http $response + * @param string $realm */ - public function authFailed() + public function failHttpAuthentication(Zend_Controller_Response_Http $response, $realm) { - Mage::app()->getResponse() - ->setHeader('HTTP/1.1','401 Unauthorized') - ->setHeader('WWW-Authenticate','Basic realm="RSS Feeds"') + $response->setHeader('HTTP/1.1', '401 Unauthorized') + ->setHeader('WWW-Authenticate', 'Basic realm="' . $realm . '"') ->setBody('

401 Unauthorized

') - ->sendResponse(); - exit; + ; } /** diff --git a/app/code/core/Mage/Core/Model/Config.php b/app/code/core/Mage/Core/Model/Config.php index 4fd7e113aebfe..e02e0583fcbf1 100644 --- a/app/code/core/Mage/Core/Model/Config.php +++ b/app/code/core/Mage/Core/Model/Config.php @@ -752,21 +752,6 @@ public function addAllowedModules($module) return $this; } - /** - * Define if module is allowed - * - * @param string $moduleName - * @return bool - */ - protected function _isAllowedModule($moduleName) - { - if (empty($this->_allowedModules)) { - return true; - } else { - return in_array($moduleName, $this->_allowedModules); - } - } - /** * Load declared modules configuration * @@ -776,57 +761,18 @@ protected function _loadDeclaredModules() { $moduleFiles = $this->_getDeclaredModuleFiles(); if (!$moduleFiles) { - return ; + return $this; } Magento_Profiler::start('load_modules_declaration'); - $unsortedConfig = new Mage_Core_Model_Config_Base(); - $unsortedConfig->loadString(''); - $fileConfig = new Mage_Core_Model_Config_Base(); - - // load modules declarations - foreach ($moduleFiles as $file) { - $fileConfig->loadFile($file); + $unsortedConfig = new Mage_Core_Model_Config_Base(''); + foreach ($moduleFiles as $oneConfigFile) { + $fileConfig = new Mage_Core_Model_Config_Base($oneConfigFile); $unsortedConfig->extend($fileConfig); } - $moduleDepends = array(); - foreach ($unsortedConfig->getNode('modules')->children() as $moduleName => $moduleNode) { - if (!$this->_isAllowedModule($moduleName)) { - continue; - } - - $depends = array(); - if ($moduleNode->depends) { - foreach ($moduleNode->depends->children() as $depend) { - $depends[$depend->getName()] = true; - } - } - $moduleDepends[$moduleName] = array( - 'module' => $moduleName, - 'depends' => $depends, - 'active' => ('true' === (string)$moduleNode->active ? true : false), - ); - } - - // check and sort module dependence - $moduleDepends = $this->_sortModuleDepends($moduleDepends); - - // create sorted config - $sortedConfig = new Mage_Core_Model_Config_Base(); - $sortedConfig->loadString(''); - - foreach ($unsortedConfig->getNode()->children() as $nodeName => $node) { - if ($nodeName != 'modules') { - $sortedConfig->getNode()->appendChild($node); - } - } - - foreach ($moduleDepends as $moduleProp) { - $node = $unsortedConfig->getNode('modules/'.$moduleProp['module']); - $sortedConfig->getNode('modules')->appendChild($node); - } + $sortedConfig = new Mage_Core_Model_Config_Module($unsortedConfig, $this->_allowedModules); $this->extend($sortedConfig); @@ -834,54 +780,6 @@ protected function _loadDeclaredModules() return $this; } - /** - * Sort modules and check depends - * - * @param array $modules - * @return array - */ - protected function _sortModuleDepends($modules) - { - foreach ($modules as $moduleName => $moduleProps) { - $depends = $moduleProps['depends']; - foreach ($moduleProps['depends'] as $depend => $true) { - if ($moduleProps['active'] && ((!isset($modules[$depend])) || empty($modules[$depend]['active']))) { - Mage::throwException( - Mage::helper('Mage_Core_Helper_Data')->__('Module "%1$s" requires module "%2$s".', $moduleName, $depend) - ); - } - $depends = array_merge($depends, $modules[$depend]['depends']); - } - $modules[$moduleName]['depends'] = $depends; - } - $modules = array_values($modules); - - $size = count($modules) - 1; - for ($i = $size; $i >= 0; $i--) { - for ($j = $size; $i < $j; $j--) { - if (isset($modules[$i]['depends'][$modules[$j]['module']])) { - $value = $modules[$i]; - $modules[$i] = $modules[$j]; - $modules[$j] = $value; - } - } - } - - $definedModules = array(); - foreach ($modules as $moduleProp) { - foreach ($moduleProp['depends'] as $dependModule => $true) { - if (!isset($definedModules[$dependModule])) { - Mage::throwException( - Mage::helper('Mage_Core_Helper_Data')->__('Module "%1$s" cannot depend on "%2$s".', $moduleProp['module'], $dependModule) - ); - } - } - $definedModules[$moduleProp['module']] = true; - } - - return $modules; - } - /** * Determine whether provided name begins from any available modules, according to namespaces priority * If matched, returns as the matched module "factory" name or a fully qualified module name diff --git a/app/code/core/Mage/Core/Model/Config/Module.php b/app/code/core/Mage/Core/Model/Config/Module.php new file mode 100644 index 0000000000000..93e1c78fece08 --- /dev/null +++ b/app/code/core/Mage/Core/Model/Config/Module.php @@ -0,0 +1,193 @@ +'); + + $moduleDependencies = $this->_loadModuleDependencies($modulesConfig, $allowedModules); + + $this->_checkModuleRequirements($moduleDependencies); + + $moduleDependencies = $this->_sortModuleDependencies($moduleDependencies); + + // create sorted configuration + foreach ($modulesConfig->getNode()->children() as $nodeName => $node) { + if ($nodeName != 'modules') { + $this->getNode()->appendChild($node); + } + } + foreach ($moduleDependencies as $moduleInfo) { + $node = $modulesConfig->getNode('modules/' . $moduleInfo['module']); + $this->getNode('modules')->appendChild($node); + } + } + + /** + * Load dependencies for active & allowed modules into an array structure + * + * @param Mage_Core_Model_Config_Base $modulesConfig + * @param array $allowedModules + * @return array + */ + protected function _loadModuleDependencies(Mage_Core_Model_Config_Base $modulesConfig, array $allowedModules) + { + $result = array(); + foreach ($modulesConfig->getNode('modules')->children() as $moduleName => $moduleNode) { + $isModuleActive = 'true' === (string)$moduleNode->active; + $isModuleAllowed = empty($allowedModules) || in_array($moduleName, $allowedModules); + if (!$isModuleActive || !$isModuleAllowed) { + continue; + } + $dependencies = array(); + if ($moduleNode->depends) { + /** @var $dependencyNode Varien_Simplexml_Element */ + foreach ($moduleNode->depends->children() as $dependencyNode) { + $dependencyModuleName = $dependencyNode->getName(); + $dependencies[$dependencyModuleName] = $this->_getDependencyType($dependencyNode); + } + } + $result[$moduleName] = array( + 'module' => $moduleName, + 'dependencies' => $dependencies, + ); + } + return $result; + } + + /** + * Determine dependency type from XML node that defines module dependency + * + * @param Varien_Simplexml_Element $dependencyNode + * @return string + * @throws UnexpectedValueException + */ + protected function _getDependencyType(Varien_Simplexml_Element $dependencyNode) + { + $result = $dependencyNode->getAttribute('type') ?: self::DEPENDENCY_TYPE_HARD; + if (!in_array($result, array(self::DEPENDENCY_TYPE_HARD, self::DEPENDENCY_TYPE_SOFT))) { + $dependencyNodeXml = trim($dependencyNode->asNiceXml()); + throw new UnexpectedValueException( + "Unknown module dependency type '$result' in declaration '$dependencyNodeXml'." + ); + } + return $result; + } + + /** + * Check whether module requirements are fulfilled + * + * @param array $moduleDependencies + * @throws Magento_Exception + */ + protected function _checkModuleRequirements(array $moduleDependencies) + { + foreach ($moduleDependencies as $moduleName => $moduleInfo) { + foreach ($moduleInfo['dependencies'] as $relatedModuleName => $dependencyType) { + $relatedModuleActive = isset($moduleDependencies[$relatedModuleName]); + if (!$relatedModuleActive && $dependencyType == self::DEPENDENCY_TYPE_HARD) { + throw new Magento_Exception("Module '$moduleName' requires module '$relatedModuleName'."); + } + } + } + } + + /** + * Sort modules until dependent modules go after ones they depend on + * + * @param array $moduleDependencies + * @return array + */ + protected function _sortModuleDependencies(array $moduleDependencies) + { + // add indirect dependencies + foreach ($moduleDependencies as $moduleName => &$moduleInfo) { + $moduleInfo['dependencies'] = $this->_getAllDependencies($moduleDependencies, $moduleName); + } + unset($moduleInfo); + + // "bubble sort" modules until dependent modules go after ones they depend on + $moduleDependencies = array_values($moduleDependencies); + $size = count($moduleDependencies) - 1; + for ($i = $size; $i >= 0; $i--) { + for ($j = $size; $i < $j; $j--) { + if (isset($moduleDependencies[$i]['dependencies'][$moduleDependencies[$j]['module']])) { + $tempValue = $moduleDependencies[$i]; + $moduleDependencies[$i] = $moduleDependencies[$j]; + $moduleDependencies[$j] = $tempValue; + } + } + } + + return $moduleDependencies; + } + + /** + * Recursively compute all dependencies and detect circular ones + * + * @param array $moduleDependencies + * @param string $moduleName + * @param array $usedModules Keep track of used modules to detect circular dependencies + * @return array + * @throws Magento_Exception + */ + protected function _getAllDependencies(array $moduleDependencies, $moduleName, $usedModules = array()) + { + $usedModules[] = $moduleName; + $result = $moduleDependencies[$moduleName]['dependencies']; + foreach (array_keys($result) as $relatedModuleName) { + if (in_array($relatedModuleName, $usedModules)) { + throw new Magento_Exception( + "Module '$moduleName' cannot depend on '$relatedModuleName' since it creates circular dependency." + ); + } + if (empty($moduleDependencies[$relatedModuleName])) { + continue; + } + $relatedDependencies = $this->_getAllDependencies($moduleDependencies, $relatedModuleName, $usedModules); + $result = array_merge($result, $relatedDependencies); + } + return $result; + } +} diff --git a/app/code/core/Mage/Core/view/frontend/layout.xml b/app/code/core/Mage/Core/view/frontend/layout.xml index 4376426a6c8ab..f34c4a6e50715 100644 --- a/app/code/core/Mage/Core/view/frontend/layout.xml +++ b/app/code/core/Mage/Core/view/frontend/layout.xml @@ -30,8 +30,4 @@ - - - - diff --git a/app/code/core/Mage/DesignEditor/view/frontend/layout.xml b/app/code/core/Mage/DesignEditor/view/frontend/layout.xml index 83a5688cc8754..b287e17936d20 100644 --- a/app/code/core/Mage/DesignEditor/view/frontend/layout.xml +++ b/app/code/core/Mage/DesignEditor/view/frontend/layout.xml @@ -27,7 +27,6 @@ --> - jquery/jquery-1.7.1.min.js mage/jquery-no-conflict.js @@ -53,7 +52,6 @@ - diff --git a/app/code/core/Mage/ImportExport/Model/Export/Entity/Product.php b/app/code/core/Mage/ImportExport/Model/Export/Entity/Product.php index 166d04b054ccb..7089e672d49cf 100644 --- a/app/code/core/Mage/ImportExport/Model/Export/Entity/Product.php +++ b/app/code/core/Mage/ImportExport/Model/Export/Entity/Product.php @@ -792,7 +792,9 @@ public function export() $dataRow[self::COL_TYPE] = null; } else { $dataRow[self::COL_STORE] = null; - $dataRow += $stockItemRows[$productId]; + if (isset($stockItemRows[$productId])) { + array_merge($dataRow, $stockItemRows[$productId]); + } } $this->_updateDataWithCategoryColumns($dataRow, $rowCategories, $productId); diff --git a/app/code/core/Mage/Install/Model/Observer.php b/app/code/core/Mage/Install/Model/Observer.php index e2cac5bec746d..144eb61cb7eef 100644 --- a/app/code/core/Mage/Install/Model/Observer.php +++ b/app/code/core/Mage/Install/Model/Observer.php @@ -40,11 +40,4 @@ public function bindLocale($observer) } return $this; } - - public function installFailure($observer) - { - echo "

There was a problem proceeding with Magento installation.

"; - echo "

Please contact developers with error messages on this page.

"; - echo Mage::printException($observer->getEvent()->getException()); - } } diff --git a/app/code/core/Mage/Install/etc/config.xml b/app/code/core/Mage/Install/etc/config.xml index 5d052f2591271..7253953dc78bb 100644 --- a/app/code/core/Mage/Install/etc/config.xml +++ b/app/code/core/Mage/Install/etc/config.xml @@ -65,14 +65,6 @@ - - - - Mage_Install_Model_Observer - installFailure - - - diff --git a/app/code/core/Mage/Oauth/view/adminhtml/layout.xml b/app/code/core/Mage/Oauth/view/adminhtml/layout.xml index aa50cffd9cc59..0ed245bf0db8f 100644 --- a/app/code/core/Mage/Oauth/view/adminhtml/layout.xml +++ b/app/code/core/Mage/Oauth/view/adminhtml/layout.xml @@ -35,7 +35,7 @@ - + @@ -64,7 +64,7 @@ - + @@ -116,7 +116,7 @@ - + Mage_Oauth::css/oauth-simple.css @@ -126,18 +126,16 @@ - + - - + - @@ -146,17 +144,15 @@ - + - - + - @@ -164,17 +160,15 @@ - + - - + - @@ -189,6 +183,6 @@ - +
diff --git a/app/code/core/Mage/Oauth/view/frontend/layout.xml b/app/code/core/Mage/Oauth/view/frontend/layout.xml index 5dadcd936531d..6b67369bb0ae7 100644 --- a/app/code/core/Mage/Oauth/view/frontend/layout.xml +++ b/app/code/core/Mage/Oauth/view/frontend/layout.xml @@ -50,7 +50,7 @@ - + Mage_Oauth::css/oauth-simple.css @@ -59,7 +59,7 @@ - + @@ -68,7 +68,7 @@ - + @@ -80,7 +80,7 @@ - + @@ -88,7 +88,7 @@ - + @@ -99,7 +99,7 @@ - + @@ -107,7 +107,7 @@ - + @@ -128,7 +128,7 @@ - + diff --git a/app/code/core/Mage/Paypal/view/frontend/layout.xml b/app/code/core/Mage/Paypal/view/frontend/layout.xml index e6c397efee81e..98eb62cdc5621 100644 --- a/app/code/core/Mage/Paypal/view/frontend/layout.xml +++ b/app/code/core/Mage/Paypal/view/frontend/layout.xml @@ -209,8 +209,7 @@ Available logo types can be assigned with action="setLogoType": - - + diff --git a/app/code/core/Mage/PaypalUk/view/frontend/layout.xml b/app/code/core/Mage/PaypalUk/view/frontend/layout.xml index bab0070426713..bc94fbe9a3d6c 100644 --- a/app/code/core/Mage/PaypalUk/view/frontend/layout.xml +++ b/app/code/core/Mage/PaypalUk/view/frontend/layout.xml @@ -136,8 +136,7 @@ - - + diff --git a/app/code/core/Mage/Review/etc/config.xml b/app/code/core/Mage/Review/etc/config.xml index 2693c92f62696..2066c5c809def 100644 --- a/app/code/core/Mage/Review/etc/config.xml +++ b/app/code/core/Mage/Review/etc/config.xml @@ -71,16 +71,6 @@ - - - - - Mage_Rss_Model_Observer - reviewSaveAfter - - - - diff --git a/app/code/core/Mage/Review/view/frontend/layout.xml b/app/code/core/Mage/Review/view/frontend/layout.xml index 4a7859d6a54e5..e7d21a023e3ec 100644 --- a/app/code/core/Mage/Review/view/frontend/layout.xml +++ b/app/code/core/Mage/Review/view/frontend/layout.xml @@ -49,19 +49,6 @@ Customer account home dashboard layout - - - - - - - - - - - diff --git a/app/code/core/Mage/Rss/Block/Catalog/New.php b/app/code/core/Mage/Rss/Block/Catalog/New.php index d7aee895318d5..e678dda3872eb 100644 --- a/app/code/core/Mage/Rss/Block/Catalog/New.php +++ b/app/code/core/Mage/Rss/Block/Catalog/New.php @@ -92,11 +92,11 @@ protected function _toHtml() ) ) ->addAttributeToSort('news_from_date','desc') - ->addAttributeToSelect(array('name', 'short_description', 'description', 'thumbnail'), 'inner') + ->addAttributeToSelect(array('name', 'short_description', 'description'), 'inner') ->addAttributeToSelect( array( 'price', 'special_price', 'special_from_date', 'special_to_date', - 'msrp_enabled', 'msrp_display_actual_price_type', 'msrp' + 'msrp_enabled', 'msrp_display_actual_price_type', 'msrp', 'thumbnail' ), 'left' ) diff --git a/app/code/core/Mage/Rss/Block/Catalog/NotifyStock.php b/app/code/core/Mage/Rss/Block/Catalog/NotifyStock.php index 3702d247a46c5..d4e91809723a3 100644 --- a/app/code/core/Mage/Rss/Block/Catalog/NotifyStock.php +++ b/app/code/core/Mage/Rss/Block/Catalog/NotifyStock.php @@ -31,31 +31,8 @@ * @package Mage_Rss * @author Magento Core Team */ -class Mage_Rss_Block_Catalog_NotifyStock extends Mage_Rss_Block_Abstract +class Mage_Rss_Block_Catalog_NotifyStock extends Mage_Core_Block_Abstract { - - /** - * Cache tag constant for feed notify stock - * - * @var string - */ - const CACHE_TAG = 'block_html_rss_catalog_notifystock'; - - /** - * Constructor - * - * @return null - */ - protected function _construct() - { - $this->setCacheTags(array(self::CACHE_TAG)); - /* - * setting cache to save the rss for 10 minutes - */ - $this->setCacheKey('rss_catalog_notifystock'); - $this->setCacheLifetime(600); - } - /** * Render RSS * diff --git a/app/code/core/Mage/Rss/Block/Catalog/Review.php b/app/code/core/Mage/Rss/Block/Catalog/Review.php index 80ff79fcbd93e..fb6371765e63d 100644 --- a/app/code/core/Mage/Rss/Block/Catalog/Review.php +++ b/app/code/core/Mage/Rss/Block/Catalog/Review.php @@ -31,31 +31,8 @@ * @package Mage_Rss * @author Magento Core Team */ -class Mage_Rss_Block_Catalog_Review extends Mage_Rss_Block_Abstract +class Mage_Rss_Block_Catalog_Review extends Mage_Core_Block_Abstract { - - /** - * Cache tag constant for feed reviews - * - * @var string - */ - const CACHE_TAG = 'block_html_rss_catalog_review'; - - /** - * Initialize cache - * - * @return null - */ - protected function _construct() - { - $this->setCacheTags(array(self::CACHE_TAG)); - /* - * setting cache to save the rss for 10 minutes - */ - $this->setCacheKey('rss_catalog_review'); - $this->setCacheLifetime(600); - } - /** * Render XML response * diff --git a/app/code/core/Mage/Rss/Block/Order/New.php b/app/code/core/Mage/Rss/Block/Order/New.php index eda9fe8567b67..9f2942973d754 100644 --- a/app/code/core/Mage/Rss/Block/Order/New.php +++ b/app/code/core/Mage/Rss/Block/Order/New.php @@ -31,26 +31,8 @@ * @package Mage_Rss * @author Magento Core Team */ -class Mage_Rss_Block_Order_New extends Mage_Core_Block_Template +class Mage_Rss_Block_Order_New extends Mage_Core_Block_Abstract { - - /** - * Cache tag constant for feed new orders - * - * @var string - */ - const CACHE_TAG = 'block_html_rss_order_new'; - - protected function _construct() - { - $this->setCacheTags(array(self::CACHE_TAG)); - /* - * setting cache to save the rss for 10 minutes - */ - $this->setCacheKey('rss_order_new'); - $this->setCacheLifetime(600); - } - protected function _toHtml() { $order = Mage::getModel('Mage_Sales_Model_Order'); diff --git a/app/code/core/Mage/Rss/Controller/AdminhtmlAbstract.php b/app/code/core/Mage/Rss/Controller/AdminhtmlAbstract.php deleted file mode 100644 index cf7a793e49301..0000000000000 --- a/app/code/core/Mage/Rss/Controller/AdminhtmlAbstract.php +++ /dev/null @@ -1,59 +0,0 @@ - - */ -abstract class Mage_Rss_Controller_AdminhtmlAbstract extends Mage_Core_Controller_Front_Action -{ - /** - * Returns map of action to acl paths, needed to check user's access to a specific action - * - * @return array - */ - abstract protected function _getAdminAclMap(); - - /** - * Controller predispatch method to change area for a specific action - * - * @return Mage_Rss_Controller_AdminhtmlAbstract - */ - public function preDispatch() - { - $action = $this->getRequest()->getActionName(); - $map = $this->_getAdminAclMap(); - if (isset($map[$action])) { - $this->_currentArea = 'adminhtml'; - $path = $map[$action]; - Mage::helper('Mage_Rss_Helper_Data')->authAdmin($path); - } - return parent::preDispatch(); - } -} diff --git a/app/code/core/Mage/Rss/Helper/Data.php b/app/code/core/Mage/Rss/Helper/Data.php index 28b1578aabd95..83b790e20eb43 100644 --- a/app/code/core/Mage/Rss/Helper/Data.php +++ b/app/code/core/Mage/Rss/Helper/Data.php @@ -34,78 +34,6 @@ */ class Mage_Rss_Helper_Data extends Mage_Core_Helper_Abstract { - /** - * Authenticate customer on frontend - * - */ - public function authFrontend() - { - $session = Mage::getSingleton('Mage_Rss_Model_Session'); - if ($session->isCustomerLoggedIn()) { - return; - } - list($username, $password) = $this->authValidate(); - $customer = Mage::getModel('Mage_Customer_Model_Customer')->authenticate($username, $password); - if ($customer && $customer->getId()) { - Mage::getSingleton('Mage_Rss_Model_Session')->settCustomer($customer); - } else { - $this->authFailed(); - } - } - - /** - * Authenticates admin user and checks ACL. Returns user model upon successful authentication. - * If user authentication fails, then shows error and exits php instantly. - * - * @param string $path - * @return Mage_User_Model_User - */ - public function authAdmin($path) - { - $session = Mage::getSingleton('Mage_Rss_Model_Session'); - if ($session->isAdminLoggedIn()) { - return $session->getAdmin(); - } - - list($username, $password) = $this->authValidate(); - Mage::getSingleton('Mage_Adminhtml_Model_Url')->setNoSecret(true); - - $auth = Mage::getSingleton('Mage_Backend_Model_Auth'); - $auth->login($username, $password); - $adminSession = $auth->getAuthStorage(); - - $user = $adminSession->getUser(); - - if ($user && $user->getIsActive() == '1' && $adminSession->isAllowed($path)){ - $session->setAdmin($user); - return $user; - } else { - // Error is shown and exit() is called - Mage::helper('Mage_Core_Helper_Http')->authFailed(); - } - } - - /** - * Validate Authenticate - * - * @param array $headers - * @return array - */ - public function authValidate($headers=null) - { - $userPass = Mage::helper('Mage_Core_Helper_Http')->authValidate($headers); - return $userPass; - } - - /** - * Send authenticate failed headers - * - */ - public function authFailed() - { - Mage::helper('Mage_Core_Helper_Http')->authFailed(); - } - /** * Disable using of flat catalog and/or product model to prevent limiting results to single store. Probably won't * work inside a controller. diff --git a/app/code/core/Mage/Rss/Model/Observer.php b/app/code/core/Mage/Rss/Model/Observer.php deleted file mode 100644 index ed78507fbc397..0000000000000 --- a/app/code/core/Mage/Rss/Model/Observer.php +++ /dev/null @@ -1,76 +0,0 @@ - - */ -class Mage_Rss_Model_Observer -{ - - /** - * Clean cache for catalog review rss - * - * @param Varien_Event_Observer $observer - * @return void - */ - public function reviewSaveAfter(Varien_Event_Observer $observer) - { - - Mage::app()->cleanCache(array(Mage_Rss_Block_Catalog_Review::CACHE_TAG)); - - } - - /** - * Clean cache for notify stock rss - * - * @param Varien_Event_Observer $observer - * @return void - */ - public function salesOrderItemSaveAfterNotifyStock(Varien_Event_Observer $observer) - { - - Mage::app()->cleanCache(array(Mage_Rss_Block_Catalog_NotifyStock::CACHE_TAG)); - - } - - /** - * Clean cache for catalog new orders rss - * - * @param Varien_Event_Observer $observer - * @return void - */ - public function salesOrderItemSaveAfterOrderNew(Varien_Event_Observer $observer) - { - - Mage::app()->cleanCache(array(Mage_Rss_Block_Order_New::CACHE_TAG)); - - } -} diff --git a/app/code/core/Mage/Rss/Model/Session.php b/app/code/core/Mage/Rss/Model/Session.php deleted file mode 100644 index d3a90f80f448d..0000000000000 --- a/app/code/core/Mage/Rss/Model/Session.php +++ /dev/null @@ -1,51 +0,0 @@ - - */ -class Mage_Rss_Model_Session extends Mage_Core_Model_Session_Abstract -{ - public function __construct() - { - $this->init('rss'); - } - - public function isAdminLoggedIn() - { - return $this->getAdmin() && $this->getAdmin()->getId(); - } - - public function isCustomerLoggedIn() - { - return $this->getCustomer() && $this->getCustomer()->getId(); - } -} diff --git a/app/code/core/Mage/Rss/controllers/CatalogController.php b/app/code/core/Mage/Rss/controllers/CatalogController.php index 0fa5e51356b50..469a19026f0a6 100644 --- a/app/code/core/Mage/Rss/controllers/CatalogController.php +++ b/app/code/core/Mage/Rss/controllers/CatalogController.php @@ -24,6 +24,8 @@ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ +require_once __DIR__ . '/OrderController.php'; + /** * Customer reviews controller * @@ -31,96 +33,103 @@ * @package Mage_Rss * @author Magento Core Team */ - -class Mage_Rss_CatalogController extends Mage_Rss_Controller_AdminhtmlAbstract +class Mage_Rss_CatalogController extends Mage_Core_Controller_Front_Action { /** - * Returns map of action to acl paths, needed to check user's access to a specific action - * - * @return array + * Emulate admin area for certain actions */ - protected function _getAdminAclMap() - { - return array( - 'notifystock' => 'catalog/products', - 'review' => 'catalog/reviews_ratings' - ); - } - - protected function isFeedEnable($code) + public function preDispatch() { - return Mage::getStoreConfig('rss/catalog/'.$code); - } - - protected function checkFeedEnable($code) - { - if ($this->isFeedEnable($code)) { - $this->getResponse()->setHeader('Content-type', 'text/xml; charset=UTF-8'); - return true; - } else { - $this->getResponse()->setHeader('HTTP/1.1','404 Not Found'); - $this->getResponse()->setHeader('Status','404 File not found'); - $this->_forward('nofeed','index','rss'); - return false; + $action = $this->getRequest()->getActionName(); + $acl = array('notifystock' => 'catalog/products', 'review' => 'catalog/reviews_ratings'); + if (isset($acl[$action])) { + $this->setCurrentArea('adminhtml'); + if (Mage_Rss_OrderController::authenticateAndAuthorizeAdmin($this, $acl[$action])) { + return; + } } + parent::preDispatch(); } public function newAction() { - $this->checkFeedEnable('new'); - $this->loadLayout(false); - $this->renderLayout(); + $this->_genericAction('new'); } public function specialAction() { - $this->checkFeedEnable('special'); - $this->loadLayout(false); - $this->renderLayout(); + $this->_genericAction('special'); } public function salesruleAction() { - $this->checkFeedEnable('salesrule'); - $this->loadLayout(false); - $this->renderLayout(); + $this->_genericAction('salesrule'); } public function tagAction() { - if ($this->checkFeedEnable('tag')) { - $tagName = urldecode($this->getRequest()->getParam('tagName')); - $tagModel = Mage::getModel('Mage_Tag_Model_Tag'); - $tagModel->loadByName($tagName); - if ($tagModel->getId() && $tagModel->getStatus()==$tagModel->getApprovedStatus()) { - Mage::register('tag_model', $tagModel); - $this->loadLayout(false); - $this->renderLayout(); - return; - } + if (!$this->_isEnabled('tag')) { + $this->_forward('nofeed', 'index', 'rss'); + return; + } + $tagName = urldecode($this->getRequest()->getParam('tagName')); + $tagModel = Mage::getModel('Mage_Tag_Model_Tag'); + $tagModel->loadByName($tagName); + if ($tagModel->getId() && $tagModel->getStatus() == $tagModel->getApprovedStatus()) { + Mage::register('tag_model', $tagModel); + $this->_render(); + return; } $this->_forward('nofeed', 'index', 'rss'); } public function notifystockAction() { - $this->getResponse()->setHeader('Content-type', 'text/xml; charset=UTF-8'); - $this->loadLayout(false); - $this->renderLayout(); + $this->_render(); } public function reviewAction() { - $this->getResponse()->setHeader('Content-type', 'text/xml; charset=UTF-8'); - $this->loadLayout(false); - $this->renderLayout(); + $this->_render(); } public function categoryAction() { - if ($this->checkFeedEnable('category')) { - $this->loadLayout(false); - $this->renderLayout(); + $this->_genericAction('category'); + } + + /** + * Render or forward to "no route" action if this type of RSS is disabled + * + * @param string $code + */ + protected function _genericAction($code) + { + if ($this->_isEnabled($code)) { + $this->_render(); + } else { + $this->_forward('nofeed', 'index', 'rss'); } } + + /** + * Whether specified type of RSS is enabled + * + * @param string $code + * @return bool + */ + protected function _isEnabled($code) + { + return Mage::getStoreConfigFlag("rss/catalog/{$code}"); + } + + /** + * Render as XML-document using layout handle without inheriting any other handles + */ + protected function _render() + { + $this->getResponse()->setHeader('Content-Type', 'text/xml; charset=UTF-8'); + $this->loadLayout(false); + $this->renderLayout(); + } } diff --git a/app/code/core/Mage/Rss/controllers/IndexController.php b/app/code/core/Mage/Rss/controllers/IndexController.php index d340435f68bc4..c45262a8644c4 100644 --- a/app/code/core/Mage/Rss/controllers/IndexController.php +++ b/app/code/core/Mage/Rss/controllers/IndexController.php @@ -56,9 +56,7 @@ public function indexAction() $this->loadLayout(); $this->renderLayout(); } else { - $this->getResponse()->setHeader('HTTP/1.1','404 Not Found'); - $this->getResponse()->setHeader('Status','404 File not found'); - $this->_forward('defaultNoRoute'); + $this->norouteAction(); } } @@ -67,10 +65,11 @@ public function indexAction() */ public function nofeedAction() { - $this->getResponse()->setHeader('HTTP/1.1','404 Not Found'); - $this->getResponse()->setHeader('Status','404 File not found'); - $this->loadLayout(false); - $this->renderLayout(); + $this->getResponse()->setHeader('HTTP/1.1', '404 Not Found') + ->setHeader('Status', '404 File not found') + ->setHeader('Content-Type', 'text/plain; charset=UTF-8') + ->setBody($this->__('There was no RSS feed enabled.')) + ; } /** @@ -81,39 +80,19 @@ public function nofeedAction() */ public function wishlistAction() { - if (!Mage::getStoreConfig('rss/wishlist/active')) { - $this->getResponse()->setHeader('HTTP/1.1','404 Not Found'); - $this->getResponse()->setHeader('Status','404 File not found'); - $this->_forward('nofeed','index','rss'); - return; - } - - $wishlist = $this->_getWishlist(); - if (!$wishlist) { - $this->_forward('nofeed','index','rss'); - return; - } - - if ($wishlist->getVisibility()) { - $this->_showWishlistRss(); - return ; - } else if (Mage::getSingleton('Mage_Customer_Model_Session')->authenticate($this) - && $wishlist->getCustomerId() == $this->_getCustomer()->getId() - ) { - $this->_showWishlistRss(); - } else { - $this->_forward('nofeed','index','rss'); + if (Mage::getStoreConfig('rss/wishlist/active')) { + $wishlist = $this->_getWishlist(); + if ($wishlist && ($wishlist->getVisibility() + || Mage::getSingleton('Mage_Customer_Model_Session')->authenticate($this) + && $wishlist->getCustomerId() == $this->_getCustomer()->getId()) + ) { + $this->getResponse()->setHeader('Content-Type', 'text/xml; charset=UTF-8'); + $this->loadLayout(false); + $this->renderLayout(); + return; + } } - } - - /** - * Show wishlist rss - */ - protected function _showWishlistRss() - { - $this->getResponse()->setHeader('Content-type', 'text/xml; charset=UTF-8'); - $this->loadLayout(false); - $this->renderLayout(); + $this->nofeedAction(); } /** diff --git a/app/code/core/Mage/Rss/controllers/OrderController.php b/app/code/core/Mage/Rss/controllers/OrderController.php index e8728a25c1283..f04ba9af951d6 100644 --- a/app/code/core/Mage/Rss/controllers/OrderController.php +++ b/app/code/core/Mage/Rss/controllers/OrderController.php @@ -32,18 +32,52 @@ * @author Magento Core Team */ -class Mage_Rss_OrderController extends Mage_Rss_Controller_AdminhtmlAbstract +class Mage_Rss_OrderController extends Mage_Core_Controller_Front_Action { + public function preDispatch() + { + if ('new' === $this->getRequest()->getActionName()) { + $this->setCurrentArea('adminhtml'); + if (!self::authenticateAndAuthorizeAdmin($this, 'sales/order')) { + return; + } + } + parent::preDispatch(); + } + /** - * Returns map of action to acl paths, needed to check user's access to a specific action + * Check if admin is logged in and authorized to access resource by specified ACL path * - * @return array + * If not authenticated, will try to do it using credentials from HTTP-request + * + * @param Mage_Core_Controller_Front_Action $controller + * @param string $aclResource + * @return bool */ - protected function _getAdminAclMap() + public static function authenticateAndAuthorizeAdmin(Mage_Core_Controller_Front_Action $controller, $aclResource) { - return array( - 'new' => 'sales/order' - ); + /** @var $auth Mage_Backend_Model_Auth */ + $auth = Mage::getModel('Mage_Backend_Model_Auth'); + $session = $auth->getAuthStorage(); + + // try to login using HTTP-authentication + if (!$session->isLoggedIn()) { + list($login, $password) = Mage::helper('Mage_Core_Helper_Http') + ->getHttpAuthCredentials($controller->getRequest()); + try { + $auth->login($login, $password); + } catch (Mage_Backend_Model_Auth_Exception $e) { + Mage::logException($e); + } + } + + // verify if logged in and authorized + if (!$session->isLoggedIn() || !$session->isAllowed($aclResource)) { + Mage::helper('Mage_Core_Helper_Http')->failHttpAuthentication($controller->getResponse(), 'RSS Feeds'); + $controller->setFlag('', self::FLAG_NO_DISPATCH, true); + return false; + } + return true; } public function newAction() @@ -53,17 +87,6 @@ public function newAction() $this->renderLayout(); } - public function customerAction() - { - if (Mage::app()->getStore()->isCurrentlySecure()) { - $this->getResponse()->setHeader('Content-type', 'text/xml; charset=UTF-8'); - Mage::helper('Mage_Rss_Helper_Data')->authFrontend(); - } else { - $this->_redirect('rss/order/customer', array('_secure'=>true)); - return $this; - } - } - /** * Order status action */ diff --git a/app/code/core/Mage/Rss/etc/config.xml b/app/code/core/Mage/Rss/etc/config.xml index ad97992cd722c..a7089e9a4595e 100644 --- a/app/code/core/Mage/Rss/etc/config.xml +++ b/app/code/core/Mage/Rss/etc/config.xml @@ -53,24 +53,6 @@ - - - - - Mage_Rss_Model_Observer - salesOrderItemSaveAfterNotifyStock - - - - - - - Mage_Rss_Model_Observer - salesOrderItemSaveAfterOrderNew - - - - diff --git a/app/code/core/Mage/Rss/view/frontend/layout.xml b/app/code/core/Mage/Rss/view/frontend/layout.xml index 67f0a135e7693..a319772b2c74a 100644 --- a/app/code/core/Mage/Rss/view/frontend/layout.xml +++ b/app/code/core/Mage/Rss/view/frontend/layout.xml @@ -46,13 +46,7 @@ - - - - - - - + msrp_rssMage_Catalog_Block_Product_Price @@ -60,32 +54,27 @@ - - + msrp_rssMage_Catalog_Block_Product_Price - - + - - + - - + msrp_rssMage_Catalog_Block_Product_Price - - + msrp_rssMage_Catalog_Block_Product_Price @@ -93,8 +82,7 @@ Catalog layout - - + diff --git a/app/code/core/Mage/Sales/view/frontend/layout.xml b/app/code/core/Mage/Sales/view/frontend/layout.xml index 06f16df8b556f..f1f1cc50fe12b 100644 --- a/app/code/core/Mage/Sales/view/frontend/layout.xml +++ b/app/code/core/Mage/Sales/view/frontend/layout.xml @@ -83,8 +83,8 @@ Customer account home dashboard layout - + @@ -330,7 +330,7 @@ Guest - + @@ -359,7 +359,7 @@ Guest - + @@ -389,7 +389,7 @@ Guest - + @@ -413,7 +413,7 @@ Guest - + diff --git a/app/design/frontend/default/iphone/Mage_Catalog/layout.xml b/app/design/frontend/default/iphone/Mage_Catalog/layout.xml index a8740a1a86bd0..d99b622a711b7 100644 --- a/app/design/frontend/default/iphone/Mage_Catalog/layout.xml +++ b/app/design/frontend/default/iphone/Mage_Catalog/layout.xml @@ -86,7 +86,7 @@ Category default layout Category layered navigation layout --> - + diff --git a/app/design/frontend/default/iphone/Mage_CatalogSearch/layout.xml b/app/design/frontend/default/iphone/Mage_CatalogSearch/layout.xml index 56e906fe93efe..90f86406154c9 100644 --- a/app/design/frontend/default/iphone/Mage_CatalogSearch/layout.xml +++ b/app/design/frontend/default/iphone/Mage_CatalogSearch/layout.xml @@ -34,7 +34,7 @@ - + diff --git a/app/design/frontend/default/iphone/Mage_Checkout/layout.xml b/app/design/frontend/default/iphone/Mage_Checkout/layout.xml index 7748c64b70250..68fc1309259ef 100644 --- a/app/design/frontend/default/iphone/Mage_Checkout/layout.xml +++ b/app/design/frontend/default/iphone/Mage_Checkout/layout.xml @@ -78,10 +78,10 @@ Default layout, loads most of the pages - + - + diff --git a/app/design/frontend/default/iphone/Mage_Customer/layout.xml b/app/design/frontend/default/iphone/Mage_Customer/layout.xml index 45b5fa2621f79..14a3d761c54a8 100644 --- a/app/design/frontend/default/iphone/Mage_Customer/layout.xml +++ b/app/design/frontend/default/iphone/Mage_Customer/layout.xml @@ -125,7 +125,7 @@ New customer registration - + diff --git a/app/design/frontend/default/iphone/Mage_Newsletter/layout.xml b/app/design/frontend/default/iphone/Mage_Newsletter/layout.xml index c67c89bb9b363..56c75fdd45b11 100644 --- a/app/design/frontend/default/iphone/Mage_Newsletter/layout.xml +++ b/app/design/frontend/default/iphone/Mage_Newsletter/layout.xml @@ -52,7 +52,7 @@ Customer account pages, rendered for all tabs in dashboard - + diff --git a/app/design/frontend/default/iphone/Mage_Page/layout.xml b/app/design/frontend/default/iphone/Mage_Page/layout.xml index ec723d60befdc..ec8b066c308d1 100644 --- a/app/design/frontend/default/iphone/Mage_Page/layout.xml +++ b/app/design/frontend/default/iphone/Mage_Page/layout.xml @@ -89,7 +89,7 @@ Default layout, loads most of the pages - + diff --git a/app/design/frontend/default/iphone/Mage_Review/layout.xml b/app/design/frontend/default/iphone/Mage_Review/layout.xml index 8b0f527b30f55..a3c7c79852a98 100644 --- a/app/design/frontend/default/iphone/Mage_Review/layout.xml +++ b/app/design/frontend/default/iphone/Mage_Review/layout.xml @@ -49,18 +49,6 @@ Customer account home dashboard layout - - - - - - - - - - diff --git a/app/design/frontend/default/iphone/Mage_Rss/layout.xml b/app/design/frontend/default/iphone/Mage_Rss/layout.xml index 650ad24757107..a00b9276fa598 100644 --- a/app/design/frontend/default/iphone/Mage_Rss/layout.xml +++ b/app/design/frontend/default/iphone/Mage_Rss/layout.xml @@ -33,7 +33,7 @@ - + @@ -43,12 +43,8 @@ - - - - - + msrp_rssMage_Catalog_Block_Product_Price @@ -56,27 +52,27 @@ Catalog layout --> - + msrp_rssMage_Catalog_Block_Product_Price - + - + - + msrp_rssMage_Catalog_Block_Product_Price - + msrp_rssMage_Catalog_Block_Product_Price @@ -84,6 +80,6 @@ Catalog layout Order layout --> - + diff --git a/app/design/frontend/default/iphone/Mage_Sales/layout.xml b/app/design/frontend/default/iphone/Mage_Sales/layout.xml index 9464bb8e97380..5f01afaaaba5c 100644 --- a/app/design/frontend/default/iphone/Mage_Sales/layout.xml +++ b/app/design/frontend/default/iphone/Mage_Sales/layout.xml @@ -66,7 +66,7 @@ Customer account home dashboard layout - + @@ -78,9 +78,9 @@ Customer account home dashboard layout - - + + @@ -106,7 +106,7 @@ Customer account home dashboard layout - + @@ -135,7 +135,7 @@ Customer account home dashboard layout - + @@ -158,7 +158,7 @@ Customer account home dashboard layout - + @@ -194,7 +194,7 @@ Customer account home dashboard layout - + @@ -212,7 +212,7 @@ Customer account home dashboard layout - + @@ -228,7 +228,7 @@ Customer account home dashboard layout - + @@ -308,7 +308,7 @@ Email layouts section Guest --> - + @@ -319,8 +319,8 @@ Guest - - + + @@ -348,8 +348,8 @@ Guest - - + + @@ -378,8 +378,8 @@ Guest - - + + @@ -402,8 +402,8 @@ Guest - - + + @@ -441,7 +441,7 @@ Guest - + @@ -458,7 +458,7 @@ Guest - + @@ -473,7 +473,7 @@ Guest - + diff --git a/app/design/frontend/default/iphone/Mage_Wishlist/layout.xml b/app/design/frontend/default/iphone/Mage_Wishlist/layout.xml index e6b86883d6644..7b84a764a3886 100644 --- a/app/design/frontend/default/iphone/Mage_Wishlist/layout.xml +++ b/app/design/frontend/default/iphone/Mage_Wishlist/layout.xml @@ -70,7 +70,7 @@ Customer account home dashboard layout Wishlist pages --> - + @@ -106,7 +106,7 @@ Wishlist pages - + @@ -118,7 +118,7 @@ Wishlist pages - + @@ -130,7 +130,7 @@ Wishlist pages - + diff --git a/app/design/frontend/default/modern/Mage_Catalog/layout.xml b/app/design/frontend/default/modern/Mage_Catalog/layout.xml index ed4b92a91afc7..0df791d11a2ef 100644 --- a/app/design/frontend/default/modern/Mage_Catalog/layout.xml +++ b/app/design/frontend/default/modern/Mage_Catalog/layout.xml @@ -127,7 +127,7 @@ Category default layout - + diff --git a/app/design/frontend/default/modern/Mage_Checkout/layout.xml b/app/design/frontend/default/modern/Mage_Checkout/layout.xml index 5b3a8010d0304..7e6d567ebcf91 100644 --- a/app/design/frontend/default/modern/Mage_Checkout/layout.xml +++ b/app/design/frontend/default/modern/Mage_Checkout/layout.xml @@ -93,7 +93,7 @@ Default layout, loads most of the pages - + diff --git a/app/design/frontend/default/modern/Mage_Customer/layout.xml b/app/design/frontend/default/modern/Mage_Customer/layout.xml index 4cbd9764612d4..291119771236d 100644 --- a/app/design/frontend/default/modern/Mage_Customer/layout.xml +++ b/app/design/frontend/default/modern/Mage_Customer/layout.xml @@ -131,7 +131,7 @@ New customer registration - + diff --git a/app/design/frontend/default/modern/Mage_Review/layout.xml b/app/design/frontend/default/modern/Mage_Review/layout.xml index ccebaf0fae075..6f65af6b8dcb0 100644 --- a/app/design/frontend/default/modern/Mage_Review/layout.xml +++ b/app/design/frontend/default/modern/Mage_Review/layout.xml @@ -50,18 +50,6 @@ Customer account home dashboard layout - - - - - - - - - - diff --git a/app/design/frontend/default/modern/Mage_Rss/layout.xml b/app/design/frontend/default/modern/Mage_Rss/layout.xml index 704ba52ff1c4f..753b5fcfbcda3 100644 --- a/app/design/frontend/default/modern/Mage_Rss/layout.xml +++ b/app/design/frontend/default/modern/Mage_Rss/layout.xml @@ -45,47 +45,35 @@ Default layout, loads most of the pages - - - - - - - + - - + - - + - - + - - + - - + - - + diff --git a/app/design/frontend/default/modern/Mage_Sales/layout.xml b/app/design/frontend/default/modern/Mage_Sales/layout.xml index 725507f3df537..a0e21d8619b78 100644 --- a/app/design/frontend/default/modern/Mage_Sales/layout.xml +++ b/app/design/frontend/default/modern/Mage_Sales/layout.xml @@ -79,8 +79,8 @@ Customer account home dashboard layout - + @@ -314,7 +314,7 @@ Guest - + @@ -343,7 +343,7 @@ Guest - + @@ -373,7 +373,7 @@ Guest - + @@ -397,7 +397,7 @@ Guest - + diff --git a/dev/tests/integration/etc/local-mysql.xml.dist b/dev/tests/integration/etc/local-mysql.xml.dist index 04771b02ea568..2d785263272fe 100644 --- a/dev/tests/integration/etc/local-mysql.xml.dist +++ b/dev/tests/integration/etc/local-mysql.xml.dist @@ -55,6 +55,15 @@ + + + + + + + + + diff --git a/dev/tests/integration/framework/Magento/Test/Db/Adapter/Mysql.php b/dev/tests/integration/framework/Magento/Test/Db/Adapter/Mysql.php new file mode 100644 index 0000000000000..c0d0791dd302b --- /dev/null +++ b/dev/tests/integration/framework/Magento/Test/Db/Adapter/Mysql.php @@ -0,0 +1,81 @@ +_transparentLevel += 1; + return $this->beginTransaction(); + } + + /** + * See Magento_Test_Db_Adapter_TransactionInterface + * + * @return Magento_Test_Db_Adapter_Mysql + */ + public function commitTransparentTransaction() + { + $this->_transparentLevel -= 1; + return $this->commit(); + } + + /** + * See Magento_Test_Db_Adapter_TransactionInterface + * + * @return Magento_Test_Db_Adapter_Mysql + */ + public function rollbackTransparentTransaction() + { + $this->_transparentLevel -= 1; + return $this->rollback(); + } + + /** + * Adjust transaction level with "transparent" counter + * + * @return int + */ + public function getTransactionLevel() + { + return parent::getTransactionLevel() - $this->_transparentLevel; + } +} diff --git a/dev/tests/integration/testsuite/Mage/Paypal/_files/order_standard_commit_workaround.php b/dev/tests/integration/framework/Magento/Test/Db/Adapter/TransactionInterface.php similarity index 56% rename from dev/tests/integration/testsuite/Mage/Paypal/_files/order_standard_commit_workaround.php rename to dev/tests/integration/framework/Magento/Test/Db/Adapter/TransactionInterface.php index 02da35f7e80a6..c2a510f36766f 100644 --- a/dev/tests/integration/testsuite/Mage/Paypal/_files/order_standard_commit_workaround.php +++ b/dev/tests/integration/framework/Magento/Test/Db/Adapter/TransactionInterface.php @@ -19,10 +19,35 @@ * needs please refer to http://www.magentocommerce.com for more information. * * @category Magento - * @package Mage_Paypal + * @package Magento_Test * @subpackage integration_tests * @copyright Copyright (c) 2012 Magento Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ -require __DIR__ . '/order_standard.php'; -$order->afterCommitCallback(); + +/** + * "Transparent" DB transaction hack for integration tests + */ +interface Magento_Test_Db_Adapter_TransactionInterface +{ + /** + * Increment "transparent" transaction counter and start real transaction + * + * @return Zend_Db_Adapter_Abstract + */ + public function beginTransparentTransaction(); + + /** + * Decrement "transparent" transaction counter and commit real transaction + * + * @return Zend_Db_Adapter_Abstract + */ + public function commitTransparentTransaction(); + + /** + * Decrement "transparent" transaction counter and rollback real transaction + * + * @return Zend_Db_Adapter_Abstract + */ + public function rollbackTransparentTransaction(); +} diff --git a/dev/tests/integration/framework/Magento/Test/Listener/Annotation/Fixture.php b/dev/tests/integration/framework/Magento/Test/Listener/Annotation/Fixture.php index 811010639b7df..e55a3c049d7dd 100644 --- a/dev/tests/integration/framework/Magento/Test/Listener/Annotation/Fixture.php +++ b/dev/tests/integration/framework/Magento/Test/Listener/Annotation/Fixture.php @@ -122,7 +122,7 @@ protected function _startTransaction() { /** @var $adapter Varien_Db_Adapter_Interface */ $adapter = Mage::getSingleton('Mage_Core_Model_Resource')->getConnection('write'); - $adapter->beginTransaction(); + $adapter->beginTransparentTransaction(); } /** @@ -132,7 +132,7 @@ protected function _rollbackTransaction() { /** @var $adapter Varien_Db_Adapter_Interface */ $adapter = Mage::getSingleton('Mage_Core_Model_Resource')->getConnection('write'); - $adapter->rollBack(); + $adapter->rollbackTransparentTransaction(); } /** diff --git a/dev/tests/integration/framework/Magento/Test/Request.php b/dev/tests/integration/framework/Magento/Test/Request.php index 677ecee2bf54c..f9b331730ab5b 100644 --- a/dev/tests/integration/framework/Magento/Test/Request.php +++ b/dev/tests/integration/framework/Magento/Test/Request.php @@ -30,6 +30,13 @@ */ class Magento_Test_Request extends Mage_Core_Controller_Request_Http { + /** + * Server super-global mock + * + * @var array + */ + protected $_server = array(); + /** * Retrieve HTTP HOST. * This method is a stub - all parameters are ignored, just static value returned. @@ -43,4 +50,32 @@ public function getHttpHost($trimPort = true) { return 'localhost'; } + + /** + * Set "server" super-global mock + * + * @param array $server + * @return Magento_Test_Request + */ + public function setServer(array $server) + { + $this->_server = $server; + return $this; + } + + /** + * Overridden getter to avoid using of $_SERVER + * + * @param string|null $key + * @param mixed|null $default + * @return array|mixed|null + */ + public function getServer($key = null, $default = null) + { + if (null === $key) { + return $this->_server; + } + + return (isset($this->_server[$key])) ? $this->_server[$key] : $default; + } } diff --git a/dev/tests/integration/framework/Magento/Test/TestCase/ControllerAbstract.php b/dev/tests/integration/framework/Magento/Test/TestCase/ControllerAbstract.php index 5e76fcc76db10..7afa196f40b80 100644 --- a/dev/tests/integration/framework/Magento/Test/TestCase/ControllerAbstract.php +++ b/dev/tests/integration/framework/Magento/Test/TestCase/ControllerAbstract.php @@ -43,7 +43,15 @@ abstract class Magento_Test_TestCase_ControllerAbstract extends PHPUnit_Framewor protected $_runCode = ''; protected $_runScope = 'store'; protected $_runOptions = array(); + + /** + * @var Magento_Test_Request + */ protected $_request; + + /** + * @var Magento_Test_Response + */ protected $_response; /** @@ -85,7 +93,7 @@ public function dispatch($uri) /** * Request getter * - * @return Mage_Core_Controller_Request_Http + * @return Magento_Test_Request */ public function getRequest() { @@ -117,6 +125,28 @@ public function assert404NotFound() $this->assertContains('404 Not Found', $this->getResponse()->getBody()); } + /** + * Analyze response object and look for header with specified name, and assert a regex towards its value + * + * @param string $headerName + * @param string $valueRegex + * @throws PHPUnit_Framework_AssertionFailedError when header not found + */ + public function assertHeaderPcre($headerName, $valueRegex) + { + $headerFound = false; + $headers = $this->getResponse()->getHeaders(); + foreach ($headers as $header) { + if ($header['name'] === $headerName) { + $headerFound = true; + $this->assertRegExp($valueRegex, $header['value']); + } + } + if (!$headerFound) { + $this->fail("Header '{$headerName}' was not found. Headers dump:\n" . var_export($headers, 1)); + } + } + /** * Assert that there is a redirect to expected URL. * Omit expected URL to check that redirect to wherever has been occurred. diff --git a/dev/tests/integration/framework/tests/unit/testsuite/Magento/Test/Db/Adapter/TransactionInterfaceTest.php b/dev/tests/integration/framework/tests/unit/testsuite/Magento/Test/Db/Adapter/TransactionInterfaceTest.php new file mode 100644 index 0000000000000..ec6d1a73c05a3 --- /dev/null +++ b/dev/tests/integration/framework/tests/unit/testsuite/Magento/Test/Db/Adapter/TransactionInterfaceTest.php @@ -0,0 +1,106 @@ +_getAdapterMock($class); + $uniqid = uniqid(); + $adapter->expects($this->once())->method('beginTransaction')->will($this->returnValue($uniqid)); + $this->assertSame(0, $adapter->getTransactionLevel()); + $this->assertEquals($uniqid, $adapter->beginTransparentTransaction()); + $this->assertSame(-1, $adapter->getTransactionLevel()); + } + + /** + * @param string $class + * @dataProvider transparentTransactionDataProvider + */ + public function testRollbackTransparentTransaction($class) + { + $adapter = $this->_getAdapterMock($class); + $uniqid = uniqid(); + $adapter->expects($this->once())->method('rollback')->will($this->returnValue($uniqid)); + $adapter->beginTransparentTransaction(); + $this->assertEquals($uniqid, $adapter->rollbackTransparentTransaction()); + $this->assertSame(0, $adapter->getTransactionLevel()); + } + + /** + * @param string $class + * @dataProvider transparentTransactionDataProvider + */ + public function testCommitTransparentTransaction($class) + { + $adapter = $this->_getAdapterMock($class); + $uniqid = uniqid(); + $adapter->expects($this->once())->method('commit')->will($this->returnValue($uniqid)); + $adapter->beginTransparentTransaction(); + $this->assertEquals($uniqid, $adapter->commitTransparentTransaction()); + $this->assertSame(0, $adapter->getTransactionLevel()); + } + + /** + * @return array + */ + public function transparentTransactionDataProvider() + { + $result = array(); + foreach (glob(realpath(__DIR__ . '/../../../../../../../Magento/Test/Db/Adapter') . '/*.php') as $file) { + $suffix = basename($file, '.php'); + if (false === strpos($suffix, 'Interface')) { + $result[] = array("Magento_Test_Db_Adapter_{$suffix}"); + } + } + return $result; + } + + /** + * Instantiate specified adapter class and block all methods that would try to execute real queries + * + * @param string $class + * @return Magento_Test_Db_Adapter_TransactionInterface|PHPUnit_Framework_MockObject_MockObject + */ + protected function _getAdapterMock($class) + { + $adapter = $this->getMock($class, array('beginTransaction', 'rollback', 'commit'), array(), '', false); + $this->assertInstanceOf('Magento_Test_Db_Adapter_TransactionInterface', $adapter); + return $adapter; + } +} diff --git a/dev/tests/integration/framework/tests/unit/testsuite/Magento/Test/RequestTest.php b/dev/tests/integration/framework/tests/unit/testsuite/Magento/Test/RequestTest.php index 7d684e9ffc67f..243d6bbcc201f 100644 --- a/dev/tests/integration/framework/tests/unit/testsuite/Magento/Test/RequestTest.php +++ b/dev/tests/integration/framework/tests/unit/testsuite/Magento/Test/RequestTest.php @@ -27,11 +27,31 @@ class Magento_Test_RequestTest extends PHPUnit_Framework_TestCase { + /** + * @var Magento_Test_Request + */ + protected $_model = null; + + protected function setUp() + { + $this->_model = new Magento_Test_Request; + } + public function testGetHttpHost() { - $request = new Magento_Test_Request(); - $this->assertEquals('localhost', $request->getHttpHost()); - $this->assertEquals('localhost', $request->getHttpHost(false)); + $this->assertEquals('localhost', $this->_model->getHttpHost()); + $this->assertEquals('localhost', $this->_model->getHttpHost(false)); + } + + public function testSetGetServer() + { + $this->assertSame(array(), $this->_model->getServer()); + $this->assertSame($this->_model, $this->_model->setServer(array('test' => 'value', 'null' => null))); + $this->assertSame(array('test' => 'value', 'null' => null), $this->_model->getServer()); + $this->assertEquals('value', $this->_model->getServer('test')); + $this->assertSame(null, $this->_model->getServer('non-existing')); + $this->assertSame('default', $this->_model->getServer('non-existing', 'default')); + $this->assertSame(null, $this->_model->getServer('null')); } } diff --git a/dev/tests/integration/testsuite/Mage/Adminhtml/controllers/Sales/OrderControllerTest.php b/dev/tests/integration/testsuite/Mage/Adminhtml/controllers/Sales/OrderControllerTest.php index 52cc46d27cb07..287d605e4bd24 100644 --- a/dev/tests/integration/testsuite/Mage/Adminhtml/controllers/Sales/OrderControllerTest.php +++ b/dev/tests/integration/testsuite/Mage/Adminhtml/controllers/Sales/OrderControllerTest.php @@ -34,7 +34,7 @@ public function testIndexAction() } /** - * @magentoDataFixture Mage/Sales/_files/order_commit_workaround.php + * @magentoDataFixture Mage/Sales/_files/order.php */ public function testIndexActionWithOrder() { @@ -43,7 +43,7 @@ public function testIndexActionWithOrder() } /** - * @magentoDataFixture Mage/Sales/_files/order_commit_workaround.php + * @magentoDataFixture Mage/Sales/_files/order.php */ public function testOrderViewAction() { diff --git a/dev/tests/integration/testsuite/Mage/Sales/_files/transactions_commit_workaround.php b/dev/tests/integration/testsuite/Mage/Catalog/_files/product_special_price.php similarity index 89% rename from dev/tests/integration/testsuite/Mage/Sales/_files/transactions_commit_workaround.php rename to dev/tests/integration/testsuite/Mage/Catalog/_files/product_special_price.php index 04094179627f0..605c301a08115 100644 --- a/dev/tests/integration/testsuite/Mage/Sales/_files/transactions_commit_workaround.php +++ b/dev/tests/integration/testsuite/Mage/Catalog/_files/product_special_price.php @@ -19,10 +19,11 @@ * needs please refer to http://www.magentocommerce.com for more information. * * @category Mage - * @package Mage_Sales + * @package Mage_Catalog * @subpackage integration_tests * @copyright Copyright (c) 2012 Magento Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ -require __DIR__ . '/transactions.php'; -$order->afterCommitCallback(); + +require __DIR__ . '/products.php'; +$product->setSpecialPrice('5.99')->save(); diff --git a/dev/tests/integration/testsuite/Mage/Catalog/_files/products_new.php b/dev/tests/integration/testsuite/Mage/Catalog/_files/products_new.php index 98e99144ad5bd..d2b16f0cd1607 100644 --- a/dev/tests/integration/testsuite/Mage/Catalog/_files/products_new.php +++ b/dev/tests/integration/testsuite/Mage/Catalog/_files/products_new.php @@ -38,4 +38,6 @@ ->setStockData(array('qty' => 100, 'is_in_stock' => 1)) ->setNewsFromDate(date('Y-m-d', strtotime('-2 day'))) ->setNewsNewsToDate(date('Y-m-d', strtotime('+2 day'))) + ->setDescription('description') + ->setShortDescription('short desc') ->save(); diff --git a/dev/tests/integration/testsuite/Mage/Catalog/_files/two_products.php b/dev/tests/integration/testsuite/Mage/Catalog/_files/two_products.php index ba361be241b71..d58dd00ea5184 100644 --- a/dev/tests/integration/testsuite/Mage/Catalog/_files/two_products.php +++ b/dev/tests/integration/testsuite/Mage/Catalog/_files/two_products.php @@ -71,7 +71,7 @@ ->setStockData( array( 'use_config_manage_stock' => 1, - 'qty' => 100, + 'qty' => 50, 'is_qty_decimal' => 0, 'is_in_stock' => 1, ) diff --git a/dev/tests/integration/testsuite/Mage/Core/Model/_files/_layout_update.xml b/dev/tests/integration/testsuite/Mage/Core/Model/_files/_layout_update.xml index f78f627f8b7c8..07051ea2ac061 100644 --- a/dev/tests/integration/testsuite/Mage/Core/Model/_files/_layout_update.xml +++ b/dev/tests/integration/testsuite/Mage/Core/Model/_files/_layout_update.xml @@ -27,7 +27,7 @@ */ --> - + Magento Admin diff --git a/dev/tests/integration/testsuite/Mage/Core/Model/_files/design/frontend/test/default/Mage_Core/layout.xml b/dev/tests/integration/testsuite/Mage/Core/Model/_files/design/frontend/test/default/Mage_Core/layout.xml index 7c55616c04543..b60af132d35b0 100644 --- a/dev/tests/integration/testsuite/Mage/Core/Model/_files/design/frontend/test/default/Mage_Core/layout.xml +++ b/dev/tests/integration/testsuite/Mage/Core/Model/_files/design/frontend/test/default/Mage_Core/layout.xml @@ -29,7 +29,7 @@ - + Magento Admin prototype/prototype.js diff --git a/dev/tests/integration/testsuite/Mage/Paypal/Model/IpnTest.php b/dev/tests/integration/testsuite/Mage/Paypal/Model/IpnTest.php index d786e6bbe82c4..dd92be39e9a17 100644 --- a/dev/tests/integration/testsuite/Mage/Paypal/Model/IpnTest.php +++ b/dev/tests/integration/testsuite/Mage/Paypal/Model/IpnTest.php @@ -40,7 +40,7 @@ protected function setUp() /** * @param string $currencyCode * @dataProvider currencyProvider - * @magentoDataFixture Mage/Paypal/_files/order_express_commit_workaround.php + * @magentoDataFixture Mage/Paypal/_files/order_express.php * @magentoConfigFixture current_store payment/paypal_direct/active 1 * @magentoConfigFixture current_store payment/paypal_express/active 1 * @magentoConfigFixture current_store paypal/general/merchant_country US @@ -53,7 +53,7 @@ public function testProcessIpnRequestExpressCurrency($currencyCode) /** * @param string $currencyCode * @dataProvider currencyProvider - * @magentoDataFixture Mage/Paypal/_files/order_standard_commit_workaround.php + * @magentoDataFixture Mage/Paypal/_files/order_standard.php * @magentoConfigFixture current_store payment/paypal_standard/active 1 * @magentoConfigFixture current_store paypal/general/business_account merchant_2012050718_biz@example.com */ diff --git a/dev/tests/integration/testsuite/Mage/Paypal/controllers/HostedproControllerTest.php b/dev/tests/integration/testsuite/Mage/Paypal/controllers/HostedproControllerTest.php index dc0ad430bde93..31fdf60e56ec7 100644 --- a/dev/tests/integration/testsuite/Mage/Paypal/controllers/HostedproControllerTest.php +++ b/dev/tests/integration/testsuite/Mage/Paypal/controllers/HostedproControllerTest.php @@ -26,7 +26,7 @@ */ /** - * @magentoDataFixture Mage/Sales/_files/order_commit_workaround.php + * @magentoDataFixture Mage/Sales/_files/order.php */ class Mage_Paypal_HostedproControllerTest extends Magento_Test_TestCase_ControllerAbstract { diff --git a/dev/tests/integration/testsuite/Mage/Paypal/controllers/PayflowControllerTest.php b/dev/tests/integration/testsuite/Mage/Paypal/controllers/PayflowControllerTest.php index c255c51d7bc7d..2390b2a8d6d7d 100644 --- a/dev/tests/integration/testsuite/Mage/Paypal/controllers/PayflowControllerTest.php +++ b/dev/tests/integration/testsuite/Mage/Paypal/controllers/PayflowControllerTest.php @@ -26,7 +26,7 @@ */ /** - * @magentoDataFixture Mage/Sales/_files/order_commit_workaround.php + * @magentoDataFixture Mage/Sales/_files/order.php */ class Mage_Paypal_PayflowControllerTest extends Magento_Test_TestCase_ControllerAbstract { @@ -37,7 +37,7 @@ public function setUp() $order = new Mage_Sales_Model_Order(); $order->load('100000001', 'increment_id'); $order->getPayment()->setMethod(Mage_Paypal_Model_Config::METHOD_PAYFLOWLINK); - $order->save()->afterCommitCallback(); + $order->save(); $session = Mage::getSingleton('Mage_Checkout_Model_Session'); $session->setLastRealOrderId($order->getRealOrderId()) diff --git a/dev/tests/integration/testsuite/Mage/Paypal/controllers/PayflowadvancedControllerTest.php b/dev/tests/integration/testsuite/Mage/Paypal/controllers/PayflowadvancedControllerTest.php index f2a7b3930f848..ab82a69215b95 100644 --- a/dev/tests/integration/testsuite/Mage/Paypal/controllers/PayflowadvancedControllerTest.php +++ b/dev/tests/integration/testsuite/Mage/Paypal/controllers/PayflowadvancedControllerTest.php @@ -26,7 +26,7 @@ */ /** - * @magentoDataFixture Mage/Sales/_files/order_commit_workaround.php + * @magentoDataFixture Mage/Sales/_files/order.php */ class Mage_Paypal_PayflowadvancedControllerTest extends Magento_Test_TestCase_ControllerAbstract { diff --git a/dev/tests/integration/testsuite/Mage/Paypal/controllers/StandardControllerTest.php b/dev/tests/integration/testsuite/Mage/Paypal/controllers/StandardControllerTest.php index 5a9beb96dc735..ebd5f29d90c03 100644 --- a/dev/tests/integration/testsuite/Mage/Paypal/controllers/StandardControllerTest.php +++ b/dev/tests/integration/testsuite/Mage/Paypal/controllers/StandardControllerTest.php @@ -26,7 +26,7 @@ */ /** - * @magentoDataFixture Mage/Sales/_files/order_commit_workaround.php + * @magentoDataFixture Mage/Sales/_files/order.php */ class Mage_Paypal_StandardControllerTest extends Magento_Test_TestCase_ControllerAbstract { @@ -35,7 +35,7 @@ public function testRedirectActionIsContentGenerated() $order = new Mage_Sales_Model_Order(); $order->load('100000001', 'increment_id'); $order->getPayment()->setMethod(Mage_Paypal_Model_Config::METHOD_WPS); - $order->save()->afterCommitCallback(); + $order->save(); $session = Mage::getSingleton('Mage_Checkout_Model_Session'); $session->setLastRealOrderId($order->getRealOrderId()) diff --git a/dev/tests/integration/testsuite/Mage/Sales/_files/order_commit_workaround.php b/dev/tests/integration/testsuite/Mage/Review/_files/reviews.php similarity index 61% rename from dev/tests/integration/testsuite/Mage/Sales/_files/order_commit_workaround.php rename to dev/tests/integration/testsuite/Mage/Review/_files/reviews.php index 7e1b02175e411..6b793dfcba31d 100644 --- a/dev/tests/integration/testsuite/Mage/Sales/_files/order_commit_workaround.php +++ b/dev/tests/integration/testsuite/Mage/Review/_files/reviews.php @@ -19,10 +19,21 @@ * needs please refer to http://www.magentocommerce.com for more information. * * @category Mage - * @package Mage_Sales + * @package Mage_Review * @subpackage integration_tests * @copyright Copyright (c) 2012 Magento Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ -require __DIR__ . '/order.php'; -$order->afterCommitCallback(); + +require __DIR__ . '/../../Catalog/_files/two_products.php'; + +$review = new Mage_Review_Model_Review(array( + 'nickname' => 'Nickname', 'title' => 'Review Summary', 'detail' => 'Review text' +)); +$review->setEntityId($review->getEntityIdByCode(Mage_Review_Model_Review::ENTITY_PRODUCT_CODE)) + ->setEntityPkValue($product->getId()) // the last product from the fixture file included above + ->setStatusId(Mage_Review_Model_Review::STATUS_PENDING) + ->setStoreId(Mage::app()->getStore()->getId()) + ->setStores(array(Mage::app()->getStore()->getId())) + ->save() +; diff --git a/dev/tests/integration/testsuite/Mage/Rss/Helper/DataTest.php b/dev/tests/integration/testsuite/Mage/Rss/Helper/DataTest.php deleted file mode 100644 index dbd5500fcf9c2..0000000000000 --- a/dev/tests/integration/testsuite/Mage/Rss/Helper/DataTest.php +++ /dev/null @@ -1,70 +0,0 @@ -_helper = new Mage_Rss_Helper_Data; - } - - /** - * @magentoAppIsolation enabled - */ - public function testAuthAdminLoggedIn() - { - $admin = new Varien_Object(array('id' => 1)); - $session = Mage::getSingleton('Mage_Rss_Model_Session'); - $session->setAdmin($admin); - $this->assertEquals($admin, $this->_helper->authAdmin('')); - } - - public function testAuthAdminNotLogged() - { - $this->markTestIncomplete('Incomplete until helper stops exiting script for non-logged user'); - $this->assertFalse($this->_helper->authAdmin('')); - } - - /** - * @magentoAppIsolation enabled - */ - public function testAuthAdminLogin() - { - $_SERVER['PHP_AUTH_USER'] = Magento_Test_Bootstrap::ADMIN_NAME; - $_SERVER['PHP_AUTH_PW'] = Magento_Test_Bootstrap::ADMIN_PASSWORD; - $this->assertInstanceOf('Mage_User_Model_User', $this->_helper->authAdmin('')); - - $response = Mage::app()->getResponse(); - $code = $response->getHttpResponseCode(); - $this->assertFalse(($code >= 300) && ($code < 400)); - } -} diff --git a/dev/tests/integration/testsuite/Mage/Rss/controllers/CatalogControllerTest.php b/dev/tests/integration/testsuite/Mage/Rss/controllers/CatalogControllerTest.php index 227b2cadc1e9a..17218c97834cc 100644 --- a/dev/tests/integration/testsuite/Mage/Rss/controllers/CatalogControllerTest.php +++ b/dev/tests/integration/testsuite/Mage/Rss/controllers/CatalogControllerTest.php @@ -28,62 +28,143 @@ class Mage_Rss_CatalogControllerTest extends Magento_Test_TestCase_ControllerAbstract { /** - * @dataProvider actionsDataProvider + * @param string $action + * @dataProvider actionNoFeedDataProvider */ - public function testRssActionsNonLoggedUser($action) + public function testActionsNoFeed($action) { - $this->markTestIncomplete('Incomplete until Mage_Core_Helper_Http stops exiting script for non-logged user'); - $this->dispatch('rss/catalog/' . $action . '/'); + $this->dispatch("rss/catalog/{$action}"); + $this->assertHeaderPcre('Http/1.1', '/^404 Not Found$/'); + $this->assertEquals('There was no RSS feed enabled.', $this->getResponse()->getBody()); } /** - * @dataProvider actionsDataProvider + * @return array */ - public function testRssActionsLoggedUser($action) + public function actionNoFeedDataProvider() { - $admin = new Mage_User_Model_User; - $admin->loadByUsername(Magento_Test_Bootstrap::ADMIN_NAME); - $session = Mage::getSingleton('Mage_Rss_Model_Session'); - $session->setAdmin($admin); - - $adminSession = Mage::getSingleton('Mage_Backend_Model_Auth_Session'); - $adminSession->setUpdatedAt(time()) - ->setUser($admin); + return array(array('new'), array('special'), array('salesrule'), array('tag'), array('category')); + } - $this->dispatch('rss/catalog/' . $action . '/'); + /** + * @magentoDataFixture Mage/Catalog/_files/products_new.php + * @magentoConfigFixture current_store rss/catalog/new 1 + */ + public function testNewAction() + { + $this->dispatch('rss/catalog/new'); + $this->assertContains('New Product', $this->getResponse()->getBody()); + } + /** + * @magentoDataFixture Mage/Catalog/_files/product_special_price.php + * @magentoConfigFixture current_store rss/catalog/special 1 + */ + public function testSpecialAction() + { + $this->dispatch('rss/catalog/special'); $body = $this->getResponse()->getBody(); - $this->assertNotEmpty($body); + $this->assertContains('$10.00', $body); + $this->assertContains('$5.99', $body); + } - $response = Mage::app()->getResponse(); - $code = $response->getHttpResponseCode(); - $this->assertFalse(($code >= 300) && ($code < 400)); + /** + * @magentoConfigFixture current_store rss/catalog/salesrule 1 + */ + public function testSalesruleAction() + { + $this->dispatch('rss/catalog/salesrule'); + $this->assertHeaderPcre('Content-Type', '/text\/xml/'); + // to improve accuracy of the test, implement a fixture of a shopping cart price rule with a coupon + $this->assertContains( + 'http://localhost/index.php/rss/catalog/salesrule/', $this->getResponse()->getBody() + ); + } - $xmlContentType = false; - $headers = $response->getHeaders(); - foreach ($headers as $header) { - if ($header['name'] != 'Content-Type') { - continue; - } - if (strpos($header['value'], 'text/xml') !== false) { - $xmlContentType = true; - } - } - $this->assertTrue($xmlContentType, 'Rss document should output xml header'); + /** + * @magentoConfigFixture current_store rss/catalog/tag 1 + */ + public function testTagAction() + { + $this->dispatch('rss/catalog/tag'); + // this test is also inaccurate without a fixture of product with tags + $this->assertEquals('nofeed', $this->getRequest()->getActionName()); + $this->assertHeaderPcre('Status', '/^404 File not found$/'); + } - $body = $response->getBody(); - $this->assertContains('dispatch("rss/catalog/{$action}"); + $this->assertHeaderPcre('Http/1.1', '/^401 Unauthorized$/'); } /** * @return array */ - public function actionsDataProvider() + public function authorizationFailedDataProvider() { return array( array('notifystock'), array('review') ); } -} + /** + * @magentoDataFixture Mage/Catalog/_files/two_products.php + * @magentoConfigFixture current_store cataloginventory/item_options/notify_stock_qty 75 + */ + public function testNotifyStockAction() + { + // workaround: trigger updating "low stock date", because RSS collection requires it to be not null + Mage::getResourceSingleton('Mage_CatalogInventory_Model_Resource_Stock')->updateLowStockDate(); + $this->_loginAdmin(); + $this->dispatch('rss/catalog/notifystock'); + + $this->assertHeaderPcre('Content-Type', '/text\/xml/'); + + // assert that among 2 products in fixture, there is only one with 50 qty + $body = $this->getResponse()->getBody(); + $this->assertNotContains('', $body); // this one was supposed to have qty 100 ( > 75) + $this->assertContains('', $body); // 50 < 75 + } + + /** + * @magentoDataFixture Mage/Review/_files/reviews.php + */ + public function testReviewAction() + { + $this->_loginAdmin(); + $this->dispatch('rss/catalog/review'); + $this->assertHeaderPcre('Content-Type', '/text\/xml/'); + $body = $this->getResponse()->getBody(); + $this->assertContains('"Simple Product2"', $body); + $this->assertContains('Review text', $body); + } + + /** + * @magentoConfigFixture current_store rss/catalog/category 1 + */ + public function testCategoryAction() + { + $this->getRequest()->setParam('cid', Mage::app()->getStore()->getRootCategoryId()); + $this->dispatch('rss/catalog/category'); + $this->assertStringMatchesFormat( + '%Ahttp://localhost/index.php/catalog/category/view/%A/id/2/%A', + $this->getResponse()->getBody() + ); + } + + /** + * Emulate administrator logging in + */ + protected function _loginAdmin() + { + $this->getRequest()->setServer(array( + 'PHP_AUTH_USER' => Magento_Test_Bootstrap::ADMIN_NAME, + 'PHP_AUTH_PW' => Magento_Test_Bootstrap::ADMIN_PASSWORD + )); + } +} diff --git a/dev/tests/integration/testsuite/Mage/Rss/controllers/IndexControllerTest.php b/dev/tests/integration/testsuite/Mage/Rss/controllers/IndexControllerTest.php new file mode 100644 index 0000000000000..198293c82c0e3 --- /dev/null +++ b/dev/tests/integration/testsuite/Mage/Rss/controllers/IndexControllerTest.php @@ -0,0 +1,69 @@ +dispatch('rss/index/index'); + $this->assert404NotFound(); + } + + /** + * @magentoConfigFixture current_store rss/config/active 1 + * @magentoConfigFixture current_store rss/catalog/new 1 + */ + public function testIndexAction() + { + $this->dispatch('rss/index/index'); + $this->assertContains('/rss/catalog/new/', $this->getResponse()->getBody()); + } + + public function testNofeedAction() + { + $this->dispatch('rss/index/nofeed'); + $this->assertHeaderPcre('Status', '/404/'); + $this->assertHeaderPcre('Content-Type', '/text\/plain/'); + } + + /** + * @magentoConfigFixture current_store rss/wishlist/active 1 + * @magentoDataFixture Mage/Wishlist/_files/wishlist.php + * @magentoAppIsolation enabled + */ + public function testWishlistAction() + { + $wishlist = new Mage_Wishlist_Model_Wishlist; + $wishlist->load('fixture_unique_code', 'sharing_code'); + $this->getRequest()->setParam('wishlist_id', $wishlist->getId()) + ->setParam('data', base64_encode('1')) + ; + Mage::getSingleton('Mage_Customer_Model_Session')->login('customer@example.com', 'password'); + $this->dispatch('rss/index/wishlist'); + $this->assertContains('', $this->getResponse()->getBody()); + } +} diff --git a/dev/tests/integration/testsuite/Mage/Rss/controllers/OrderControllerTest.php b/dev/tests/integration/testsuite/Mage/Rss/controllers/OrderControllerTest.php index 686029fcb78e1..ebc412e2a4654 100644 --- a/dev/tests/integration/testsuite/Mage/Rss/controllers/OrderControllerTest.php +++ b/dev/tests/integration/testsuite/Mage/Rss/controllers/OrderControllerTest.php @@ -27,45 +27,61 @@ class Mage_Rss_OrderControllerTest extends Magento_Test_TestCase_ControllerAbstract { - public function testNewActionNonLoggedUser() + /** + * Reuse URI for "new" action + */ + const NEW_ORDER_URI = 'rss/order/new'; + + public function testNewActionAuthorizationFailed() { - $this->markTestIncomplete('Incomplete until Mage_Core_Helper_Http stops exiting script for non-logged user'); - $this->dispatch('rss/order/new/'); + $this->dispatch(self::NEW_ORDER_URI); + $this->assertHeaderPcre('Http/1.1', '/^401 Unauthorized$/'); } - public function testNewActionLoggedUser() + /** + * @magentoDataFixture Mage/Sales/_files/order.php + */ + public function testNewAction() { - $admin = new Mage_User_Model_User; - $admin->loadByUsername(Magento_Test_Bootstrap::ADMIN_NAME); - $session = Mage::getSingleton('Mage_Rss_Model_Session'); - $session->setAdmin($admin); - - $adminSession = Mage::getSingleton('Mage_Backend_Model_Auth_Session'); - $adminSession->setUpdatedAt(time()) - ->setUser($admin); - - $this->dispatch('rss/order/new/'); - - $body = $this->getResponse()->getBody(); - $this->assertNotEmpty($body); + $this->getRequest()->setServer(array( + 'PHP_AUTH_USER' => Magento_Test_Bootstrap::ADMIN_NAME, + 'PHP_AUTH_PW' => Magento_Test_Bootstrap::ADMIN_PASSWORD + )); + $this->dispatch(self::NEW_ORDER_URI); + $this->assertHeaderPcre('Content-Type', '/text\/xml/'); + $this->assertContains('#100000001', $this->getResponse()->getBody()); + } - $response = Mage::app()->getResponse(); - $code = $response->getHttpResponseCode(); - $this->assertFalse(($code >= 300) && ($code < 400)); + public function testNotLoggedIn() + { + $this->dispatch(self::NEW_ORDER_URI); + $this->assertHeaderPcre('Http/1.1', '/^401 Unauthorized$/'); + } - $xmlContentType = false; - $headers = $response->getHeaders(); - foreach ($headers as $header) { - if ($header['name'] != 'Content-Type') { - continue; - } - if (strpos($header['value'], 'text/xml') !== false) { - $xmlContentType = true; - } - } - $this->assertTrue($xmlContentType, 'Rss document should output xml header'); + /** + * @param string $login + * @param string $password + * @dataProvider invalidAccessDataProvider + * @magentoDataFixture Mage/User/_files/dummy_user.php + * @covers Mage_Rss_OrderController::authenticateAndAuthorizeAdmin + */ + public function testInvalidAccess($login, $password) + { + $this->getRequest()->setServer(array('PHP_AUTH_USER' => $login, 'PHP_AUTH_PW' => $password)); + $this->dispatch(self::NEW_ORDER_URI); + $this->assertHeaderPcre('Http/1.1', '/^401 Unauthorized$/'); + } - $body = $response->getBody(); - $this->assertContains(' array('', Magento_Test_Bootstrap::ADMIN_PASSWORD), + 'no password' => array(Magento_Test_Bootstrap::ADMIN_NAME, ''), + 'no login and password' => array('', ''), + 'user with inappropriate ACL' => array('dummy_username', 'dummy_password1'), + ); } } diff --git a/dev/tests/integration/testsuite/Mage/Sales/Model/AbstractTest.php b/dev/tests/integration/testsuite/Mage/Sales/Model/AbstractTest.php index b461dc8034999..7d2e23b260425 100644 --- a/dev/tests/integration/testsuite/Mage/Sales/Model/AbstractTest.php +++ b/dev/tests/integration/testsuite/Mage/Sales/Model/AbstractTest.php @@ -27,7 +27,7 @@ class Mage_Sales_Model_AbstractTest extends PHPUnit_Framework_TestCase { /** - * @magentoDataFixture Mage/Sales/_files/order_commit_workaround.php + * @magentoDataFixture Mage/Sales/_files/order.php */ public function testAfterCommitCallbackOrderGrid() { diff --git a/dev/tests/integration/testsuite/Mage/Sales/Model/Order/Payment/TransactionTest.php b/dev/tests/integration/testsuite/Mage/Sales/Model/Order/Payment/TransactionTest.php index 14a9e49041b58..e6967417d7a7a 100644 --- a/dev/tests/integration/testsuite/Mage/Sales/Model/Order/Payment/TransactionTest.php +++ b/dev/tests/integration/testsuite/Mage/Sales/Model/Order/Payment/TransactionTest.php @@ -29,7 +29,7 @@ * Tests transaction model: * * @see Mage_Sales_Model_Order_Payment_Transaction - * @magentoDataFixture Mage/Sales/_files/transactions_commit_workaround.php + * @magentoDataFixture Mage/Sales/_files/transactions.php */ class Mage_Sales_Model_Order_Payment_TransactionTest extends PHPUnit_Framework_TestCase { diff --git a/dev/tests/integration/testsuite/Mage/Sales/_files/order.php b/dev/tests/integration/testsuite/Mage/Sales/_files/order.php index f2c863c272bde..03ecc47a8277c 100644 --- a/dev/tests/integration/testsuite/Mage/Sales/_files/order.php +++ b/dev/tests/integration/testsuite/Mage/Sales/_files/order.php @@ -43,6 +43,7 @@ ->setCustomerIsGuest(true) ->setBillingAddress($billingAddress) ->setShippingAddress($shippingAddress) + ->setStoreId(Mage::app()->getStore()->getId()) ->setPayment($payment) ; $order->save(); diff --git a/dev/tests/integration/testsuite/Mage/Wishlist/_files/wishlist.php b/dev/tests/integration/testsuite/Mage/Wishlist/_files/wishlist.php index e0e415d536840..dbcdf73d5fde7 100644 --- a/dev/tests/integration/testsuite/Mage/Wishlist/_files/wishlist.php +++ b/dev/tests/integration/testsuite/Mage/Wishlist/_files/wishlist.php @@ -42,4 +42,4 @@ // 'validate_datetime_2' => '', // 'qty' => '1', ))); -$wishlist->save(); +$wishlist->setSharingCode('fixture_unique_code')->save(); diff --git a/dev/tests/integration/testsuite/integrity/LayoutTest.php b/dev/tests/integration/testsuite/integrity/LayoutTest.php index 23c68dd70acbb..b765b19108b5c 100644 --- a/dev/tests/integration/testsuite/integrity/LayoutTest.php +++ b/dev/tests/integration/testsuite/integrity/LayoutTest.php @@ -56,14 +56,7 @@ public function testHandlesHierarchy($area, $package, $theme) /** @var Mage_Core_Model_Layout_Element $node */ $errors = array(); foreach ($handles as $node) { - $error = $this->_validatePageNodeInHierarchy($node, $xml); - if ($error) { - $index = $node->getName(); - if (!isset($errors[$index])) { - $errors[$index] = array(); - } - $errors[$index][] = $error; - } + $this->_collectHierarchyErrors($node, $xml, $errors); } if ($errors) { @@ -90,49 +83,25 @@ protected function _composeXml($area, $package, $theme) } /** - * Validates node's declared position in hierarchy. Returns error description, if something is wrong. + * Validate node's declared position in hierarchy and add errors to the specified array if found * * @param SimpleXMLElement $node * @param Mage_Core_Model_Layout_Element $xml - * @return string|false - * @SuppressWarnings(PHPMD.CyclomaticComplexity) + * @param array &$errors */ - protected function _validatePageNodeInHierarchy($node, $xml) + protected function _collectHierarchyErrors($node, $xml, &$errors) { - $type = $node->getAttribute('type'); - $parent = $node->getAttribute('parent'); - $owner = $node->getAttribute('owner'); - - switch ($type) { - case Mage_Core_Model_Layout_Update::TYPE_PAGE: - if ($owner) { - return 'Attribute "owner" is not appropriate for page types'; - } - $refName = $parent; - break; - case Mage_Core_Model_Layout_Update::TYPE_FRAGMENT: - if ($parent) { - return 'Attribute "parent" is not appropriate for page fragment types'; - } - if (!$owner) { - return 'No owner specified for page fragment type handle'; - } - $refName = $owner; - break; - default: - return "Unknown handle type: {$type}"; - } - + $name = $node->getName(); + $refName = $node->getAttribute('type') == Mage_Core_Model_Layout_Update::TYPE_FRAGMENT + ? $node->getAttribute('owner') : $node->getAttribute('parent'); if ($refName) { $refNode = $xml->xpath("/layouts/{$refName}"); - if (!$refNode || !count($refNode)) { - return "Node '{$refName}', referenced in hierarchy, does not exist"; - } - if ($refNode[0]->getAttribute('type') == Mage_Core_Model_Layout_Update::TYPE_FRAGMENT) { - return "Page fragment type '{$refName}', cannot be an ancestor in a hierarchy"; + if (!$refNode) { + $errors[$name][] = "Node '{$refName}', referenced in hierarchy, does not exist"; + } elseif ($refNode[0]->getAttribute('type') == Mage_Core_Model_Layout_Update::TYPE_FRAGMENT) { + $errors[$name][] = "Page fragment type '{$refName}', cannot be an ancestor in a hierarchy"; } } - return false; } /** diff --git a/dev/tests/integration/testsuite/integrity/modular/TemplateFilesTest.php b/dev/tests/integration/testsuite/integrity/modular/TemplateFilesTest.php index deca37175f65c..b8ad3a9877f3d 100644 --- a/dev/tests/integration/testsuite/integrity/modular/TemplateFilesTest.php +++ b/dev/tests/integration/testsuite/integrity/modular/TemplateFilesTest.php @@ -28,7 +28,7 @@ /** * @group integrity */ -class Integrity_Modular_TemplateFilesTest extends PHPUnit_Framework_TestCase +class Integrity_Modular_TemplateFilesTest extends Magento_Test_TestCase_IntegrityAbstract { /** * @param string $module @@ -56,6 +56,9 @@ public function allTemplatesDataProvider() { $templates = array(); foreach (Utility_Classes::collectModuleClasses('Block') as $blockClass => $module) { + if (!in_array($module, $this->_getEnabledModules())) { + continue; + } $class = new ReflectionClass($blockClass); if ($class->isAbstract() || !$class->isSubclassOf('Mage_Core_Block_Template')) { continue; diff --git a/dev/tests/static/framework/Inspection/CopyPasteDetector/Command.php b/dev/tests/static/framework/Inspection/CopyPasteDetector/Command.php index 4a8e34f690327..3002161a8e063 100644 --- a/dev/tests/static/framework/Inspection/CopyPasteDetector/Command.php +++ b/dev/tests/static/framework/Inspection/CopyPasteDetector/Command.php @@ -87,44 +87,4 @@ protected function _buildShellCmd($whiteList, $blackList) . ' ' . $whiteList ; } - - /** - * Runs command and produces report in html format - * - * @param array $whiteList Files/directories to be inspected - * @param array $blackList Files/directories to be excluded from the inspection - * @return bool - */ - public function run(array $whiteList, array $blackList = array()) - { - $result = parent::run($whiteList, $blackList); - if ($result) { - $generateHtmlResult = $this->_generateHtmlReport(); - if ($generateHtmlResult === false) { - $result = false; - } - } - return $result; - } - - /** - * Generate HTML representation for an existing XML report using XSLT transformation - * - * @return bool|null - */ - protected function _generateHtmlReport() - { - if ($this->_execShellCmd('xsltproc --version') === false) { - return null; - } - $xsltFile = __DIR__ . '/html_report.xslt'; - $result = $this->_execShellCmd(sprintf( - "xsltproc %s %s > %s", - escapeshellarg($xsltFile), - escapeshellarg($this->_reportFile), - escapeshellarg("{$this->_reportFile}.html") - )); - $this->_generateLastRunMessage(); - return ($result !== false); - } } diff --git a/dev/tests/static/framework/Inspection/CopyPasteDetector/html_report.xslt b/dev/tests/static/framework/Inspection/CopyPasteDetector/html_report.xslt deleted file mode 100644 index 2078185125b2d..0000000000000 --- a/dev/tests/static/framework/Inspection/CopyPasteDetector/html_report.xslt +++ /dev/null @@ -1,98 +0,0 @@ - - - - - - - - - - - - - -

Summary of duplicated code

- This page summarizes the code fragments that have been found to be replicated in the code. - Only those fragments longer than 30 lines of code are shown. -

- - - - - - - - - - - - - -
# duplicationsTotal linesTotal tokensApprox # bytes
-

- You expand and collapse the code fragments using the + buttons. You can also navigate to the source code by clicking - on the file names. -

- - - - - - - - - - - - - - - -
IDFilesLines
- - - - -
../src/.html# line
-
# lines :
- - - -
- - - -
-

- - - - - - - diff --git a/dev/tests/static/framework/tests/unit/testsuite/Inspection/CopyPasteDetector/CommandTest.php b/dev/tests/static/framework/tests/unit/testsuite/Inspection/CopyPasteDetector/CommandTest.php index 270afbd0ca129..16b8f6d14a88f 100644 --- a/dev/tests/static/framework/tests/unit/testsuite/Inspection/CopyPasteDetector/CommandTest.php +++ b/dev/tests/static/framework/tests/unit/testsuite/Inspection/CopyPasteDetector/CommandTest.php @@ -101,28 +101,4 @@ public function testRun() ; $this->_cmd->run(array('some/test/dir with space', 'some/test/file with space.php')); } - - public function testRunHtmlReport() - { - $this->_cmd - ->expects($this->at(0)) - ->method('_execShellCmd') - ->with($this->stringContains('phpcpd')) - ; - $this->_cmd - ->expects($this->at(1)) - ->method('_execShellCmd') - ->with($this->stringContains('xsltproc')) - ->will($this->returnValue('Using libxml X, libxslt Y and libexslt Z')) - ; - $expectedQuoteChar = substr(escapeshellarg(' '), 0, 1); - $expectedXsltCmd = 'xsltproc "%s/html_report.xslt" "some/report/file.xml" > "some/report/file.xml.html"'; - $expectedXsltCmd = str_replace('"', $expectedQuoteChar, $expectedXsltCmd); - $this->_cmd - ->expects($this->at(2)) - ->method('_execShellCmd') - ->with($this->matches($expectedXsltCmd)) - ; - $this->_cmd->run(array()); - } } diff --git a/dev/tests/static/testsuite/Integrity/LayoutTest.php b/dev/tests/static/testsuite/Integrity/LayoutTest.php index db169e3f1d76c..3390250313b2b 100644 --- a/dev/tests/static/testsuite/Integrity/LayoutTest.php +++ b/dev/tests/static/testsuite/Integrity/LayoutTest.php @@ -137,6 +137,60 @@ protected function _getCodeFrontendHandles() return $this->_codeFrontendHandles; } + /** + * Suppressing PHPMD because of complex logic of validation. The problem is architectural, rather than in the test + * + * @param string $file + * @dataProvider layoutFilesDataProvider + * @SuppressWarnings(PHPMD.CyclomaticComplexity) + */ + public function testHandleDeclaration($file) + { + if (strpos($file, 'Mage/XmlConnect')) { + $this->markTestSkipped('Mage_XmlConnect module support is abandoned.'); + } + $issues = array(); + $xml = simplexml_load_file($file); + $handles = $xml->xpath('/layout/*'); + /** @var $node SimpleXMLElement */ + foreach ($handles as $node) { + $handleMessage = "Handle '{$node->getName()}':"; + $type = $node['type']; + $parent = $node['parent']; + $owner = $node['owner']; + if ($type) { + switch ($type) { + case 'page': + if ($owner) { + $issues[] = "{$handleMessage} attribute 'owner' is inappropriate for page types"; + } + break; + case 'fragment': + if ($parent) { + $issues[] = "{$handleMessage} attribute 'parent' is inappropriate for page fragment types"; + } + if (!$owner) { + $issues[] = "{$handleMessage} no 'owner' specified for page fragment type"; + } + break; + default: + $issues[] = "{$handleMessage} unknown type '{$type}'"; + break; + } + } else { + if ($node->xpath('child::label')) { + $issues[] = "{$handleMessage} 'label' child node is defined, but 'type' attribute is not"; + } + if ($parent || $owner) { + $issues[] = "{$handleMessage} 'parent' or 'owner' is defined, but 'type' is not"; + } + } + } + if (!empty($issues)) { + $this->fail(sprintf("Issues found in handle declaration:\n%s\n", implode("\n", $issues))); + } + } + /** * Suppressing PHPMD issues because this test is complex and it is not reasonable to separate it * @@ -195,29 +249,6 @@ public function testContainerDeclaration($file) } } - /** - * @param string $file - * @dataProvider layoutFilesDataProvider - */ - public function testAjaxHandles($file) - { - $issues = array(); - $xml = simplexml_load_file($file); - $handles = $xml->xpath('/layout//*[@parent="ajax_index"]'); - if ($handles) { - foreach ($handles as $handle) { - if (!$handle->xpath('reference[@name="root"]')) { - $issues[] = $handle->getName(); - } - } - } - if (!empty($issues)) { - $this->fail( - sprintf('Hadle(s) "%s" in "%s" must contain reference to root', implode(', ', $issues), $file) - ); - } - } - /** * @return array */ diff --git a/dev/tests/static/testsuite/Legacy/LayoutTest.php b/dev/tests/static/testsuite/Legacy/LayoutTest.php index 9f823e30efbee..b1229a68aa37b 100644 --- a/dev/tests/static/testsuite/Legacy/LayoutTest.php +++ b/dev/tests/static/testsuite/Legacy/LayoutTest.php @@ -107,20 +107,20 @@ public function testLayoutFile($layoutFile) $this->_testObsoleteReferences($layoutXml); $selectorHeadBlock = '(name()="block" or name()="reference") and (@name="head" or @name="convert_root_head")'; - $this->assertEmpty( + $this->assertSame(array(), $layoutXml->xpath( '//*[' . $selectorHeadBlock . ']/action[@method="addItem"]' ), "Mage_Page_Block_Html_Head::addItem is obsolete. $suggestion" ); - $this->assertEmpty( + $this->assertSame(array(), $layoutXml->xpath( '//action[@method="addJs" or @method="addCss"]/parent::*[not(' . $selectorHeadBlock . ')]' ), "Calls addCss/addJs are allowed within the 'head' block only. Verify integrity of the nodes nesting." ); - $this->assertEmpty( - $layoutXml->xpath('/layout/*[@output="toHtml"]'), 'output="toHtml" is obsolete. Use output="1"' + $this->assertSame(array(), + $layoutXml->xpath('/layout//*[@output="toHtml"]'), 'output="toHtml" is obsolete. Use output="1"' ); foreach ($layoutXml as $handle) { $this->assertNotContains($handle->getName(), $this->_obsoleteNodes, 'Layout handle was removed.'); @@ -135,7 +135,8 @@ public function testLayoutFile($layoutFile) . 'there is no solution to get rid of it right now.' ); } - $this->assertEmpty($layoutXml->xpath('/layout//block[@type="Mage_Core_Block_Text_List"]'), + $this->assertSame(array(), + $layoutXml->xpath('/layout//block[@type="Mage_Core_Block_Text_List"]'), 'The class Mage_Core_Block_Text_List is not supposed to be used in layout anymore.' ); } diff --git a/dev/tests/static/testsuite/Legacy/_files/obsolete_classes.php b/dev/tests/static/testsuite/Legacy/_files/obsolete_classes.php index bf351ea4f5c90..a3e66d8f8e45b 100644 --- a/dev/tests/static/testsuite/Legacy/_files/obsolete_classes.php +++ b/dev/tests/static/testsuite/Legacy/_files/obsolete_classes.php @@ -125,6 +125,8 @@ 'Mage_Reports_Model_Resource_Invoiced_Collection', 'Mage_Reports_Model_Resource_Refunded_Collection', 'Mage_Reports_Model_Resource_Shipping_Collection', + 'Mage_Rss_Model_Observer', + 'Mage_Rss_Model_Session' => array('suggestion' => 'Mage_Backend_Model_Auth and Mage_Backend_Model_Auth_Session'), 'Mage_Sales_Block_Order_Details', 'Mage_Sales_Block_Order_Tax', 'Mage_Sales_Model_Entity_Order', diff --git a/dev/tests/static/testsuite/Legacy/_files/obsolete_constants.php b/dev/tests/static/testsuite/Legacy/_files/obsolete_constants.php index 7da27e43f880b..3b5a4f3b58d8c 100644 --- a/dev/tests/static/testsuite/Legacy/_files/obsolete_constants.php +++ b/dev/tests/static/testsuite/Legacy/_files/obsolete_constants.php @@ -46,6 +46,9 @@ 'CONFIG_XML_PATH_DISPLAY_FULL_SUMMARY', 'CONFIG_XML_PATH_DISPLAY_ZERO_TAX', 'EXCEPTION_CODE_IS_GROUPED_PRODUCT', + 'Mage_Rss_Block_Catalog_NotifyStock::CACHE_TAG', + 'Mage_Rss_Block_Catalog_Review::CACHE_TAG', + 'Mage_Rss_Block_Order_New::CACHE_TAG', 'REGISTRY_FORM_PARAMS_KEY' => array('suggestion' => 'direct value'), 'TYPE_TINYINT' => array('suggestion' => 'Varien_Db_Ddl_Table::TYPE_SMALLINT'), 'TYPE_CHAR' => array('suggestion' => 'Varien_Db_Ddl_Table::TYPE_TEXT'), diff --git a/dev/tests/static/testsuite/Legacy/_files/obsolete_methods.php b/dev/tests/static/testsuite/Legacy/_files/obsolete_methods.php index fe703a069c56d..2467d2e265fb7 100644 --- a/dev/tests/static/testsuite/Legacy/_files/obsolete_methods.php +++ b/dev/tests/static/testsuite/Legacy/_files/obsolete_methods.php @@ -141,7 +141,10 @@ 'aggregate' => array('class_scope' => 'Mage_Tag_Model_Resource_Tag'), 'aggregate' => array('class_scope' => 'Mage_Tag_Model_Tag'), 'applyDesign' => array('class_scope' => 'Mage_Catalog_Model_Design'), - 'authAdmin' => array('class_scope' => 'Mage_Adminhtml_Helper_Rss'), + 'authAdmin', + 'authFailed' => array('suggestion' => 'Mage_Core_Helper_Http::failHttpAuthentication()'), + 'authFrontend', + 'authValidate' => array('suggestion' => 'Mage_Core_Helper_Http::getHttpAuthCredentials()'), 'bundlesAction' => array('class_scope' => 'Mage_Adminhtml_Catalog_ProductController'), 'calcTaxAmount' => array('class_scope' => 'Mage_Sales_Model_Quote_Item_Abstract'), 'canPrint' => array('class_scope' => 'Mage_Checkout_Block_Onepage_Success'), diff --git a/dev/tests/static/testsuite/Php/_files/whitelist/core.txt b/dev/tests/static/testsuite/Php/_files/whitelist/core.txt index 29b4bc173f17a..c70ac2913a8a7 100644 --- a/dev/tests/static/testsuite/Php/_files/whitelist/core.txt +++ b/dev/tests/static/testsuite/Php/_files/whitelist/core.txt @@ -1,6 +1,7 @@ app/bootstrap.php app/code/core/Mage/Adminhtml/Model/Observer.php app/code/core/Mage/Core/Block/Abstract.php +app/code/core/Mage/Core/Model/Config/Module.php app/code/core/Mage/Core/Model/Design.php app/code/core/Mage/Core/Model/ShellAbstract.php app/code/core/Mage/Core/Model/Layout.php diff --git a/dev/tests/unit/testsuite/Mage/Core/Helper/HttpTest.php b/dev/tests/unit/testsuite/Mage/Core/Helper/HttpTest.php new file mode 100644 index 0000000000000..60efb7b424b3d --- /dev/null +++ b/dev/tests/unit/testsuite/Mage/Core/Helper/HttpTest.php @@ -0,0 +1,103 @@ +_object = new Mage_Core_Helper_Http; + } + + /** + * @param array $server + * @param string $expectedLogin + * @param string $expectedPass + * @dataProvider getHttpAuthCredentialsDataProvider + */ + public function testGetHttpAuthCredentials($server, $expectedLogin, $expectedPass) + { + $request = $this->getMock('Zend_Controller_Request_Http', array('getServer')); + $request->expects($this->once())->method('getServer')->will($this->returnValue($server)); + $this->assertSame(array($expectedLogin, $expectedPass), $this->_object->getHttpAuthCredentials($request)); + } + + /** + * @return array + */ + public function getHttpAuthCredentialsDataProvider() + { + $login = 'login'; + $password = 'password'; + $header = 'Basic bG9naW46cGFzc3dvcmQ='; + + $anotherLogin = 'another_login'; + $anotherPassword = 'another_password'; + $anotherHeader = 'Basic YW5vdGhlcl9sb2dpbjphbm90aGVyX3Bhc3N3b3Jk'; + + return array( + array(array(), '', ''), + array(array('REDIRECT_HTTP_AUTHORIZATION' => $header), $login, $password), + array(array('HTTP_AUTHORIZATION' => $header), $login, $password), + array(array('Authorization' => $header), $login, $password), + array(array( + 'REDIRECT_HTTP_AUTHORIZATION' => $header, + 'PHP_AUTH_USER' => $anotherLogin, + 'PHP_AUTH_PW' => $anotherPassword + ), $anotherLogin, $anotherPassword + ), + array(array( + 'REDIRECT_HTTP_AUTHORIZATION' => $header, + 'PHP_AUTH_USER' => $anotherLogin, + 'PHP_AUTH_PW' => $anotherPassword + ), $anotherLogin, $anotherPassword + ), + array( + array('REDIRECT_HTTP_AUTHORIZATION' => $header, 'HTTP_AUTHORIZATION' => $anotherHeader,), + $anotherLogin, $anotherPassword + ), + ); + } + + public function testFailHttpAuthentication() + { + $response = new Zend_Controller_Response_Http; + $realm = uniqid(); + $response->headersSentThrowsException = false; + $this->_object->failHttpAuthentication($response, $realm); + $headers = $response->getHeaders(); + $this->assertArrayHasKey(0, $headers); + $this->assertEquals('401 Unauthorized', $headers[0]['value']); + $this->assertArrayHasKey(1, $headers); + $this->assertContains('realm="' . $realm .'"', $headers[1]['value']); + $this->assertContains('401', $response->getBody()); + } +} diff --git a/dev/tests/unit/testsuite/Mage/Core/Model/Config/ModuleTest.php b/dev/tests/unit/testsuite/Mage/Core/Model/Config/ModuleTest.php new file mode 100644 index 0000000000000..2116f3e302a1f --- /dev/null +++ b/dev/tests/unit/testsuite/Mage/Core/Model/Config/ModuleTest.php @@ -0,0 +1,105 @@ +assertXmlStringEqualsXmlFile($expectedConfigFile, $model->getXmlString()); + } + + public function constructorDataProvider() + { + return array( + 'sorting dependencies' => array( + __DIR__ . '/_files/module_input.xml', + __DIR__ . '/_files/module_sorted.xml', + ), + 'disallowed modules' => array( + __DIR__ . '/_files/module_input.xml', + __DIR__ . '/_files/module_filtered.xml', + array('Fixture_ModuleOne', 'Fixture_ModuleTwo'), + ), + ); + } + + /** + * @param string $inputConfigFile + * @param string $expectedException + * @param string $expectedExceptionMsg + * @param array $allowedModules + * @dataProvider constructorExceptionDataProvider + */ + public function testConstructorException( + $inputConfigFile, $expectedException, $expectedExceptionMsg, $allowedModules = array() + ) { + $this->setExpectedException($expectedException, $expectedExceptionMsg); + new Mage_Core_Model_Config_Module(new Mage_Core_Model_Config_Base($inputConfigFile), $allowedModules); + } + + public function constructorExceptionDataProvider() + { + return array( + 'linear dependency' => array( + __DIR__ . '/_files/module_dependency_linear_input.xml', + 'Magento_Exception', + "Module 'Fixture_Module' requires module 'Fixture_NonExistingModule'.", + ), + 'circular dependency' => array( + __DIR__ . '/_files/module_dependency_circular_input.xml', + 'Magento_Exception', + "Module 'Fixture_ModuleTwo' cannot depend on 'Fixture_ModuleOne' since it creates circular dependency.", + ), + 'soft circular dependency' => array( + __DIR__ . '/_files/module_dependency_circular_soft_input.xml', + 'Magento_Exception', + "Module 'Fixture_ModuleTwo' cannot depend on 'Fixture_ModuleOne' since it creates circular dependency.", + ), + 'wrong dependency type' => array( + __DIR__ . '/_files/module_dependency_wrong_input.xml', + 'UnexpectedValueException', + 'Unknown module dependency type \'wrong\' in declaration \'\'.', + ), + 'dependency on disallowed module' => array( + __DIR__ . '/_files/module_input.xml', + 'Magento_Exception', + "Module 'Fixture_ModuleTwo' requires module 'Fixture_ModuleOne'.", + array('Fixture_ModuleTwo') + ) + ); + } +} diff --git a/dev/tests/unit/testsuite/Mage/Core/Model/Config/_files/module_dependency_circular_input.xml b/dev/tests/unit/testsuite/Mage/Core/Model/Config/_files/module_dependency_circular_input.xml new file mode 100644 index 0000000000000..ea5da2469644f --- /dev/null +++ b/dev/tests/unit/testsuite/Mage/Core/Model/Config/_files/module_dependency_circular_input.xml @@ -0,0 +1,43 @@ + + + + + + true + + + + + + true + + + + + + diff --git a/dev/tests/unit/testsuite/Mage/Core/Model/Config/_files/module_dependency_circular_soft_input.xml b/dev/tests/unit/testsuite/Mage/Core/Model/Config/_files/module_dependency_circular_soft_input.xml new file mode 100644 index 0000000000000..1b05c642aaaaf --- /dev/null +++ b/dev/tests/unit/testsuite/Mage/Core/Model/Config/_files/module_dependency_circular_soft_input.xml @@ -0,0 +1,43 @@ + + + + + + true + + + + + + true + + + + + + diff --git a/app/code/core/Mage/Rss/view/frontend/nofeed.phtml b/dev/tests/unit/testsuite/Mage/Core/Model/Config/_files/module_dependency_linear_input.xml similarity index 74% rename from app/code/core/Mage/Rss/view/frontend/nofeed.phtml rename to dev/tests/unit/testsuite/Mage/Core/Model/Config/_files/module_dependency_linear_input.xml index 72d0fa26742a6..9234afbcf46c3 100644 --- a/app/code/core/Mage/Rss/view/frontend/nofeed.phtml +++ b/dev/tests/unit/testsuite/Mage/Core/Model/Config/_files/module_dependency_linear_input.xml @@ -1,4 +1,5 @@ - + + + + + true + + + + + + diff --git a/dev/tests/integration/testsuite/Mage/Paypal/_files/order_express_commit_workaround.php b/dev/tests/unit/testsuite/Mage/Core/Model/Config/_files/module_dependency_wrong_input.xml similarity index 50% rename from dev/tests/integration/testsuite/Mage/Paypal/_files/order_express_commit_workaround.php rename to dev/tests/unit/testsuite/Mage/Core/Model/Config/_files/module_dependency_wrong_input.xml index a343154723e79..f92629f461e3a 100644 --- a/dev/tests/integration/testsuite/Mage/Paypal/_files/order_express_commit_workaround.php +++ b/dev/tests/unit/testsuite/Mage/Core/Model/Config/_files/module_dependency_wrong_input.xml @@ -1,13 +1,14 @@ - + + + + + true + + + + + + true + + + diff --git a/dev/tests/unit/testsuite/Mage/Core/Model/Config/_files/module_filtered.xml b/dev/tests/unit/testsuite/Mage/Core/Model/Config/_files/module_filtered.xml new file mode 100644 index 0000000000000..32aa016ccd344 --- /dev/null +++ b/dev/tests/unit/testsuite/Mage/Core/Model/Config/_files/module_filtered.xml @@ -0,0 +1,44 @@ + + + + + + true + + + + + + true + + + + + + + diff --git a/dev/tests/unit/testsuite/Mage/Core/Model/Config/_files/module_input.xml b/dev/tests/unit/testsuite/Mage/Core/Model/Config/_files/module_input.xml new file mode 100644 index 0000000000000..d70e40bd57e63 --- /dev/null +++ b/dev/tests/unit/testsuite/Mage/Core/Model/Config/_files/module_input.xml @@ -0,0 +1,53 @@ + + + + + + true + + + + + + true + + + + + + + true + + + + + + false + + + diff --git a/dev/tests/unit/testsuite/Mage/Core/Model/Config/_files/module_sorted.xml b/dev/tests/unit/testsuite/Mage/Core/Model/Config/_files/module_sorted.xml new file mode 100644 index 0000000000000..c80e58012dda8 --- /dev/null +++ b/dev/tests/unit/testsuite/Mage/Core/Model/Config/_files/module_sorted.xml @@ -0,0 +1,50 @@ + + + + + + true + + + + + + true + + + + + + + true + + + + + +