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

! Add error messages easier clarification via new features of PHPUnit 3.6

parent 37228366
......@@ -29,6 +29,7 @@ class EcomDev_PHPUnit_Controller_Front extends Mage_Core_Controller_Varien_Front
* (non-PHPdoc)
* @see Mage_Core_Controller_Varien_Front::_checkBaseUrl()
*/
protected function _checkBaseUrl()
{
// Does nothing
......
......@@ -66,6 +66,21 @@ abstract class EcomDev_PHPUnit_Test_Case extends PHPUnit_Framework_TestCase
return Mage::app();
}
/**
* Returns a EcomDev_PHPUnit_Constraint_Or matcher object.
*
* @return EcomDev_PHPUnit_Constraint_Or
*/
public static function logicalOr()
{
$constraints = func_get_args();
$constraint = new EcomDev_PHPUnit_Constraint_Or;
$constraint->setConstraints($constraints);
return $constraint;
}
/**
* Asserts that event was dispatched at least once
*
......
......@@ -183,7 +183,7 @@ abstract class EcomDev_PHPUnit_Constraint_Abstract
*/
public function fail($other, $description, $not = FALSE)
{
$failureDescription = $this->failureDescription($other, $description, $not);
$failureDescription = sprintf('Failed asserting that %s', $this->failureDescription($other, $description, $not));
if (in_array($this->_type, $this->_typesWithDiff)) {
throw new EcomDev_PHPUnit_Constraint_Exception(
......
......@@ -123,6 +123,7 @@ class EcomDev_PHPUnit_Constraint_Config extends PHPUnit_Framework_Constraint
*/
protected function failureDescription($other)
{
return $this->constraint->failureDescription($other);
$nodeValue = $this->getNodeValue($other);
return $this->constraint->failureDescription($nodeValue);
}
}
......@@ -131,7 +131,7 @@ class EcomDev_PHPUnit_Constraint_Config_ClassAlias
protected function customFailureDescription($other, $description, $not)
{
return sprintf(
'Failed asserting that %s "%s/%s" %s.',
'%s "%s/%s" %s.',
$this->_textByGroup[$this->_group],
$this->_classAliasPrefix, $this->_classAliasName,
$this->toString()
......
......@@ -169,7 +169,7 @@ class EcomDev_PHPUnit_Constraint_Config_EventObserver
protected function customFailureDescription($other, $description, $not)
{
return sprintf(
'Failed asserting that %s "%s" event observer %s.',
'%s "%s" event observer %s.',
$this->_area,
$this->_expectedValue,
$this->toString()
......
......@@ -185,7 +185,7 @@ class EcomDev_PHPUnit_Constraint_Config_Layout
protected function customFailureDescription($other, $description, $not)
{
return sprintf(
'Failed asserting that layout %s.',
'layout %s.',
$this->toString()
);
}
......
......@@ -222,7 +222,7 @@ class EcomDev_PHPUnit_Constraint_Config_Module
protected function customFailureDescription($other, $description, $not)
{
return sprintf(
'Failed asserting that %s module %s.', $this->_moduleName, $this->toString()
'%s module %s.', $this->_moduleName, $this->toString()
);
}
}
......@@ -300,7 +300,7 @@ class EcomDev_PHPUnit_Constraint_Config_Node
protected function customFailureDescription($other, $description, $not)
{
return sprintf(
'Failed asserting that configuration node "%s" %s.', $this->_nodePath, $this->toString()
'configuration node "%s" %s.', $this->_nodePath, $this->toString()
);
}
}
......@@ -228,7 +228,7 @@ class EcomDev_PHPUnit_Constraint_Config_Resource
protected function customFailureDescription($other, $description, $not)
{
return sprintf(
'Failed asserting that setup resources %s.',
'setup resources %s.',
$this->toString()
);
}
......
......@@ -358,7 +358,7 @@ class EcomDev_PHPUnit_Constraint_Config_Resource_Script
protected function customFailureDescription($other, $description, $not)
{
return sprintf(
'Failed asserting that setup resources %s.',
'setup resources %s.',
$this->toString()
);
}
......
......@@ -97,7 +97,7 @@ class EcomDev_PHPUnit_Constraint_Config_TableAlias
protected function customFailureDescription($other, $description, $not)
{
return sprintf(
'Failed asserting that table alias "%s/%s" %s.',
'table alias "%s/%s" %s.',
$this->_tableAliasPrefix, $this->_tableAliasName,
$this->toString()
);
......
......@@ -301,7 +301,7 @@ class EcomDev_PHPUnit_Constraint_Controller_Request extends EcomDev_PHPUnit_Cons
protected function customFailureDescription($other, $description, $not)
{
return sprintf(
'Failed asserting that request %s.',
'request %s.',
$this->toString()
);
}
......
......@@ -31,7 +31,7 @@ abstract class EcomDev_PHPUnit_Constraint_Controller_Response_Abstract
protected function customFailureDescription($other, $description, $not)
{
return sprintf(
'Failed asserting that request %s.',
'request %s.',
$this->toString()
);
}
......
......@@ -157,7 +157,7 @@ class EcomDev_PHPUnit_Constraint_Json extends EcomDev_PHPUnit_Constraint_Abstrac
protected function customFailureDescription($other, $description, $not)
{
return sprintf(
'Failed asserting that string value %s.',
'string value %s.',
$this->toString()
);
}
......
......@@ -30,7 +30,7 @@ abstract class EcomDev_PHPUnit_Constraint_Layout_Abstract extends EcomDev_PHPUni
protected function customFailureDescription($other, $description, $not)
{
return sprintf(
'Failed asserting that layout %s.',
'layout %s.',
$this->toString()
);
}
......
<?php
/**
* PHP Unit test suite for Magento
*
* NOTICE OF LICENSE
*
* This source file is subject to the Open Software License (OSL 3.0)
* that is bundled with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://opensource.org/licenses/osl-3.0.php
*
* @category EcomDev
* @package EcomDev_PHPUnit
* @copyright Copyright (c) 2012 EcomDev BV (http://www.ecomdev.org)
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
* @author Ivan Chepurnyi <ivan.chepurnyi@ecomdev.org>
*/
/**
* Fix of comparison type for Or constraint
*/
class EcomDev_PHPUnit_Constraint_Or extends PHPUnit_Framework_Constraint_Or
{
protected function failureDescription($other)
{
$text = '';
foreach ($this->constraints as $key => $constraint) {
if ($key > 0) {
$text .= ' or ';
}
$text .= $constraint->failureDescription($other);
}
return $text;
}
}
\ No newline at end of file
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