Commit 826861f9 authored by Ivan Chepurnyi's avatar Ivan Chepurnyi

! Added more compatibility for 1.6+ CE and PHPUnit 3.6+

parent 73b3fbff
...@@ -22,19 +22,6 @@ ...@@ -22,19 +22,6 @@
*/ */
class EcomDev_PHPUnit_Controller_Front extends Mage_Core_Controller_Varien_Front class EcomDev_PHPUnit_Controller_Front extends Mage_Core_Controller_Varien_Front
{ {
/**
* Overriden for getting rid of unusual behavior in the test case,
* because test should be isolated
*
* (non-PHPdoc)
* @see Mage_Core_Controller_Varien_Front::_checkBaseUrl()
*/
protected function _checkBaseUrl()
{
// Does nothing
}
/** /**
* Overriden for getting rid * Overriden for getting rid
* of initialization of routers for each test case * of initialization of routers for each test case
......
...@@ -337,8 +337,12 @@ class EcomDev_PHPUnit_Controller_Request_Http ...@@ -337,8 +337,12 @@ class EcomDev_PHPUnit_Controller_Request_Http
public function getHttpHost($trimPort = false) public function getHttpHost($trimPort = false)
{ {
$baseUrl = $this->getBaseUrl(); $baseUrl = $this->getBaseUrl();
$parts = parse_url($baseUrl); $parts = parse_url($baseUrl);
if (!isset($parts['host'])) {
new RuntimeException('Cannot run controller test, because the host is not set for base url.');
}
$httpHost = $parts['host']; $httpHost = $parts['host'];
if (!$trimPort && isset($parts['port'])) { if (!$trimPort && isset($parts['port'])) {
$httpHost .= ':' . $parts['port']; $httpHost .= ':' . $parts['port'];
......
...@@ -173,6 +173,7 @@ class EcomDev_PHPUnit_Model_App extends Mage_Core_Model_App ...@@ -173,6 +173,7 @@ class EcomDev_PHPUnit_Model_App extends Mage_Core_Model_App
} }
} }
Mage::setIsDeveloperMode(true);
$this->_config = Mage::getConfig(); $this->_config = Mage::getConfig();
$this->_initBaseConfig(); $this->_initBaseConfig();
$this->_initCache(); $this->_initCache();
......
...@@ -278,12 +278,14 @@ class EcomDev_PHPUnit_Model_Layout ...@@ -278,12 +278,14 @@ class EcomDev_PHPUnit_Model_Layout
/** /**
* Records action call * Records action call
*
* (non-PHPdoc) * (non-PHPdoc)
* @see Mage_Core_Model_Layout::_generateAction() * @see Mage_Core_Model_Layout::_generateAction()
*/ */
protected function _generateAction($node, $parent) protected function _generateAction($node, $parent)
{ {
$this->_collectedArgs = null; $this->_collectedArgs = $this->_collectActionArguments($node);
$this->_translateLayoutNode($node, $this->_collectedArgs);
parent::_generateAction($node, $parent); parent::_generateAction($node, $parent);
if ($this->_collectedArgs !== null) { if ($this->_collectedArgs !== null) {
$method = (string)$node['method']; $method = (string)$node['method'];
...@@ -299,17 +301,51 @@ class EcomDev_PHPUnit_Model_Layout ...@@ -299,17 +301,51 @@ class EcomDev_PHPUnit_Model_Layout
return $this; return $this;
} }
/** /**
* Collects arguments if was not collected before * Collects action arguments
* (non-PHPdoc) *
* @see Mage_Core_Model_Layout::_translateLayoutNode() * @param Varien_SimpleXml_Element $node
* @return array
*/ */
protected function _translateLayoutNode($node, $args) protected function _collectActionArguments($node)
{ {
parent::_translateLayoutNode($node, $args); $args = (array)$node->children();
if ($this->_collectedArgs === null) { unset($args['@attributes']);
$this->_collectedArgs = $args;
foreach ($args as $key => $arg) {
if (($arg instanceof Mage_Core_Model_Layout_Element)) {
if (isset($arg['helper'])) {
$helperName = explode('/', (string)$arg['helper']);
$helperMethod = array_pop($helperName);
$helperName = implode('/', $helperName);
$arg = $arg->asArray();
unset($arg['@']);
$args[$key] = call_user_func_array(array(Mage::helper($helperName), $helperMethod), $arg);
} else {
/**
* if there is no helper we hope that this is assoc array
*/
$arr = array();
foreach($arg as $subkey => $value) {
$arr[(string)$subkey] = $value->asArray();
} }
if (!empty($arr)) {
$args[$key] = $arr;
}
}
}
}
if (isset($node['json'])) {
$json = explode(' ', (string)$node['json']);
foreach ($json as $arg) {
$args[$arg] = Mage::helper('core')->jsonDecode($args[$arg]);
}
}
return $args;
} }
/** /**
......
...@@ -356,8 +356,8 @@ abstract class EcomDev_PHPUnit_Test_Case extends PHPUnit_Framework_TestCase ...@@ -356,8 +356,8 @@ abstract class EcomDev_PHPUnit_Test_Case extends PHPUnit_Framework_TestCase
); );
} }
// Remove addition of /data suffix if version is more than 1.6.x
if ($type == 'helper' && strpos($classAlias, '/') === false) { if (version_compare(Mage::getVersion(), '1.6.0.0', '<') && $type == 'helper' && strpos($classAlias, '/') === false) {
$classAlias .= '/data'; $classAlias .= '/data';
} }
......
...@@ -20,6 +20,9 @@ ...@@ -20,6 +20,9 @@
<unsecure> <unsecure>
<base_url>[change me]</base_url> <base_url>[change me]</base_url>
</unsecure> </unsecure>
<url>
<redirect_to_base>0</redirect_to_base>
</url>
</web> </web>
</default> </default>
</config> </config>
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment