1
|
|
|
<?php |
2
|
|
|
namespace Agavi\Testing; |
3
|
|
|
|
4
|
|
|
// +---------------------------------------------------------------------------+ |
5
|
|
|
// | This file is part of the Agavi package. | |
6
|
|
|
// | Copyright (c) 2005-2010 the Agavi Project. | |
7
|
|
|
// | | |
8
|
|
|
// | For the full copyright and license information, please view the LICENSE | |
9
|
|
|
// | file that was distributed with this source code. You can also view the | |
10
|
|
|
// | LICENSE file online at http://www.agavi.org/LICENSE.txt | |
11
|
|
|
// | vi: set noexpandtab: | |
12
|
|
|
// | Local Variables: | |
13
|
|
|
// | indent-tabs-mode: t | |
14
|
|
|
// | End: | |
15
|
|
|
// +---------------------------------------------------------------------------+ |
16
|
|
|
use Agavi\Core\Context; |
17
|
|
|
use Agavi\Request\RequestDataHolder; |
18
|
|
|
use Agavi\Response\Response; |
19
|
|
|
|
20
|
|
|
/** |
21
|
|
|
* ContainerTestCase is the base class for all tests that target a specific |
22
|
|
|
* container execution and provides the necessary assertions |
23
|
|
|
* |
24
|
|
|
* |
25
|
|
|
* @package agavi |
26
|
|
|
* @subpackage testing |
27
|
|
|
* |
28
|
|
|
* @author Felix Gilcher <[email protected]> |
29
|
|
|
* @copyright The Agavi Project |
30
|
|
|
* |
31
|
|
|
* @since 1.0.0 |
32
|
|
|
* |
33
|
|
|
* @version $Id: FlowTestCase.class.php 3843 2009-02-16 14:12:47Z felix $ |
34
|
|
|
*/ |
35
|
|
|
abstract class ContainerTestCase extends FragmentTestCase |
36
|
|
|
{ |
37
|
|
|
/** |
38
|
|
|
* @var string the name of the controller to use |
39
|
|
|
*/ |
40
|
|
|
protected $controllerName; |
41
|
|
|
|
42
|
|
|
/** |
43
|
|
|
* @var string the name of the module the controller resides in |
44
|
|
|
*/ |
45
|
|
|
protected $moduleName; |
46
|
|
|
|
47
|
|
|
/** |
48
|
|
|
* @var Response the response after the dispatch call |
49
|
|
|
*/ |
50
|
|
|
protected $response; |
51
|
|
|
|
52
|
|
|
/** |
53
|
|
|
* dispatch the request |
54
|
|
|
* |
55
|
|
|
* @author Felix Gilcher <[email protected]> |
56
|
|
|
* @since 1.0.0 |
57
|
|
|
*/ |
58
|
|
|
public function execute($arguments = null, $outputType = null, $requestMethod = null) |
59
|
|
|
{ |
60
|
|
|
$context = Context::getInstance(); |
61
|
|
|
|
62
|
|
|
$dispatcher = $context->getDispatcher(); |
63
|
|
|
$dispatcher->setParameter('send_response', false); |
64
|
|
|
|
65
|
|
|
if (!($arguments instanceof RequestDataHolder)) { |
66
|
|
|
$arguments = $this->createRequestDataHolder(array(RequestDataHolder::SOURCE_PARAMETERS => $arguments)); |
67
|
|
|
} |
68
|
|
|
|
69
|
|
|
$this->response = $dispatcher->dispatch(null, $dispatcher->createExecutionContainer($this->moduleName, $this->controllerName, $arguments, $outputType, $requestMethod)); |
70
|
|
|
} |
71
|
|
|
|
72
|
|
|
/** |
73
|
|
|
* assert that the response has a given tag |
74
|
|
|
* |
75
|
|
|
* @see the documentation of PHPUnit's assertTag() |
76
|
|
|
* |
77
|
|
|
* @param array $matcher the matcher describing the tag |
78
|
|
|
* @param string $message an optional message |
79
|
|
|
* @param bool $isHtml |
80
|
|
|
* |
81
|
|
|
* @author Felix Gilcher <[email protected]> |
82
|
|
|
* @since 1.0.0 |
83
|
|
|
*/ |
84
|
|
|
public function assertResponseHasTag($matcher, $message = '', $isHtml = true) |
85
|
|
|
{ |
86
|
|
|
$this->assertTag($matcher, $this->response->getContent(), $message, $isHtml); |
|
|
|
|
87
|
|
|
} |
88
|
|
|
|
89
|
|
|
|
90
|
|
|
/** |
91
|
|
|
* assert that the response does not have a given tag |
92
|
|
|
* |
93
|
|
|
* @see the documentation of PHPUnit's assertTag() |
94
|
|
|
* |
95
|
|
|
* @author Felix Gilcher <[email protected]> |
96
|
|
|
* @since 1.0.0 |
97
|
|
|
*/ |
98
|
|
|
public function assertResponseHasNotTag($matcher, $message = '', $isHtml = true) |
99
|
|
|
{ |
100
|
|
|
$this->assertNotTag($matcher, $this->response->getContent(), $message, $isHtml); |
|
|
|
|
101
|
|
|
} |
102
|
|
|
} |
103
|
|
|
|
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.
This is most likely a typographical error or the method has been renamed.