| 1 |
lars |
1 |
<?php
|
|
|
2 |
|
|
|
3 |
/*
|
|
|
4 |
* This file is part of the symfony package.
|
|
|
5 |
* (c) Fabien Potencier <fabien.potencier@symfony-project.com>
|
|
|
6 |
*
|
|
|
7 |
* For the full copyright and license information, please view the LICENSE
|
|
|
8 |
* file that was distributed with this source code.
|
|
|
9 |
*/
|
|
|
10 |
|
|
|
11 |
/**
|
|
|
12 |
* sfTestFunctional tests an application by using a browser simulator.
|
|
|
13 |
*
|
|
|
14 |
* @package symfony
|
|
|
15 |
* @subpackage test
|
|
|
16 |
* @author Fabien Potencier <fabien.potencier@symfony-project.com>
|
|
|
17 |
* @version SVN: $Id: sfTestFunctional.class.php 23937 2009-11-14 17:43:12Z fabien $
|
|
|
18 |
*/
|
|
|
19 |
class sfTestFunctional extends sfTestFunctionalBase
|
|
|
20 |
{
|
|
|
21 |
/**
|
|
|
22 |
* Initializes the browser tester instance.
|
|
|
23 |
*
|
|
|
24 |
* @param sfBrowserBase $browser A sfBrowserBase instance
|
|
|
25 |
* @param lime_test $lime A lime instance
|
|
|
26 |
*/
|
|
|
27 |
public function __construct(sfBrowserBase $browser, lime_test $lime = null, $testers = array())
|
|
|
28 |
{
|
|
|
29 |
$testers = array_merge(array(
|
|
|
30 |
'view_cache' => 'sfTesterViewCache',
|
|
|
31 |
'form' => 'sfTesterForm',
|
|
|
32 |
), $testers);
|
|
|
33 |
|
|
|
34 |
parent::__construct($browser, $lime, $testers);
|
|
|
35 |
}
|
|
|
36 |
|
|
|
37 |
/**
|
|
|
38 |
* Checks that the request is forwarded to a given module/action.
|
|
|
39 |
*
|
|
|
40 |
* @param string $moduleName The module name
|
|
|
41 |
* @param string $actionName The action name
|
|
|
42 |
* @param mixed $position The position in the action stack (default to the last entry)
|
|
|
43 |
*
|
|
|
44 |
* @return sfTestFunctional The current sfTestFunctional instance
|
|
|
45 |
*/
|
|
|
46 |
public function isForwardedTo($moduleName, $actionName, $position = 'last')
|
|
|
47 |
{
|
|
|
48 |
$actionStack = $this->browser->getContext()->getActionStack();
|
|
|
49 |
|
|
|
50 |
switch ($position)
|
|
|
51 |
{
|
|
|
52 |
case 'first':
|
|
|
53 |
$entry = $actionStack->getFirstEntry();
|
|
|
54 |
break;
|
|
|
55 |
case 'last':
|
|
|
56 |
$entry = $actionStack->getLastEntry();
|
|
|
57 |
break;
|
|
|
58 |
default:
|
|
|
59 |
$entry = $actionStack->getEntry($position);
|
|
|
60 |
}
|
|
|
61 |
|
|
|
62 |
$this->test()->is($entry->getModuleName(), $moduleName, sprintf('request is forwarded to the "%s" module (%s)', $moduleName, $position));
|
|
|
63 |
$this->test()->is($entry->getActionName(), $actionName, sprintf('request is forwarded to the "%s" action (%s)', $actionName, $position));
|
|
|
64 |
|
|
|
65 |
return $this;
|
|
|
66 |
}
|
|
|
67 |
}
|