We will work on Apr 26th (Saturday) and will be off from Apr 30th (Wednesday) until May 2nd (Friday) for public holiday in our country

Commit 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 @@
*/
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
* of initialization of routers for each test case
......
......@@ -337,8 +337,12 @@ class EcomDev_PHPUnit_Controller_Request_Http
public function getHttpHost($trimPort = false)
{
$baseUrl = $this->getBaseUrl();
$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'];
if (!$trimPort && isset($parts['port'])) {
$httpHost .= ':' . $parts['port'];
......
......@@ -173,6 +173,7 @@ class EcomDev_PHPUnit_Model_App extends Mage_Core_Model_App
}
}
Mage::setIsDeveloperMode(true);
$this->_config = Mage::getConfig();
$this->_initBaseConfig();
$this->_initCache();
......
......@@ -278,12 +278,14 @@ class EcomDev_PHPUnit_Model_Layout
/**
* Records action call
*
* (non-PHPdoc)
* @see Mage_Core_Model_Layout::_generateAction()
*/
protected function _generateAction($node, $parent)
{
$this->_collectedArgs = null;
$this->_collectedArgs = $this->_collectActionArguments($node);
$this->_translateLayoutNode($node, $this->_collectedArgs);
parent::_generateAction($node, $parent);
if ($this->_collectedArgs !== null) {
$method = (string)$node['method'];
......@@ -299,17 +301,51 @@ class EcomDev_PHPUnit_Model_Layout
return $this;
}
/**
* Collects arguments if was not collected before
* (non-PHPdoc)
* @see Mage_Core_Model_Layout::_translateLayoutNode()
* Collects action arguments
*
* @param Varien_SimpleXml_Element $node
* @return array
*/
protected function _translateLayoutNode($node, $args)
protected function _collectActionArguments($node)
{
parent::_translateLayoutNode($node, $args);
if ($this->_collectedArgs === null) {
$this->_collectedArgs = $args;
$args = (array)$node->children();
unset($args['@attributes']);
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
);
}
if ($type == 'helper' && strpos($classAlias, '/') === false) {
// Remove addition of /data suffix if version is more than 1.6.x
if (version_compare(Mage::getVersion(), '1.6.0.0', '<') && $type == 'helper' && strpos($classAlias, '/') === false) {
$classAlias .= '/data';
}
......
......@@ -19,7 +19,10 @@
</secure>
<unsecure>
<base_url>[change me]</base_url>
</unsecure>
</unsecure>
<url>
<redirect_to_base>0</redirect_to_base>
</url>
</web>
</default>
</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