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 b0fd8e25 authored by Ivan Chepurnyi's avatar Ivan Chepurnyi

! Compatibility and strict issues fixed for extension

parent be294b5a
...@@ -64,6 +64,18 @@ class EcomDev_PHPUnit_Model_Config extends Mage_Core_Model_Config ...@@ -64,6 +64,18 @@ class EcomDev_PHPUnit_Model_Config extends Mage_Core_Model_Config
return $this; return $this;
} }
/**
* Get events configuration
*
* @param string $area event area
* @param string $eventName event name
* @return Mage_Core_Model_Config_Element
*/
public function getEventConfig($area, $eventName)
{
return $this->getNode($area)->events->{$eventName};
}
/** /**
* Replaces creation of some instance by mock object * Replaces creation of some instance by mock object
* *
......
...@@ -502,6 +502,18 @@ class EcomDev_PHPUnit_Model_Fixture ...@@ -502,6 +502,18 @@ class EcomDev_PHPUnit_Model_Fixture
} }
Mage::getConfig()->loadDb(); Mage::getConfig()->loadDb();
// Flush website and store configuration caches
foreach (Mage::app()->getWebsites(true) as $website) {
EcomDev_Utils_Reflection::setRestrictedPropertyValue(
$website, '_configCache', array()
);
}
foreach (Mage::app()->getStores(true) as $store) {
EcomDev_Utils_Reflection::setRestrictedPropertyValue(
$store, '_configCache', array()
);
}
return $this; return $this;
} }
...@@ -653,31 +665,7 @@ class EcomDev_PHPUnit_Model_Fixture ...@@ -653,31 +665,7 @@ class EcomDev_PHPUnit_Model_Fixture
*/ */
protected function _setConfigNodeValue($path, $value) protected function _setConfigNodeValue($path, $value)
{ {
$pathArray = explode('/', $path);
$scope = array_shift($pathArray);
switch ($scope) {
case 'stores':
$storeCode = array_shift($pathArray);
Mage::app()->getStore($storeCode)->setConfig(
implode('/', $pathArray), $value
);
break;
case 'websites':
$websiteCode = array_shift($pathArray);
$website = Mage::app()->getWebsite($websiteCode);
EcomDev_Utils_Reflection::setRestrictedPropertyValue(
$website, '_configCache', array()
);
// Should change value
default:
Mage::getConfig()->setNode($path, $value); Mage::getConfig()->setNode($path, $value);
break;
}
return $this; return $this;
} }
......
...@@ -112,9 +112,10 @@ class EcomDev_PHPUnit_Model_Layout ...@@ -112,9 +112,10 @@ class EcomDev_PHPUnit_Model_Layout
$this->_records = array(); $this->_records = array();
foreach ($this->_blocks as $block) { foreach ($this->_blocks as $block) {
/* @var $block Mage_Core_Block_Abstract */
// Remove references between blocks // Remove references between blocks
$block->setParentBlock(null); EcomDev_Utils_Reflection::setRestrictedPropertyValue($block, '_parentBlock', null);
$block->setMessageBlock(null); $block->unsMessageBlock();
$block->unsetChildren(); $block->unsetChildren();
} }
...@@ -285,9 +286,9 @@ class EcomDev_PHPUnit_Model_Layout ...@@ -285,9 +286,9 @@ class EcomDev_PHPUnit_Model_Layout
protected function _generateAction($node, $parent) protected function _generateAction($node, $parent)
{ {
$this->_collectedArgs = $this->_collectActionArguments($node); $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) {
$this->_translateLayoutNode($node, $this->_collectedArgs);
$method = (string)$node['method']; $method = (string)$node['method'];
if (!empty($node['block'])) { if (!empty($node['block'])) {
$parentName = (string)$node['block']; $parentName = (string)$node['block'];
...@@ -307,10 +308,14 @@ class EcomDev_PHPUnit_Model_Layout ...@@ -307,10 +308,14 @@ class EcomDev_PHPUnit_Model_Layout
* Collects action arguments * Collects action arguments
* *
* @param Varien_SimpleXml_Element $node * @param Varien_SimpleXml_Element $node
* @return array * @return array|null
*/ */
protected function _collectActionArguments($node) protected function _collectActionArguments($node)
{ {
if (isset($node['ifconfig']) && !Mage::getStoreConfigFlag((string)$node['ifconfig'])) {
return null;
}
$args = (array)$node->children(); $args = (array)$node->children();
unset($args['@attributes']); unset($args['@attributes']);
......
...@@ -718,7 +718,7 @@ abstract class EcomDev_PHPUnit_Test_Case extends PHPUnit_Framework_TestCase ...@@ -718,7 +718,7 @@ abstract class EcomDev_PHPUnit_Test_Case extends PHPUnit_Framework_TestCase
if (current($annotationValue)) { if (current($annotationValue)) {
$classAlias = current($annotationValue); $classAlias = current($annotationValue);
} else { } else {
$classAlias = self::app()->getConfig()->getNode($configPath); $classAlias = (string) self::app()->getConfig()->getNode($configPath);
} }
return $classAlias; return $classAlias;
......
...@@ -186,7 +186,7 @@ abstract class EcomDev_PHPUnit_Test_Case_Config extends EcomDev_PHPUnit_Test_Cas ...@@ -186,7 +186,7 @@ abstract class EcomDev_PHPUnit_Test_Case_Config extends EcomDev_PHPUnit_Test_Cas
* @param EcomDev_PHPUnit_Constraint_Config $constraint * @param EcomDev_PHPUnit_Constraint_Config $constraint
* @param string $message * @param string $message
*/ */
public static function assertThatConfig(EcomDev_PHPUnit_Constraint_Config $constraint, $message) public static function assertThatConfig(PHPUnit_Framework_Constraint $constraint, $message)
{ {
self::assertThat(Mage::getConfig(), $constraint, $message); self::assertThat(Mage::getConfig(), $constraint, $message);
} }
......
...@@ -80,7 +80,7 @@ abstract class EcomDev_PHPUnit_Test_Case_Controller extends EcomDev_PHPUnit_Test ...@@ -80,7 +80,7 @@ abstract class EcomDev_PHPUnit_Test_Case_Controller extends EcomDev_PHPUnit_Test
* @param string $type * @param string $type
* @return EcomDev_PHPUnit_Constraint_Layout * @return EcomDev_PHPUnit_Constraint_Layout
*/ */
public static function layout($type = EcomDev_PHPUnit_Constraint_Layout::TYPE_LOADED) public static function layout($type)
{ {
return new EcomDev_PHPUnit_Constraint_Layout($type); return new EcomDev_PHPUnit_Constraint_Layout($type);
} }
...@@ -437,10 +437,10 @@ abstract class EcomDev_PHPUnit_Test_Case_Controller extends EcomDev_PHPUnit_Test ...@@ -437,10 +437,10 @@ abstract class EcomDev_PHPUnit_Test_Case_Controller extends EcomDev_PHPUnit_Test
/** /**
* Assert shortcut for response assertions * Assert shortcut for response assertions
* *
* @param EcomDev_PHPUnit_Constraint_Controller_Response_Header $constraint * @param EcomDev_PHPUnit_Constraint_Controller_Response_Abstract $constraint
* @param string $message * @param string $message
*/ */
public static function assertThatResponse(EcomDev_PHPUnit_Constraint_Controller_Response_Header $constraint, $message) public static function assertThatResponse(PHPUnit_Framework_Constraint $constraint, $message)
{ {
self::assertThat(self::getResponse(), $constraint, $message); self::assertThat(self::getResponse(), $constraint, $message);
} }
......
...@@ -58,11 +58,11 @@ class EcomDev_PHPUnit_Constraint_Config extends PHPUnit_Framework_Constraint ...@@ -58,11 +58,11 @@ class EcomDev_PHPUnit_Constraint_Config extends PHPUnit_Framework_Constraint
* @param string $description * @param string $description
* @param boolean $not * @param boolean $not
*/ */
public function fail($other, $description, $not) public function fail($other, $description, PHPUnit_Framework_ComparisonFailure $comparisonFailure = NULL)
{ {
$nodeValue = $this->getNodeValue($other); $nodeValue = $this->getNodeValue($other);
return $this->constraint->fail($nodeValue, $description, $not); return $this->constraint->fail($nodeValue, $description, $comparisonFailure);
} }
/** /**
......
...@@ -120,9 +120,11 @@ class EcomDev_PHPUnit_Constraint_Config_Resource_Script ...@@ -120,9 +120,11 @@ class EcomDev_PHPUnit_Constraint_Config_Resource_Script
} }
// Sort install scripts by version // Sort install scripts by version
usort($result['install'], array($this, 'compareVersions')); usort($result['scheme']['install'], array($this, 'compareVersions'));
usort($result['data']['install'], array($this, 'compareVersions'));
// Sort upgrade scripts by version // Sort upgrade scripts by version
usort($result['upgrade'], array($this, 'compareVersions')); usort($result['scheme']['upgrade'], array($this, 'compareVersions'));
usort($result['data']['upgrade'], array($this, 'compareVersions'));
return $result; return $result;
} }
......
...@@ -59,7 +59,7 @@ class EcomDev_PHPUnit_Constraint_Config_TableAlias ...@@ -59,7 +59,7 @@ class EcomDev_PHPUnit_Constraint_Config_TableAlias
protected function evaluateTableAlias($other) protected function evaluateTableAlias($other)
{ {
if (!isset($other->{$this->_tableAliasPrefix})) { if (!isset($other->{$this->_tableAliasPrefix})) {
$this->setActualValue(false); $this->setActualValue('');
return false; return false;
} }
...@@ -72,7 +72,7 @@ class EcomDev_PHPUnit_Constraint_Config_TableAlias ...@@ -72,7 +72,7 @@ class EcomDev_PHPUnit_Constraint_Config_TableAlias
if (isset($modelNode->entities->{$this->_tableAliasName}->table)) { if (isset($modelNode->entities->{$this->_tableAliasName}->table)) {
$tableName = (string)$modelNode->entities->{$this->_tableAliasName}->table; $tableName = (string)$modelNode->entities->{$this->_tableAliasName}->table;
} else { } else {
$tableName = false; $tableName = '';
} }
$this->setActualValue($tableName); $this->setActualValue($tableName);
......
...@@ -49,7 +49,7 @@ class EcomDev_PHPUnit_Constraint_Controller_Response_Body ...@@ -49,7 +49,7 @@ class EcomDev_PHPUnit_Constraint_Controller_Response_Body
protected function evaluateConstraint($other) protected function evaluateConstraint($other)
{ {
$this->setActualValue($other->getOutputBody()); $this->setActualValue($other->getOutputBody());
return $this->_expectedValue->evaluate($this->_actualValue); return $this->_expectedValue->evaluate($this->_actualValue, '', true);
} }
/** /**
...@@ -59,6 +59,20 @@ class EcomDev_PHPUnit_Constraint_Controller_Response_Body ...@@ -59,6 +59,20 @@ class EcomDev_PHPUnit_Constraint_Controller_Response_Body
*/ */
protected function textConstraint() protected function textConstraint()
{ {
return sprintf('body %s', $this->_expectedValue->toString()); return $this->_expectedValue->toString();
}
/**
* Custom failure description
*
* @param $other
* @return string
*/
protected function customFailureDescription($other)
{
return sprintf(
'request body %s.',
$this->toString()
);
} }
} }
\ No newline at end of file
...@@ -85,7 +85,7 @@ class EcomDev_PHPUnit_Constraint_Controller_Response_Header ...@@ -85,7 +85,7 @@ class EcomDev_PHPUnit_Constraint_Controller_Response_Header
protected function evaluateConstraint($other) protected function evaluateConstraint($other)
{ {
$this->setActualValue($other->getSentHeader($this->_headerName)); $this->setActualValue($other->getSentHeader($this->_headerName));
return $this->_expectedValue->evaluate($this->_actualValue); return $this->_expectedValue->evaluate($this->_actualValue, '', true);
} }
/** /**
......
...@@ -40,7 +40,7 @@ abstract class EcomDev_PHPUnit_Constraint_Layout_Abstract extends EcomDev_PHPUni ...@@ -40,7 +40,7 @@ abstract class EcomDev_PHPUnit_Constraint_Layout_Abstract extends EcomDev_PHPUni
* (non-PHPdoc) * (non-PHPdoc)
* @see EcomDev_PHPUnit_Constraint_Abstract::getActualValue() * @see EcomDev_PHPUnit_Constraint_Abstract::getActualValue()
*/ */
protected function getActualValue($other) protected function getActualValue($other = null)
{ {
if ($this->_useActualValue) { if ($this->_useActualValue) {
return parent::getActualValue($other); return parent::getActualValue($other);
......
...@@ -133,7 +133,7 @@ class EcomDev_PHPUnit_Constraint_Layout_Block extends EcomDev_PHPUnit_Constraint ...@@ -133,7 +133,7 @@ class EcomDev_PHPUnit_Constraint_Layout_Block extends EcomDev_PHPUnit_Constraint
} }
$this->setActualValue($renderInfo['content']); $this->setActualValue($renderInfo['content']);
return $this->_expectedValue->evaluate($renderInfo['content']); return $this->_expectedValue->evaluate($renderInfo['content'], '', true);
} }
/** /**
......
...@@ -150,7 +150,7 @@ class EcomDev_PHPUnit_Constraint_Layout_Block_Action extends EcomDev_PHPUnit_Con ...@@ -150,7 +150,7 @@ class EcomDev_PHPUnit_Constraint_Layout_Block_Action extends EcomDev_PHPUnit_Con
$withArguments = ' with expected arguments'; $withArguments = ' with expected arguments';
} }
return sprintf('block "%s" action for method "%s" was invoked%s', return sprintf('block "%s" action for method "%s" is invoked%s',
$this->_blockName, $this->_method, $withArguments); $this->_blockName, $this->_method, $withArguments);
} }
......
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