import v1.1.0_RC2 | 2009-09-20

This commit is contained in:
2019-07-17 22:19:00 +02:00
parent 3b7ba80568
commit 38c146901c
2504 changed files with 101817 additions and 62316 deletions

View File

@ -1,4 +1,23 @@
<?php
/**
* Zend Framework
*
* LICENSE
*
* This source file is subject to the new BSD license that is bundled
* with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://framework.zend.com/license/new-bsd
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@zend.com so we can send you a copy immediately.
*
* @category Zend
* @package Zend_Test
* @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id: ControllerTestCase.php 16874 2009-07-20 12:46:00Z mikaelkael $
*/
/** PHPUnit_Framework_TestCase */
require_once 'PHPUnit/Framework/TestCase.php';
@ -23,12 +42,12 @@ require_once 'Zend/Registry.php';
/**
* Functional testing scaffold for MVC applications
*
*
* @uses PHPUnit_Framework_TestCase
* @package Zend_Test
* @subpackage PHPUnit
* @copyright Copyright (C) 2008 - Present, Zend Technologies, Inc.
* @license New BSD {@link http://framework.zend.com/license/new-bsd}
* @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
abstract class Zend_Test_PHPUnit_ControllerTestCase extends PHPUnit_Framework_TestCase
{
@ -51,7 +70,7 @@ abstract class Zend_Test_PHPUnit_ControllerTestCase extends PHPUnit_Framework_Te
* @var Zend_Controller_Request_Abstract
*/
protected $_request;
/**
* @var Zend_Controller_Response_Abstract
*/
@ -59,9 +78,9 @@ abstract class Zend_Test_PHPUnit_ControllerTestCase extends PHPUnit_Framework_Te
/**
* Overloading: prevent overloading to special properties
*
* @param string $name
* @param mixed $value
*
* @param string $name
* @param mixed $value
* @return void
*/
public function __set($name, $value)
@ -77,8 +96,8 @@ abstract class Zend_Test_PHPUnit_ControllerTestCase extends PHPUnit_Framework_Te
* Overloading for common properties
*
* Provides overloading for request, response, and frontController objects.
*
* @param mixed $name
*
* @param mixed $name
* @return void
*/
public function __get($name)
@ -99,7 +118,7 @@ abstract class Zend_Test_PHPUnit_ControllerTestCase extends PHPUnit_Framework_Te
* Set up MVC app
*
* Calls {@link bootstrap()} by default
*
*
* @return void
*/
protected function setUp()
@ -112,10 +131,10 @@ abstract class Zend_Test_PHPUnit_ControllerTestCase extends PHPUnit_Framework_Te
*
* Resets the front controller, and then bootstraps it.
*
* If {@link $bootstrap} is a callback, executes it; if it is a file, it include's
* it. When done, sets the test case request and response objects into the
* If {@link $bootstrap} is a callback, executes it; if it is a file, it include's
* it. When done, sets the test case request and response objects into the
* front controller.
*
*
* @return void
*/
final public function bootstrap()
@ -139,12 +158,12 @@ abstract class Zend_Test_PHPUnit_ControllerTestCase extends PHPUnit_Framework_Te
/**
* Dispatch the MVC
*
* If a URL is provided, sets it as the request URI in the request object.
* Then sets test case request and response objects in front controller,
* If a URL is provided, sets it as the request URI in the request object.
* Then sets test case request and response objects in front controller,
* disables throwing exceptions, and disables returning the response.
* Finally, dispatches the front controller.
*
* @param string|null $url
*
* @param string|null $url
* @return void
*/
public function dispatch($url = null)
@ -173,8 +192,8 @@ abstract class Zend_Test_PHPUnit_ControllerTestCase extends PHPUnit_Framework_Te
/**
* Reset MVC state
*
* Creates new request/response objects, resets the front controller
*
* Creates new request/response objects, resets the front controller
* instance, and resets the action helper broker.
*
* @todo Need to update Zend_Layout to add a resetInstance() method
@ -196,7 +215,7 @@ abstract class Zend_Test_PHPUnit_ControllerTestCase extends PHPUnit_Framework_Te
/**
* Rest all view placeholders
*
*
* @return void
*/
protected function _resetPlaceholders()
@ -218,7 +237,7 @@ abstract class Zend_Test_PHPUnit_ControllerTestCase extends PHPUnit_Framework_Te
* Reset the request object
*
* Useful for test cases that need to test multiple trips to the server.
*
*
* @return Zend_Test_PHPUnit_ControllerTestCase
*/
public function resetRequest()
@ -231,7 +250,7 @@ abstract class Zend_Test_PHPUnit_ControllerTestCase extends PHPUnit_Framework_Te
* Reset the response object
*
* Useful for test cases that need to test multiple trips to the server.
*
*
* @return Zend_Test_PHPUnit_ControllerTestCase
*/
public function resetResponse()
@ -243,7 +262,7 @@ abstract class Zend_Test_PHPUnit_ControllerTestCase extends PHPUnit_Framework_Te
/**
* Assert against DOM selection
*
*
* @param string $path CSS selector path
* @param string $message
* @return void
@ -261,7 +280,7 @@ abstract class Zend_Test_PHPUnit_ControllerTestCase extends PHPUnit_Framework_Te
/**
* Assert against DOM selection
*
*
* @param string $path CSS selector path
* @param string $message
* @return void
@ -279,7 +298,7 @@ abstract class Zend_Test_PHPUnit_ControllerTestCase extends PHPUnit_Framework_Te
/**
* Assert against DOM selection; node should contain content
*
*
* @param string $path CSS selector path
* @param string $match content that should be contained in matched nodes
* @param string $message
@ -298,7 +317,7 @@ abstract class Zend_Test_PHPUnit_ControllerTestCase extends PHPUnit_Framework_Te
/**
* Assert against DOM selection; node should NOT contain content
*
*
* @param string $path CSS selector path
* @param string $match content that should NOT be contained in matched nodes
* @param string $message
@ -317,7 +336,7 @@ abstract class Zend_Test_PHPUnit_ControllerTestCase extends PHPUnit_Framework_Te
/**
* Assert against DOM selection; node should match content
*
*
* @param string $path CSS selector path
* @param string $pattern Pattern that should be contained in matched nodes
* @param string $message
@ -336,7 +355,7 @@ abstract class Zend_Test_PHPUnit_ControllerTestCase extends PHPUnit_Framework_Te
/**
* Assert against DOM selection; node should NOT match content
*
*
* @param string $path CSS selector path
* @param string $pattern pattern that should NOT be contained in matched nodes
* @param string $message
@ -355,7 +374,7 @@ abstract class Zend_Test_PHPUnit_ControllerTestCase extends PHPUnit_Framework_Te
/**
* Assert against DOM selection; should contain exact number of nodes
*
*
* @param string $path CSS selector path
* @param string $count Number of nodes that should match
* @param string $message
@ -374,7 +393,7 @@ abstract class Zend_Test_PHPUnit_ControllerTestCase extends PHPUnit_Framework_Te
/**
* Assert against DOM selection; should NOT contain exact number of nodes
*
*
* @param string $path CSS selector path
* @param string $count Number of nodes that should NOT match
* @param string $message
@ -393,7 +412,7 @@ abstract class Zend_Test_PHPUnit_ControllerTestCase extends PHPUnit_Framework_Te
/**
* Assert against DOM selection; should contain at least this number of nodes
*
*
* @param string $path CSS selector path
* @param string $count Minimum number of nodes that should match
* @param string $message
@ -412,7 +431,7 @@ abstract class Zend_Test_PHPUnit_ControllerTestCase extends PHPUnit_Framework_Te
/**
* Assert against DOM selection; should contain no more than this number of nodes
*
*
* @param string $path CSS selector path
* @param string $count Maximum number of nodes that should match
* @param string $message
@ -431,7 +450,7 @@ abstract class Zend_Test_PHPUnit_ControllerTestCase extends PHPUnit_Framework_Te
/**
* Assert against XPath selection
*
*
* @param string $path XPath path
* @param string $message
* @return void
@ -449,7 +468,7 @@ abstract class Zend_Test_PHPUnit_ControllerTestCase extends PHPUnit_Framework_Te
/**
* Assert against XPath selection
*
*
* @param string $path XPath path
* @param string $message
* @return void
@ -467,7 +486,7 @@ abstract class Zend_Test_PHPUnit_ControllerTestCase extends PHPUnit_Framework_Te
/**
* Assert against XPath selection; node should contain content
*
*
* @param string $path XPath path
* @param string $match content that should be contained in matched nodes
* @param string $message
@ -486,7 +505,7 @@ abstract class Zend_Test_PHPUnit_ControllerTestCase extends PHPUnit_Framework_Te
/**
* Assert against XPath selection; node should NOT contain content
*
*
* @param string $path XPath path
* @param string $match content that should NOT be contained in matched nodes
* @param string $message
@ -505,7 +524,7 @@ abstract class Zend_Test_PHPUnit_ControllerTestCase extends PHPUnit_Framework_Te
/**
* Assert against XPath selection; node should match content
*
*
* @param string $path XPath path
* @param string $pattern Pattern that should be contained in matched nodes
* @param string $message
@ -524,7 +543,7 @@ abstract class Zend_Test_PHPUnit_ControllerTestCase extends PHPUnit_Framework_Te
/**
* Assert against XPath selection; node should NOT match content
*
*
* @param string $path XPath path
* @param string $pattern pattern that should NOT be contained in matched nodes
* @param string $message
@ -543,7 +562,7 @@ abstract class Zend_Test_PHPUnit_ControllerTestCase extends PHPUnit_Framework_Te
/**
* Assert against XPath selection; should contain exact number of nodes
*
*
* @param string $path XPath path
* @param string $count Number of nodes that should match
* @param string $message
@ -562,7 +581,7 @@ abstract class Zend_Test_PHPUnit_ControllerTestCase extends PHPUnit_Framework_Te
/**
* Assert against XPath selection; should NOT contain exact number of nodes
*
*
* @param string $path XPath path
* @param string $count Number of nodes that should NOT match
* @param string $message
@ -581,7 +600,7 @@ abstract class Zend_Test_PHPUnit_ControllerTestCase extends PHPUnit_Framework_Te
/**
* Assert against XPath selection; should contain at least this number of nodes
*
*
* @param string $path XPath path
* @param string $count Minimum number of nodes that should match
* @param string $message
@ -600,7 +619,7 @@ abstract class Zend_Test_PHPUnit_ControllerTestCase extends PHPUnit_Framework_Te
/**
* Assert against XPath selection; should contain no more than this number of nodes
*
*
* @param string $path XPath path
* @param string $count Maximum number of nodes that should match
* @param string $message
@ -619,8 +638,8 @@ abstract class Zend_Test_PHPUnit_ControllerTestCase extends PHPUnit_Framework_Te
/**
* Assert that response is a redirect
*
* @param string $message
*
* @param string $message
* @return void
*/
public function assertRedirect($message = '')
@ -636,8 +655,8 @@ abstract class Zend_Test_PHPUnit_ControllerTestCase extends PHPUnit_Framework_Te
/**
* Assert that response is NOT a redirect
*
* @param string $message
*
* @param string $message
* @return void
*/
public function assertNotRedirect($message = '')
@ -653,9 +672,9 @@ abstract class Zend_Test_PHPUnit_ControllerTestCase extends PHPUnit_Framework_Te
/**
* Assert that response redirects to given URL
*
* @param string $url
* @param string $message
*
* @param string $url
* @param string $message
* @return void
*/
public function assertRedirectTo($url, $message = '')
@ -671,9 +690,9 @@ abstract class Zend_Test_PHPUnit_ControllerTestCase extends PHPUnit_Framework_Te
/**
* Assert that response does not redirect to given URL
*
* @param string $url
* @param string $message
*
* @param string $url
* @param string $message
* @return void
*/
public function assertNotRedirectTo($url, $message = '')
@ -689,9 +708,9 @@ abstract class Zend_Test_PHPUnit_ControllerTestCase extends PHPUnit_Framework_Te
/**
* Assert that redirect location matches pattern
*
* @param string $pattern
* @param string $message
*
* @param string $pattern
* @param string $message
* @return void
*/
public function assertRedirectRegex($pattern, $message = '')
@ -707,9 +726,9 @@ abstract class Zend_Test_PHPUnit_ControllerTestCase extends PHPUnit_Framework_Te
/**
* Assert that redirect location does not match pattern
*
* @param string $pattern
* @param string $message
*
* @param string $pattern
* @param string $message
* @return void
*/
public function assertNotRedirectRegex($pattern, $message = '')
@ -725,9 +744,9 @@ abstract class Zend_Test_PHPUnit_ControllerTestCase extends PHPUnit_Framework_Te
/**
* Assert response code
*
* @param int $code
* @param string $message
*
* @param int $code
* @param string $message
* @return void
*/
public function assertResponseCode($code, $message = '')
@ -743,9 +762,9 @@ abstract class Zend_Test_PHPUnit_ControllerTestCase extends PHPUnit_Framework_Te
/**
* Assert response code
*
* @param int $code
* @param string $message
*
* @param int $code
* @param string $message
* @return void
*/
public function assertNotResponseCode($code, $message = '')
@ -762,9 +781,9 @@ abstract class Zend_Test_PHPUnit_ControllerTestCase extends PHPUnit_Framework_Te
/**
* Assert response header exists
*
* @param string $header
* @param string $message
*
* @param string $header
* @param string $message
* @return void
*/
public function assertHeader($header, $message = '')
@ -780,9 +799,9 @@ abstract class Zend_Test_PHPUnit_ControllerTestCase extends PHPUnit_Framework_Te
/**
* Assert response header does not exist
*
* @param string $header
* @param string $message
*
* @param string $header
* @param string $message
* @return void
*/
public function assertNotHeader($header, $message = '')
@ -799,10 +818,10 @@ abstract class Zend_Test_PHPUnit_ControllerTestCase extends PHPUnit_Framework_Te
/**
* Assert response header exists and contains the given string
*
* @param string $header
* @param string $match
* @param string $message
*
* @param string $header
* @param string $match
* @param string $message
* @return void
*/
public function assertHeaderContains($header, $match, $message = '')
@ -818,10 +837,10 @@ abstract class Zend_Test_PHPUnit_ControllerTestCase extends PHPUnit_Framework_Te
/**
* Assert response header does not exist and/or does not contain the given string
*
* @param string $header
*
* @param string $header
* @param string $match
* @param string $message
* @param string $message
* @return void
*/
public function assertNotHeaderContains($header, $match, $message = '')
@ -838,10 +857,10 @@ abstract class Zend_Test_PHPUnit_ControllerTestCase extends PHPUnit_Framework_Te
/**
* Assert response header exists and matches the given pattern
*
* @param string $header
* @param string $pattern
* @param string $message
*
* @param string $header
* @param string $pattern
* @param string $message
* @return void
*/
public function assertHeaderRegex($header, $pattern, $message = '')
@ -857,10 +876,10 @@ abstract class Zend_Test_PHPUnit_ControllerTestCase extends PHPUnit_Framework_Te
/**
* Assert response header does not exist and/or does not match the given regex
*
* @param string $header
*
* @param string $header
* @param string $pattern
* @param string $message
* @param string $message
* @return void
*/
public function assertNotHeaderRegex($header, $pattern, $message = '')
@ -877,9 +896,9 @@ abstract class Zend_Test_PHPUnit_ControllerTestCase extends PHPUnit_Framework_Te
/**
* Assert that the last handled request used the given module
*
* @param string $module
* @param string $message
*
* @param string $module
* @param string $message
* @return void
*/
public function assertModule($module, $message = '')
@ -896,9 +915,9 @@ abstract class Zend_Test_PHPUnit_ControllerTestCase extends PHPUnit_Framework_Te
/**
* Assert that the last handled request did NOT use the given module
*
* @param string $module
* @param string $message
*
* @param string $module
* @param string $message
* @return void
*/
public function assertNotModule($module, $message = '')
@ -915,9 +934,9 @@ abstract class Zend_Test_PHPUnit_ControllerTestCase extends PHPUnit_Framework_Te
/**
* Assert that the last handled request used the given controller
*
* @param string $controller
* @param string $message
*
* @param string $controller
* @param string $message
* @return void
*/
public function assertController($controller, $message = '')
@ -934,9 +953,9 @@ abstract class Zend_Test_PHPUnit_ControllerTestCase extends PHPUnit_Framework_Te
/**
* Assert that the last handled request did NOT use the given controller
*
* @param string $controller
* @param string $message
*
* @param string $controller
* @param string $message
* @return void
*/
public function assertNotController($controller, $message = '')
@ -953,9 +972,9 @@ abstract class Zend_Test_PHPUnit_ControllerTestCase extends PHPUnit_Framework_Te
/**
* Assert that the last handled request used the given action
*
* @param string $action
* @param string $message
*
* @param string $action
* @param string $message
* @return void
*/
public function assertAction($action, $message = '')
@ -972,9 +991,9 @@ abstract class Zend_Test_PHPUnit_ControllerTestCase extends PHPUnit_Framework_Te
/**
* Assert that the last handled request did NOT use the given action
*
* @param string $action
* @param string $message
*
* @param string $action
* @param string $message
* @return void
*/
public function assertNotAction($action, $message = '')
@ -991,9 +1010,9 @@ abstract class Zend_Test_PHPUnit_ControllerTestCase extends PHPUnit_Framework_Te
/**
* Assert that the specified route was used
*
* @param string $route
* @param string $message
*
* @param string $route
* @param string $message
* @return void
*/
public function assertRoute($route, $message = '')
@ -1011,9 +1030,9 @@ abstract class Zend_Test_PHPUnit_ControllerTestCase extends PHPUnit_Framework_Te
/**
* Assert that the route matched is NOT as specified
*
* @param string $route
* @param string $message
*
* @param string $route
* @param string $message
* @return void
*/
public function assertNotRoute($route, $message = '')
@ -1031,7 +1050,7 @@ abstract class Zend_Test_PHPUnit_ControllerTestCase extends PHPUnit_Framework_Te
/**
* Retrieve front controller instance
*
*
* @return Zend_Controller_Front
*/
public function getFrontController()
@ -1044,7 +1063,7 @@ abstract class Zend_Test_PHPUnit_ControllerTestCase extends PHPUnit_Framework_Te
/**
* Retrieve test case request object
*
*
* @return Zend_Controller_Request_Abstract
*/
public function getRequest()
@ -1057,8 +1076,8 @@ abstract class Zend_Test_PHPUnit_ControllerTestCase extends PHPUnit_Framework_Te
}
/**
* Retrieve test case response object
*
* Retrieve test case response object
*
* @return Zend_Controller_Response_Abstract
*/
public function getResponse()
@ -1072,7 +1091,7 @@ abstract class Zend_Test_PHPUnit_ControllerTestCase extends PHPUnit_Framework_Te
/**
* Retrieve DOM query object
*
*
* @return Zend_Dom_Query
*/
public function getQuery()
@ -1086,14 +1105,14 @@ abstract class Zend_Test_PHPUnit_ControllerTestCase extends PHPUnit_Framework_Te
/**
* Increment assertion count
*
*
* @return void
*/
protected function _incrementAssertionCount()
{
$stack = debug_backtrace();
foreach (debug_backtrace() as $step) {
if (isset($step['object'])
if (isset($step['object'])
&& $step['object'] instanceof PHPUnit_Framework_TestCase
) {
if (version_compare(PHPUnit_Runner_Version::id(), '3.3.3', 'lt')) {