UrlTest.php 2.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. <?php
  2. /**
  3. * Zend Framework
  4. *
  5. * LICENSE
  6. *
  7. * This source file is subject to the new BSD license that is bundled
  8. * with this package in the file LICENSE.txt.
  9. * It is also available through the world-wide-web at this URL:
  10. * http://framework.zend.com/license/new-bsd
  11. * If you did not receive a copy of the license and are unable to
  12. * obtain it through the world-wide-web, please send an email
  13. * to license@zend.com so we can send you a copy immediately.
  14. *
  15. * @category Zend
  16. * @package Zend_View
  17. * @subpackage UnitTests
  18. * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
  19. * @license http://framework.zend.com/license/new-bsd New BSD License
  20. * @version $Id$
  21. */
  22. // Call Zend_View_Helper_UrlTest::main() if this source file is executed directly.
  23. if (!defined("PHPUnit_MAIN_METHOD")) {
  24. define("PHPUnit_MAIN_METHOD", "Zend_View_Helper_UrlTest::main");
  25. }
  26. require_once 'Zend/View.php';
  27. require_once 'Zend/View/Helper/Url.php';
  28. /* Test dependency on Front Controller because there is no way to get the Controller out of View instance dynamically */
  29. require_once 'Zend/Controller/Front.php';
  30. require_once 'Zend/Controller/Request/Http.php';
  31. /**
  32. * Zend_View_Helper_UrlTest
  33. *
  34. * Tests formText helper, including some common functionality of all form helpers
  35. *
  36. * @category Zend
  37. * @package Zend_View
  38. * @subpackage UnitTests
  39. * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
  40. * @license http://framework.zend.com/license/new-bsd New BSD License
  41. * @group Zend_View
  42. * @group Zend_View_Helper
  43. */
  44. class Zend_View_Helper_UrlTest extends PHPUnit_Framework_TestCase
  45. {
  46. /**
  47. * Runs the test methods of this class.
  48. *
  49. * @access public
  50. * @static
  51. */
  52. public static function main()
  53. {
  54. $suite = new PHPUnit_Framework_TestSuite("Zend_View_Helper_UrlTest");
  55. $result = PHPUnit_TextUI_TestRunner::run($suite);
  56. }
  57. /**
  58. * Sets up the fixture, for example, open a network connection.
  59. * This method is called before a test is executed.
  60. *
  61. * @access protected
  62. */
  63. protected function setUp()
  64. {
  65. $this->front = Zend_Controller_Front::getInstance();
  66. $this->front->getRouter()->addDefaultRoutes();
  67. // $this->view = new Zend_View();
  68. $this->helper = new Zend_View_Helper_Url();
  69. // $this->helper->setView($this->view);
  70. }
  71. public function testDefaultEmpty()
  72. {
  73. $url = $this->helper->url();
  74. $this->assertEquals('/', $url);
  75. }
  76. public function testDefault()
  77. {
  78. $url = $this->helper->url(array('controller' => 'ctrl', 'action' => 'act'));
  79. $this->assertEquals('/ctrl/act', $url);
  80. }
  81. }
  82. // Call Zend_View_Helper_UrlTest::main() if this source file is executed directly.
  83. if (PHPUnit_MAIN_METHOD == "Zend_View_Helper_UrlTest::main") {
  84. Zend_View_Helper_UrlTest::main();
  85. }