| 1 | <?php |
|---|
| 2 | /** |
|---|
| 3 | * File for the UrlHelperTest class |
|---|
| 4 | * |
|---|
| 5 | * (PHP 5) |
|---|
| 6 | * |
|---|
| 7 | * @package PHPonTraxTest |
|---|
| 8 | * @license http://opensource.org/licenses/gpl-license.php GNU Public License |
|---|
| 9 | * @copyright (c) Walter O. Haas 2006 |
|---|
| 10 | * @version $Id$ |
|---|
| 11 | * @author Walt Haas <haas@xmission.com> |
|---|
| 12 | */ |
|---|
| 13 | |
|---|
| 14 | echo "testing UrlHelper\n"; |
|---|
| 15 | require_once 'testenv.php'; |
|---|
| 16 | |
|---|
| 17 | // Call UrlHelperTest::main() if this source file is executed directly. |
|---|
| 18 | if (!defined("PHPUnit2_MAIN_METHOD")) { |
|---|
| 19 | define("PHPUnit2_MAIN_METHOD", "UrlHelperTest::main"); |
|---|
| 20 | } |
|---|
| 21 | |
|---|
| 22 | require_once "PHPUnit2/Framework/TestCase.php"; |
|---|
| 23 | require_once "PHPUnit2/Framework/TestSuite.php"; |
|---|
| 24 | |
|---|
| 25 | // You may remove the following line when all tests have been implemented. |
|---|
| 26 | require_once "PHPUnit2/Framework/IncompleteTestError.php"; |
|---|
| 27 | |
|---|
| 28 | Trax::$url_prefix = "/testprefix"; |
|---|
| 29 | |
|---|
| 30 | require_once "action_view/helpers.php"; |
|---|
| 31 | require_once "action_view/helpers/form_helper.php"; |
|---|
| 32 | require_once "action_view/helpers/url_helper.php"; |
|---|
| 33 | |
|---|
| 34 | // parameters need by UrlHelper |
|---|
| 35 | $_SERVER['HTTP_HOST'] = 'www.example.com'; |
|---|
| 36 | $_SERVER['SERVER_PORT'] = '80'; |
|---|
| 37 | Trax::$current_controller_path = 'testcontrol'; |
|---|
| 38 | |
|---|
| 39 | /** |
|---|
| 40 | * Test class for UrlHelper. |
|---|
| 41 | * Generated by PHPUnit2_Util_Skeleton on 2006-03-01 at 13:17:32. |
|---|
| 42 | */ |
|---|
| 43 | class UrlHelperTest extends PHPUnit2_Framework_TestCase { |
|---|
| 44 | /** |
|---|
| 45 | * Runs the test methods of this class. |
|---|
| 46 | * |
|---|
| 47 | * @access public |
|---|
| 48 | * @static |
|---|
| 49 | */ |
|---|
| 50 | public static function main() { |
|---|
| 51 | require_once "PHPUnit2/TextUI/TestRunner.php"; |
|---|
| 52 | |
|---|
| 53 | $suite = new PHPUnit2_Framework_TestSuite("UrlHelperTest"); |
|---|
| 54 | $result = PHPUnit2_TextUI_TestRunner::run($suite); |
|---|
| 55 | } |
|---|
| 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 | |
|---|
| 66 | /** |
|---|
| 67 | * Tears down the fixture, for example, close a network connection. |
|---|
| 68 | * This method is called after a test is executed. |
|---|
| 69 | * |
|---|
| 70 | * @access protected |
|---|
| 71 | */ |
|---|
| 72 | protected function tearDown() { |
|---|
| 73 | } |
|---|
| 74 | |
|---|
| 75 | /** |
|---|
| 76 | * Test __construct() method |
|---|
| 77 | */ |
|---|
| 78 | public function test__construct() { |
|---|
| 79 | $uh = new UrlHelper; |
|---|
| 80 | $this->assertTrue(is_object($uh)); |
|---|
| 81 | $this->assertEquals('UrlHelper', get_class($uh)); |
|---|
| 82 | } |
|---|
| 83 | |
|---|
| 84 | /** |
|---|
| 85 | * Test button_to() method |
|---|
| 86 | * @todo Implement this test |
|---|
| 87 | */ |
|---|
| 88 | public function testButton_to_method() { |
|---|
| 89 | // Remove the following line when you implement this test. |
|---|
| 90 | throw new PHPUnit2_Framework_IncompleteTestError; |
|---|
| 91 | } |
|---|
| 92 | |
|---|
| 93 | /** |
|---|
| 94 | * Test button_to() function |
|---|
| 95 | * @todo Implement this test |
|---|
| 96 | */ |
|---|
| 97 | public function testButton_to_function() { |
|---|
| 98 | // Remove the following line when you implement this test. |
|---|
| 99 | throw new PHPUnit2_Framework_IncompleteTestError; |
|---|
| 100 | } |
|---|
| 101 | |
|---|
| 102 | /** |
|---|
| 103 | * Test convert_boolean_attributes() method |
|---|
| 104 | * @todo Implement this test |
|---|
| 105 | */ |
|---|
| 106 | public function testConvert_boolean_attributes() { |
|---|
| 107 | // Remove the following line when you implement this test. |
|---|
| 108 | throw new PHPUnit2_Framework_IncompleteTestError; |
|---|
| 109 | } |
|---|
| 110 | |
|---|
| 111 | /** |
|---|
| 112 | * Test convert_confirm_option_to_javascript() method |
|---|
| 113 | * @todo Implement this test |
|---|
| 114 | */ |
|---|
| 115 | public function testConvert_confirm_option_to_javascript() { |
|---|
| 116 | // Remove the following line when you implement this test. |
|---|
| 117 | throw new PHPUnit2_Framework_IncompleteTestError; |
|---|
| 118 | } |
|---|
| 119 | |
|---|
| 120 | /** |
|---|
| 121 | * Test link_image_to() method |
|---|
| 122 | * @todo Implement this test |
|---|
| 123 | */ |
|---|
| 124 | public function testLink_image_to_method() { |
|---|
| 125 | // Remove the following line when you implement this test. |
|---|
| 126 | throw new PHPUnit2_Framework_IncompleteTestError; |
|---|
| 127 | } |
|---|
| 128 | |
|---|
| 129 | /** |
|---|
| 130 | * Test link_image_to() function |
|---|
| 131 | * @todo Implement this test |
|---|
| 132 | */ |
|---|
| 133 | public function testLink_image_to_function() { |
|---|
| 134 | // Remove the following line when you implement this test. |
|---|
| 135 | throw new PHPUnit2_Framework_IncompleteTestError; |
|---|
| 136 | } |
|---|
| 137 | |
|---|
| 138 | /** |
|---|
| 139 | * Test link_to() method |
|---|
| 140 | * @todo Implement this test |
|---|
| 141 | */ |
|---|
| 142 | public function testLink_to_method() { |
|---|
| 143 | // Remove the following line when you implement this test. |
|---|
| 144 | throw new PHPUnit2_Framework_IncompleteTestError; |
|---|
| 145 | } |
|---|
| 146 | |
|---|
| 147 | /** |
|---|
| 148 | * Test link_to() function |
|---|
| 149 | * @todo Implement this test |
|---|
| 150 | */ |
|---|
| 151 | public function testLink_to_function() { |
|---|
| 152 | // Remove the following line when you implement this test. |
|---|
| 153 | throw new PHPUnit2_Framework_IncompleteTestError; |
|---|
| 154 | } |
|---|
| 155 | |
|---|
| 156 | /** |
|---|
| 157 | * Test url_for() method |
|---|
| 158 | * |
|---|
| 159 | * Thest the {@link UrlHelper::url_for()} method |
|---|
| 160 | */ |
|---|
| 161 | public function testUrl_for_method() { |
|---|
| 162 | $uh = new UrlHelper; |
|---|
| 163 | $this->assertEquals('http://www.example.com/testprefix/testcontrol', |
|---|
| 164 | $uh->url_for()); |
|---|
| 165 | $this->assertEquals('http://www.example.com/testprefix/foocontrol', |
|---|
| 166 | $uh->url_for(array(':controller'=>'foocontrol'))); |
|---|
| 167 | $this->assertEquals('http://www.example.com/testprefix' |
|---|
| 168 | . '/barcontrol/fooaction', |
|---|
| 169 | $uh->url_for(array(':controller'=>'barcontrol', |
|---|
| 170 | ':action' =>'fooaction'))); |
|---|
| 171 | $this->assertEquals('http://www.example.com/testprefix' |
|---|
| 172 | . '/barcontrol/baraction/fooid', |
|---|
| 173 | $uh->url_for(array(':controller'=> 'barcontrol', |
|---|
| 174 | ':action' => 'baraction', |
|---|
| 175 | ':id' => 'fooid'))); |
|---|
| 176 | } |
|---|
| 177 | |
|---|
| 178 | /** |
|---|
| 179 | * Test url_for() function |
|---|
| 180 | * |
|---|
| 181 | * Test the {@link url_for()} function in the {@link url_helper.php} |
|---|
| 182 | * procedural file. |
|---|
| 183 | */ |
|---|
| 184 | public function testUrl_for_function() { |
|---|
| 185 | $this->assertEquals('http://www.example.com/testprefix/testcontrol', |
|---|
| 186 | url_for()); |
|---|
| 187 | } |
|---|
| 188 | } |
|---|
| 189 | |
|---|
| 190 | // Call UrlHelperTest::main() if this source file is executed directly. |
|---|
| 191 | if (PHPUnit2_MAIN_METHOD == "UrlHelperTest::main") { |
|---|
| 192 | UrlHelperTest::main(); |
|---|
| 193 | } |
|---|
| 194 | |
|---|
| 195 | // -- set Emacs parameters -- |
|---|
| 196 | // Local variables: |
|---|
| 197 | // tab-width: 4 |
|---|
| 198 | // c-basic-offset: 4 |
|---|
| 199 | // c-hanging-comment-ender-p: nil |
|---|
| 200 | // indent-tabs-mode: nil |
|---|
| 201 | // End: |
|---|
| 202 | ?> |
|---|