sfTestFunctional.class.php 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. <?php
  2. /*
  3. * This file is part of the symfony package.
  4. * (c) Fabien Potencier <fabien.potencier@symfony-project.com>
  5. *
  6. * For the full copyright and license information, please view the LICENSE
  7. * file that was distributed with this source code.
  8. */
  9. /**
  10. * sfTestFunctional tests an application by using a browser simulator.
  11. *
  12. * @package symfony
  13. * @subpackage test
  14. * @author Fabien Potencier <fabien.potencier@symfony-project.com>
  15. * @version SVN: $Id: sfTestFunctional.class.php 14485 2009-01-06 10:34:49Z fabien $
  16. */
  17. class sfTestFunctional extends sfTestFunctionalBase
  18. {
  19. /**
  20. * Initializes the browser tester instance.
  21. *
  22. * @param sfBrowserBase $browser A sfBrowserBase instance
  23. * @param lime_test $lime A lime instance
  24. */
  25. public function __construct(sfBrowserBase $browser, lime_test $lime = null, $testers = array())
  26. {
  27. $testers = array_merge(array(
  28. 'view_cache' => 'sfTesterViewCache',
  29. 'form' => 'sfTesterForm',
  30. ), $testers);
  31. parent::__construct($browser, $lime, $testers);
  32. }
  33. /**
  34. * Checks that the request is forwarded to a given module/action.
  35. *
  36. * @param string $moduleName The module name
  37. * @param string $actionName The action name
  38. * @param mixed $position The position in the action stack (default to the last entry)
  39. *
  40. * @return sfTestBrowser The current sfTestBrowser instance
  41. */
  42. public function isForwardedTo($moduleName, $actionName, $position = 'last')
  43. {
  44. $actionStack = $this->browser->getContext()->getActionStack();
  45. switch ($position)
  46. {
  47. case 'first':
  48. $entry = $actionStack->getFirstEntry();
  49. break;
  50. case 'last':
  51. $entry = $actionStack->getLastEntry();
  52. break;
  53. default:
  54. $entry = $actionStack->getEntry($position);
  55. }
  56. $this->test()->is($entry->getModuleName(), $moduleName, sprintf('request is forwarded to the "%s" module (%s)', $moduleName, $position));
  57. $this->test()->is($entry->getActionName(), $actionName, sprintf('request is forwarded to the "%s" action (%s)', $actionName, $position));
  58. return $this;
  59. }
  60. /**
  61. * Tests if the given uri is cached.
  62. *
  63. * @deprecated since 1.2
  64. *
  65. * @param boolean $boolean Flag for checking the cache
  66. * @param boolean $with_layout If have or not layout
  67. *
  68. * @return sfTestBrowser The current sfTestBrowser instance
  69. */
  70. public function isCached($boolean, $with_layout = false)
  71. {
  72. return $this->with('view_cache')->isCached($boolean, $with_layout);
  73. }
  74. /**
  75. * Tests if the given uri is cached.
  76. *
  77. * @deprecated since 1.2
  78. *
  79. * @param string $uri Uniform resource identifier
  80. * @param boolean $boolean Flag for checking the cache
  81. * @param boolean $with_layout If have or not layout
  82. *
  83. * @return sfTestBrowser The current sfTestBrowser instance
  84. */
  85. public function isUriCached($uri, $boolean, $with_layout = false)
  86. {
  87. return $this->with('view_cache')->isUriCached($uri, $boolean, $with_layout);
  88. }
  89. }