UrlTest.php 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. <?php
  2. // Call Zend_View_Helper_UrlTest::main() if this source file is executed directly.
  3. if (!defined("PHPUnit_MAIN_METHOD")) {
  4. define("PHPUnit_MAIN_METHOD", "Zend_View_Helper_UrlTest::main");
  5. }
  6. require_once dirname(dirname(dirname(dirname(__FILE__)))) . '/TestHelper.php';
  7. require_once "PHPUnit/Framework/TestCase.php";
  8. require_once "PHPUnit/Framework/TestSuite.php";
  9. require_once 'Zend/View.php';
  10. require_once 'Zend/View/Helper/Url.php';
  11. /* Test dependency on Front Controller because there is no way to get the Controller out of View instance dynamically */
  12. require_once 'Zend/Controller/Front.php';
  13. require_once 'Zend/Controller/Request/Http.php';
  14. /**
  15. * Zend_View_Helper_UrlTest
  16. *
  17. * Tests formText helper, including some common functionality of all form helpers
  18. *
  19. * @uses PHPUnit_Framework_TestCase
  20. * @version $Id$
  21. */
  22. class Zend_View_Helper_UrlTest extends PHPUnit_Framework_TestCase
  23. {
  24. /**
  25. * Runs the test methods of this class.
  26. *
  27. * @access public
  28. * @static
  29. */
  30. public static function main()
  31. {
  32. require_once "PHPUnit/TextUI/TestRunner.php";
  33. $suite = new PHPUnit_Framework_TestSuite("Zend_View_Helper_UrlTest");
  34. $result = PHPUnit_TextUI_TestRunner::run($suite);
  35. }
  36. /**
  37. * Sets up the fixture, for example, open a network connection.
  38. * This method is called before a test is executed.
  39. *
  40. * @access protected
  41. */
  42. protected function setUp()
  43. {
  44. $this->front = Zend_Controller_Front::getInstance();
  45. $this->front->getRouter()->addDefaultRoutes();
  46. // $this->view = new Zend_View();
  47. $this->helper = new Zend_View_Helper_Url();
  48. // $this->helper->setView($this->view);
  49. }
  50. public function testDefaultEmpty()
  51. {
  52. $url = $this->helper->url();
  53. $this->assertEquals('/', $url);
  54. }
  55. public function testDefault()
  56. {
  57. $url = $this->helper->url(array('controller' => 'ctrl', 'action' => 'act'));
  58. $this->assertEquals('/ctrl/act', $url);
  59. }
  60. }
  61. // Call Zend_View_Helper_UrlTest::main() if this source file is executed directly.
  62. if (PHPUnit_MAIN_METHOD == "Zend_View_Helper_UrlTest::main") {
  63. Zend_View_Helper_UrlTest::main();
  64. }