2
0

UrlTest.php 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  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-2010 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 dirname(dirname(dirname(dirname(__FILE__)))) . '/TestHelper.php';
  27. require_once "PHPUnit/Framework/TestCase.php";
  28. require_once "PHPUnit/Framework/TestSuite.php";
  29. require_once 'Zend/View.php';
  30. require_once 'Zend/View/Helper/Url.php';
  31. /* Test dependency on Front Controller because there is no way to get the Controller out of View instance dynamically */
  32. require_once 'Zend/Controller/Front.php';
  33. require_once 'Zend/Controller/Request/Http.php';
  34. /**
  35. * Zend_View_Helper_UrlTest
  36. *
  37. * Tests formText helper, including some common functionality of all form helpers
  38. *
  39. * @category Zend
  40. * @package Zend_View
  41. * @subpackage UnitTests
  42. * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
  43. * @license http://framework.zend.com/license/new-bsd New BSD License
  44. * @group Zend_View
  45. * @group Zend_View_Helper
  46. */
  47. class Zend_View_Helper_UrlTest extends PHPUnit_Framework_TestCase
  48. {
  49. /**
  50. * Runs the test methods of this class.
  51. *
  52. * @access public
  53. * @static
  54. */
  55. public static function main()
  56. {
  57. require_once "PHPUnit/TextUI/TestRunner.php";
  58. $suite = new PHPUnit_Framework_TestSuite("Zend_View_Helper_UrlTest");
  59. $result = PHPUnit_TextUI_TestRunner::run($suite);
  60. }
  61. /**
  62. * Sets up the fixture, for example, open a network connection.
  63. * This method is called before a test is executed.
  64. *
  65. * @access protected
  66. */
  67. protected function setUp()
  68. {
  69. $this->front = Zend_Controller_Front::getInstance();
  70. $this->front->getRouter()->addDefaultRoutes();
  71. // $this->view = new Zend_View();
  72. $this->helper = new Zend_View_Helper_Url();
  73. // $this->helper->setView($this->view);
  74. }
  75. public function testDefaultEmpty()
  76. {
  77. $url = $this->helper->url();
  78. $this->assertEquals('/', $url);
  79. }
  80. public function testDefault()
  81. {
  82. $url = $this->helper->url(array('controller' => 'ctrl', 'action' => 'act'));
  83. $this->assertEquals('/ctrl/act', $url);
  84. }
  85. }
  86. // Call Zend_View_Helper_UrlTest::main() if this source file is executed directly.
  87. if (PHPUnit_MAIN_METHOD == "Zend_View_Helper_UrlTest::main") {
  88. Zend_View_Helper_UrlTest::main();
  89. }