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

! Compatibility with PHPUnit 3.6.x

parent f1d93b0c
...@@ -340,7 +340,7 @@ class EcomDev_PHPUnit_Controller_Request_Http ...@@ -340,7 +340,7 @@ class EcomDev_PHPUnit_Controller_Request_Http
$parts = parse_url($baseUrl); $parts = parse_url($baseUrl);
if (!isset($parts['host'])) { if (!isset($parts['host'])) {
new RuntimeException('Cannot run controller test, because the host is not set for base url.'); throw new RuntimeException('Cannot run controller test, because the host is not set for base url.');
} }
$httpHost = $parts['host']; $httpHost = $parts['host'];
......
...@@ -16,7 +16,6 @@ ...@@ -16,7 +16,6 @@
* @author Ivan Chepurnyi <ivan.chepurnyi@ecomdev.org> * @author Ivan Chepurnyi <ivan.chepurnyi@ecomdev.org>
*/ */
/** /**
* Base for controller test case * Base for controller test case
* *
...@@ -81,7 +80,7 @@ abstract class EcomDev_PHPUnit_Test_Case_Controller extends EcomDev_PHPUnit_Test ...@@ -81,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) public static function layout($type = EcomDev_PHPUnit_Constraint_Layout::TYPE_LOADED)
{ {
return new EcomDev_PHPUnit_Constraint_Layout($type); return new EcomDev_PHPUnit_Constraint_Layout($type);
} }
...@@ -1902,20 +1901,29 @@ abstract class EcomDev_PHPUnit_Test_Case_Controller extends EcomDev_PHPUnit_Test ...@@ -1902,20 +1901,29 @@ abstract class EcomDev_PHPUnit_Test_Case_Controller extends EcomDev_PHPUnit_Test
protected function reset() protected function reset()
{ {
$_SESSION = array(); $_SESSION = array();
// Init request for any url that using sessions
$initialUrlParams = array();
$urlModel = $this->getUrlModel(null, $initialUrlParams);
$baseUrl = $urlModel->getBaseUrl($initialUrlParams);
$this->getRequest()->reset(); $this->getRequest()->reset();
$this->getRequest()->setBaseUrl($baseUrl);
$this->getResponse()->reset(); $this->getResponse()->reset();
$this->getLayout()->reset(); $this->getLayout()->reset();
return $this; return $this;
} }
/** /**
* Dispatches controller action * Returns URL model for request
* *
* *
* @param string $route * @param string|null $route
* @param array $params * @param array $params
* @return Mage_Core_Model_Url
*/ */
public function dispatch($route = null, array $params = array()) protected function getUrlModel($route = null, array &$params)
{ {
if (!isset($params['_store'])) { if (!isset($params['_store'])) {
if (strpos($route, EcomDev_PHPUnit_Model_App::AREA_ADMINHTML) !== false) { if (strpos($route, EcomDev_PHPUnit_Model_App::AREA_ADMINHTML) !== false) {
...@@ -1932,6 +1940,20 @@ abstract class EcomDev_PHPUnit_Test_Case_Controller extends EcomDev_PHPUnit_Test ...@@ -1932,6 +1940,20 @@ abstract class EcomDev_PHPUnit_Test_Case_Controller extends EcomDev_PHPUnit_Test
$urlModel = Mage::getModel('adminhtml/url'); $urlModel = Mage::getModel('adminhtml/url');
} }
return $urlModel;
}
/**
* Dispatches controller action
*
*
* @param string $route
* @param array $params
*/
public function dispatch($route = null, array $params = array())
{
$urlModel = $this->getUrlModel($route, $params);
$this->app()->resetAreas(); $this->app()->resetAreas();
$requestUri = $urlModel->getUrl($route, $params); $requestUri = $urlModel->getUrl($route, $params);
......
...@@ -181,9 +181,9 @@ abstract class EcomDev_PHPUnit_Constraint_Abstract ...@@ -181,9 +181,9 @@ abstract class EcomDev_PHPUnit_Constraint_Abstract
* (non-PHPdoc) * (non-PHPdoc)
* @see PHPUnit_Framework_Constraint::fail() * @see PHPUnit_Framework_Constraint::fail()
*/ */
public function fail($other, $description, $not = FALSE) public function fail($other, $description, PHPUnit_Framework_ComparisonFailure $comparisonFailure = NULL)
{ {
$failureDescription = sprintf('Failed asserting that %s', $this->failureDescription($other, $description, $not)); $failureDescription = sprintf('Failed asserting that %s', $this->failureDescription($other));
if (in_array($this->_type, $this->_typesWithDiff)) { if (in_array($this->_type, $this->_typesWithDiff)) {
throw new EcomDev_PHPUnit_Constraint_Exception( throw new EcomDev_PHPUnit_Constraint_Exception(
...@@ -211,13 +211,13 @@ abstract class EcomDev_PHPUnit_Constraint_Abstract ...@@ -211,13 +211,13 @@ abstract class EcomDev_PHPUnit_Constraint_Abstract
* @param boolean $not * @param boolean $not
* @return string * @return string
*/ */
protected function failureDescription($other, $description, $not) protected function failureDescription($other)
{ {
if (method_exists($this, 'customFailureDescription')) { if (method_exists($this, 'customFailureDescription')) {
return $this->customFailureDescription($other, $description, $not); return $this->customFailureDescription($other);
} }
return parent::failureDescription($other, $description, $not); return parent::failureDescription($other);
} }
/** /**
......
...@@ -128,7 +128,7 @@ class EcomDev_PHPUnit_Constraint_Config_ClassAlias ...@@ -128,7 +128,7 @@ class EcomDev_PHPUnit_Constraint_Config_ClassAlias
* (non-PHPdoc) * (non-PHPdoc)
* @see PHPUnit_Framework_Constraint::customFailureDescription() * @see PHPUnit_Framework_Constraint::customFailureDescription()
*/ */
protected function customFailureDescription($other, $description, $not) protected function customFailureDescription($other)
{ {
return sprintf( return sprintf(
'%s "%s/%s" %s.', '%s "%s/%s" %s.',
......
...@@ -166,7 +166,7 @@ class EcomDev_PHPUnit_Constraint_Config_EventObserver ...@@ -166,7 +166,7 @@ class EcomDev_PHPUnit_Constraint_Config_EventObserver
* (non-PHPdoc) * (non-PHPdoc)
* @see PHPUnit_Framework_Constraint::customFailureDescription() * @see PHPUnit_Framework_Constraint::customFailureDescription()
*/ */
protected function customFailureDescription($other, $description, $not) protected function customFailureDescription($other)
{ {
return sprintf( return sprintf(
'%s "%s" event observer %s.', '%s "%s" event observer %s.',
......
...@@ -182,7 +182,7 @@ class EcomDev_PHPUnit_Constraint_Config_Layout ...@@ -182,7 +182,7 @@ class EcomDev_PHPUnit_Constraint_Config_Layout
* (non-PHPdoc) * (non-PHPdoc)
* @see PHPUnit_Framework_Constraint::customFailureDescription() * @see PHPUnit_Framework_Constraint::customFailureDescription()
*/ */
protected function customFailureDescription($other, $description, $not) protected function customFailureDescription($other)
{ {
return sprintf( return sprintf(
'layout %s.', 'layout %s.',
......
...@@ -297,7 +297,7 @@ class EcomDev_PHPUnit_Constraint_Config_Node ...@@ -297,7 +297,7 @@ class EcomDev_PHPUnit_Constraint_Config_Node
* (non-PHPdoc) * (non-PHPdoc)
* @see PHPUnit_Framework_Constraint::customFailureDescription() * @see PHPUnit_Framework_Constraint::customFailureDescription()
*/ */
protected function customFailureDescription($other, $description, $not) protected function customFailureDescription($other)
{ {
return sprintf( return sprintf(
'configuration node "%s" %s.', $this->_nodePath, $this->toString() 'configuration node "%s" %s.', $this->_nodePath, $this->toString()
......
...@@ -225,7 +225,7 @@ class EcomDev_PHPUnit_Constraint_Config_Resource ...@@ -225,7 +225,7 @@ class EcomDev_PHPUnit_Constraint_Config_Resource
* (non-PHPdoc) * (non-PHPdoc)
* @see PHPUnit_Framework_Constraint::customFailureDescription() * @see PHPUnit_Framework_Constraint::customFailureDescription()
*/ */
protected function customFailureDescription($other, $description, $not) protected function customFailureDescription($other)
{ {
return sprintf( return sprintf(
'setup resources %s.', 'setup resources %s.',
......
...@@ -355,7 +355,7 @@ class EcomDev_PHPUnit_Constraint_Config_Resource_Script ...@@ -355,7 +355,7 @@ class EcomDev_PHPUnit_Constraint_Config_Resource_Script
* (non-PHPdoc) * (non-PHPdoc)
* @see PHPUnit_Framework_Constraint::customFailureDescription() * @see PHPUnit_Framework_Constraint::customFailureDescription()
*/ */
protected function customFailureDescription($other, $description, $not) protected function customFailureDescription($other)
{ {
return sprintf( return sprintf(
'setup resources %s.', 'setup resources %s.',
......
...@@ -94,7 +94,7 @@ class EcomDev_PHPUnit_Constraint_Config_TableAlias ...@@ -94,7 +94,7 @@ class EcomDev_PHPUnit_Constraint_Config_TableAlias
* (non-PHPdoc) * (non-PHPdoc)
* @see PHPUnit_Framework_Constraint::customFailureDescription() * @see PHPUnit_Framework_Constraint::customFailureDescription()
*/ */
protected function customFailureDescription($other, $description, $not) protected function customFailureDescription($other)
{ {
return sprintf( return sprintf(
'table alias "%s/%s" %s.', 'table alias "%s/%s" %s.',
......
...@@ -298,7 +298,7 @@ class EcomDev_PHPUnit_Constraint_Controller_Request extends EcomDev_PHPUnit_Cons ...@@ -298,7 +298,7 @@ class EcomDev_PHPUnit_Constraint_Controller_Request extends EcomDev_PHPUnit_Cons
* (non-PHPdoc) * (non-PHPdoc)
* @see PHPUnit_Framework_Constraint::customFailureDescription() * @see PHPUnit_Framework_Constraint::customFailureDescription()
*/ */
protected function customFailureDescription($other, $description, $not) protected function customFailureDescription($other)
{ {
return sprintf( return sprintf(
'request %s.', 'request %s.',
......
...@@ -28,7 +28,7 @@ abstract class EcomDev_PHPUnit_Constraint_Controller_Response_Abstract ...@@ -28,7 +28,7 @@ abstract class EcomDev_PHPUnit_Constraint_Controller_Response_Abstract
* (non-PHPdoc) * (non-PHPdoc)
* @see PHPUnit_Framework_Constraint::customFailureDescription() * @see PHPUnit_Framework_Constraint::customFailureDescription()
*/ */
protected function customFailureDescription($other, $description, $not) protected function customFailureDescription($other)
{ {
return sprintf( return sprintf(
'request %s.', 'request %s.',
......
...@@ -27,7 +27,7 @@ abstract class EcomDev_PHPUnit_Constraint_Layout_Abstract extends EcomDev_PHPUni ...@@ -27,7 +27,7 @@ abstract class EcomDev_PHPUnit_Constraint_Layout_Abstract extends EcomDev_PHPUni
* (non-PHPdoc) * (non-PHPdoc)
* @see PHPUnit_Framework_Constraint::customFailureDescription() * @see PHPUnit_Framework_Constraint::customFailureDescription()
*/ */
protected function customFailureDescription($other, $description, $not) protected function customFailureDescription($other)
{ {
return sprintf( return sprintf(
'layout %s.', 'layout %s.',
......
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