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
$parts = parse_url($baseUrl);
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'];
......
......@@ -16,7 +16,6 @@
* @author Ivan Chepurnyi <ivan.chepurnyi@ecomdev.org>
*/
/**
* Base for controller test case
*
......@@ -81,7 +80,7 @@ abstract class EcomDev_PHPUnit_Test_Case_Controller extends EcomDev_PHPUnit_Test
* @param string $type
* @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);
}
......@@ -1902,20 +1901,29 @@ abstract class EcomDev_PHPUnit_Test_Case_Controller extends EcomDev_PHPUnit_Test
protected function reset()
{
$_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()->setBaseUrl($baseUrl);
$this->getResponse()->reset();
$this->getLayout()->reset();
return $this;
}
/**
* Dispatches controller action
* Returns URL model for request
*
*
* @param string $route
* @param string|null $route
* @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 (strpos($route, EcomDev_PHPUnit_Model_App::AREA_ADMINHTML) !== false) {
......@@ -1932,6 +1940,20 @@ abstract class EcomDev_PHPUnit_Test_Case_Controller extends EcomDev_PHPUnit_Test
$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();
$requestUri = $urlModel->getUrl($route, $params);
......
......@@ -181,9 +181,9 @@ abstract class EcomDev_PHPUnit_Constraint_Abstract
* (non-PHPdoc)
* @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)) {
throw new EcomDev_PHPUnit_Constraint_Exception(
......@@ -211,13 +211,13 @@ abstract class EcomDev_PHPUnit_Constraint_Abstract
* @param boolean $not
* @return string
*/
protected function failureDescription($other, $description, $not)
protected function failureDescription($other)
{
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
* (non-PHPdoc)
* @see PHPUnit_Framework_Constraint::customFailureDescription()
*/
protected function customFailureDescription($other, $description, $not)
protected function customFailureDescription($other)
{
return sprintf(
'%s "%s/%s" %s.',
......
......@@ -166,7 +166,7 @@ class EcomDev_PHPUnit_Constraint_Config_EventObserver
* (non-PHPdoc)
* @see PHPUnit_Framework_Constraint::customFailureDescription()
*/
protected function customFailureDescription($other, $description, $not)
protected function customFailureDescription($other)
{
return sprintf(
'%s "%s" event observer %s.',
......
......@@ -182,7 +182,7 @@ class EcomDev_PHPUnit_Constraint_Config_Layout
* (non-PHPdoc)
* @see PHPUnit_Framework_Constraint::customFailureDescription()
*/
protected function customFailureDescription($other, $description, $not)
protected function customFailureDescription($other)
{
return sprintf(
'layout %s.',
......
......@@ -297,7 +297,7 @@ class EcomDev_PHPUnit_Constraint_Config_Node
* (non-PHPdoc)
* @see PHPUnit_Framework_Constraint::customFailureDescription()
*/
protected function customFailureDescription($other, $description, $not)
protected function customFailureDescription($other)
{
return sprintf(
'configuration node "%s" %s.', $this->_nodePath, $this->toString()
......
......@@ -225,7 +225,7 @@ class EcomDev_PHPUnit_Constraint_Config_Resource
* (non-PHPdoc)
* @see PHPUnit_Framework_Constraint::customFailureDescription()
*/
protected function customFailureDescription($other, $description, $not)
protected function customFailureDescription($other)
{
return sprintf(
'setup resources %s.',
......
......@@ -355,7 +355,7 @@ class EcomDev_PHPUnit_Constraint_Config_Resource_Script
* (non-PHPdoc)
* @see PHPUnit_Framework_Constraint::customFailureDescription()
*/
protected function customFailureDescription($other, $description, $not)
protected function customFailureDescription($other)
{
return sprintf(
'setup resources %s.',
......
......@@ -94,7 +94,7 @@ class EcomDev_PHPUnit_Constraint_Config_TableAlias
* (non-PHPdoc)
* @see PHPUnit_Framework_Constraint::customFailureDescription()
*/
protected function customFailureDescription($other, $description, $not)
protected function customFailureDescription($other)
{
return sprintf(
'table alias "%s/%s" %s.',
......
......@@ -298,7 +298,7 @@ class EcomDev_PHPUnit_Constraint_Controller_Request extends EcomDev_PHPUnit_Cons
* (non-PHPdoc)
* @see PHPUnit_Framework_Constraint::customFailureDescription()
*/
protected function customFailureDescription($other, $description, $not)
protected function customFailureDescription($other)
{
return sprintf(
'request %s.',
......
......@@ -28,7 +28,7 @@ abstract class EcomDev_PHPUnit_Constraint_Controller_Response_Abstract
* (non-PHPdoc)
* @see PHPUnit_Framework_Constraint::customFailureDescription()
*/
protected function customFailureDescription($other, $description, $not)
protected function customFailureDescription($other)
{
return sprintf(
'request %s.',
......
......@@ -27,7 +27,7 @@ abstract class EcomDev_PHPUnit_Constraint_Layout_Abstract extends EcomDev_PHPUni
* (non-PHPdoc)
* @see PHPUnit_Framework_Constraint::customFailureDescription()
*/
protected function customFailureDescription($other, $description, $not)
protected function customFailureDescription($other)
{
return sprintf(
'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