Changeset 720 for trunk/tests
- Timestamp:
- Mar 9, 2020 3:14:25 AM (4 years ago)
- Location:
- trunk/tests
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tests/AppTest.php
r547 r720 54 54 { 55 55 $thisapp =& App::getInstance(); 56 $this->assertTrue( serialize($thisapp) === serialize($this->App), 'Objects do not match across instantiations.');56 $this->assertTrue($thisapp === $this->App, 'Objects do not match across instantiations.'); 57 57 } 58 58 … … 80 80 $this->App->stop(); 81 81 $this->App->start(); 82 83 82 $this->assertEquals(ini_get('error_reporting'), E_ALL, 'Error reporting not set to E_ALL.'); 84 $this->assertTrue($this->App->db->dbh && is_resource($this->App->db->dbh), 'DB handler not a resource');85 83 $this->assertTrue(isset($_SESSION), '$_SESSION is not set.'); 86 84 $_SESSION['sess_test_value'] = 'okay'; … … 115 113 $app =& App::getInstance(); 116 114 ob_start(); 117 $this->test_raisemsg(); //had to add this line for phpunit ver. 3.7 ///115 $this->test_raisemsg(); //had to add this line for phpunit ver. 3.7 118 116 $app->printraisedmessages(); 119 117 $result = ob_get_clean(); … … 137 135 { 138 136 $app =& App::getInstance(); 139 $_ GET['arg1'] = 'A';137 $_REQUEST['arg1'] = 'A'; 140 138 $result = $app->ohref('/some/url.php', array('arg1'), true); 141 139 $this->assertContains(session_name(), $result, 'SSID not found in URL.'); -
trunk/tests/FormValidatorTest.php
r468 r720 4 4 * For details visit the project site: <http://trac.strangecode.com/codebase/> 5 5 * Copyright 2001-2012 Strangecode, LLC 6 * 6 * 7 7 * This file is part of The Strangecode Codebase. 8 8 * … … 11 11 * Free Software Foundation, either version 3 of the License, or (at your option) 12 12 * any later version. 13 * 13 * 14 14 * The Strangecode Codebase is distributed in the hope that it will be useful, but 15 15 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 16 16 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more 17 17 * details. 18 * 18 * 19 19 * You should have received a copy of the GNU General Public License along with 20 20 * The Strangecode Codebase. If not, see <http://www.gnu.org/licenses/>. … … 97 97 { 98 98 // This should not generate any error. 99 $_POST['some_field'] = 'a non empty string'; 99 $_REQUEST['some_field'] = 'a non empty string'; 100 $this->FormValidator->notEmpty('some_field', _("Error message")); 101 $this->assertFalse($this->FormValidator->anyerrors()); 102 103 // This one is an error! 104 $_REQUEST['some_field'] = ''; 100 105 $this->FormValidator->isempty('some_field', _("Error message")); 101 $this->assertFalse($this->FormValidator->anyerrors()); 102 103 // This one is an error! 104 $_POST['some_field'] = ''; 106 $this->assertTrue($this->FormValidator->anyerrors()); 107 } 108 109 function test_isempty() 110 { 111 // This should not generate any error. 112 $_REQUEST['some_field'] = 'a non empty string'; 105 113 $this->FormValidator->isempty('some_field', _("Error message")); 106 $this->assertTrue($this->FormValidator->anyerrors()); 107 } 108 109 function test_isempty() 110 { 111 // This should not generate any error. 112 $_POST['some_field'] = 'a non empty string'; 114 $this->assertFalse($this->FormValidator->anyerrors()); 115 116 // This one is an error! 117 $_REQUEST['some_field'] = ''; 113 118 $this->FormValidator->isempty('some_field', _("Error message")); 114 $this->assertFalse($this->FormValidator->anyerrors());115 116 // This one is an error!117 $_POST['some_field'] = '';118 $this->FormValidator->isempty('some_field', _("Error message"));119 119 $this->assertTrue($this->FormValidator->anyerrors()); 120 120 } … … 123 123 { 124 124 // This should not generate any error. 125 $_ POST['some_field'] = 'this is a string';125 $_REQUEST['some_field'] = 'this is a string'; 126 126 $this->FormValidator->isstring('some_field', _("Error message")); 127 127 $this->assertFalse($this->FormValidator->anyerrors()); 128 129 // This one is an error! 130 $_ POST['some_field'] = 12.3248; // not a string.128 129 // This one is an error! 130 $_REQUEST['some_field'] = 12.3248; // not a string. 131 131 $this->FormValidator->isstring('some_field', _("Error message")); 132 132 $this->assertTrue($this->FormValidator->anyerrors()); … … 136 136 { 137 137 // This should not generate any error. 138 $_ POST['some_field'] = '1234.453';138 $_REQUEST['some_field'] = '1234.453'; 139 139 $this->FormValidator->isnumber('some_field', _("Error message")); 140 140 $this->assertFalse($this->FormValidator->anyerrors()); 141 142 // This one is an error! 143 $_ POST['some_field'] = 'not a number';141 142 // This one is an error! 143 $_REQUEST['some_field'] = 'not a number'; 144 144 $this->FormValidator->isnumber('some_field', _("Error message")); 145 145 $this->assertTrue($this->FormValidator->anyerrors()); … … 149 149 { 150 150 // This should not generate any error. 151 $_ POST['some_field'] = '1234';151 $_REQUEST['some_field'] = '1234'; 152 152 $this->FormValidator->isinteger('some_field', _("Error message")); 153 153 $this->assertFalse($this->FormValidator->anyerrors()); 154 155 // This one is an error! 156 $_ POST['some_field'] = '1234.1';154 155 // This one is an error! 156 $_REQUEST['some_field'] = '1234.1'; 157 157 $this->FormValidator->isinteger('some_field', _("Error message")); 158 158 $this->assertTrue($this->FormValidator->anyerrors()); … … 162 162 { 163 163 // This should not generate any error. 164 $_ POST['some_field'] = '123.1234';164 $_REQUEST['some_field'] = '123.1234'; 165 165 $this->FormValidator->isfloat('some_field', _("Error message")); 166 166 $this->assertFalse($this->FormValidator->anyerrors()); 167 168 // This one is an error! 169 $_ POST['some_field'] = 'some falsity';167 168 // This one is an error! 169 $_REQUEST['some_field'] = 'some falsity'; 170 170 $this->FormValidator->isfloat('some_field', _("Error message")); 171 171 $this->assertTrue($this->FormValidator->anyerrors()); … … 175 175 { 176 176 // This should not generate any error. 177 $_ POST['some_field'] = array('asdf', 123);177 $_REQUEST['some_field'] = array('asdf', 123); 178 178 $this->FormValidator->isarray('some_field', _("Error message")); 179 179 $this->assertFalse($this->FormValidator->anyerrors()); 180 181 // This one is an error! 182 $_ POST['some_field'] = 'some falsity';180 181 // This one is an error! 182 $_REQUEST['some_field'] = 'some falsity'; 183 183 $this->FormValidator->isarray('some_field', _("Error message")); 184 184 $this->assertTrue($this->FormValidator->anyerrors()); … … 188 188 { 189 189 // This should not generate any error. 190 $_ POST['some_field'] = '1234abcd';190 $_REQUEST['some_field'] = '1234abcd'; 191 191 $this->FormValidator->checkregex('some_field', '/\d{4}[a-d]{4}/', true, _("Error message")); 192 192 $this->assertFalse($this->FormValidator->anyerrors()); 193 194 // This should not generate any error. 195 $_ POST['some_field'] = 'no digits here';193 194 // This should not generate any error. 195 $_REQUEST['some_field'] = 'no digits here'; 196 196 $this->FormValidator->checkregex('some_field', '/\d/', false, _("Error message")); 197 197 $this->assertFalse($this->FormValidator->anyerrors()); 198 199 // This one is an error! 200 $_ POST['some_field'] = 'oops, a d1git';198 199 // This one is an error! 200 $_REQUEST['some_field'] = 'oops, a d1git'; 201 201 $this->FormValidator->checkregex('some_field', '/\d/', false, _("Error message")); 202 202 $this->assertTrue($this->FormValidator->anyerrors()); … … 206 206 { 207 207 // This should not generate any error. 208 $_ POST['some_field'] = 'some truth';208 $_REQUEST['some_field'] = 'some truth'; 209 209 $this->FormValidator->stringLength('some_field', 0, 255, _("Error message")); 210 210 $this->assertFalse($this->FormValidator->anyerrors()); 211 212 // This one is an error! 213 $_ POST['some_field'] = 'some falsity';211 212 // This one is an error! 213 $_REQUEST['some_field'] = 'some falsity'; 214 214 $this->FormValidator->stringLength('some_field', 0, 4, _("Error message")); 215 215 $this->assertTrue($this->FormValidator->anyerrors()); … … 219 219 { 220 220 // This should not generate any error. 221 $_ POST['some_field'] = '12';221 $_REQUEST['some_field'] = '12'; 222 222 $this->FormValidator->numericrange('some_field', 3, 22, _("Error message")); 223 223 $this->assertFalse($this->FormValidator->anyerrors()); 224 225 // This one is an error! 226 $_ POST['some_field'] = '12';224 225 // This one is an error! 226 $_REQUEST['some_field'] = '12'; 227 227 $this->FormValidator->numericrange('some_field', 300, 2200, _("Error message")); 228 228 $this->assertTrue($this->FormValidator->anyerrors()); … … 232 232 { 233 233 // This should not generate any error. 234 $_ POST['some_field'] = 'Quinn the Kook <quinn@strangecode.com>';234 $_REQUEST['some_field'] = 'Quinn the Kook <quinn@strangecode.com>'; 235 235 $this->FormValidator->validateemail('some_field', _("Error message")); 236 236 $this->assertFalse($this->FormValidator->anyerrors()); 237 238 // This one is an error! 239 $_ POST['some_field'] = 'quinn@kook.com.';237 238 // This one is an error! 239 $_REQUEST['some_field'] = 'quinn@kook.com.'; 240 240 $this->FormValidator->validateemail('some_field', _("Error message")); 241 241 $this->assertTrue($this->FormValidator->anyerrors()); … … 245 245 { 246 246 // This should not generate any error. 247 $_ POST['some_field'] = '+1 (530) 555-1212';247 $_REQUEST['some_field'] = '+1 (530) 555-1212'; 248 248 $this->FormValidator->validatephone('some_field', _("Error message")); 249 249 $this->assertFalse($this->FormValidator->anyerrors()); 250 251 // This one is an error! 252 $_ POST['some_field'] = 'd321/654*9875 ';250 251 // This one is an error! 252 $_REQUEST['some_field'] = 'd321/654*9875 '; 253 253 $this->FormValidator->validatephone('some_field', _("Error message")); 254 254 $this->assertTrue($this->FormValidator->anyerrors()); … … 258 258 { 259 259 // This should not generate any error. 260 $_ POST['some_field'] = 'next tuesday';260 $_REQUEST['some_field'] = 'next tuesday'; 261 261 $this->FormValidator->validatestrdate('some_field', _("Error message")); 262 262 $this->assertFalse($this->FormValidator->anyerrors()); 263 264 // This one is an error! 265 $_ POST['some_field'] = 'in a galaxy far far away';263 264 // This one is an error! 265 $_REQUEST['some_field'] = 'in a galaxy far far away'; 266 266 $this->FormValidator->validatestrdate('some_field', _("Error message")); 267 267 $this->assertTrue($this->FormValidator->anyerrors()); … … 271 271 { 272 272 // This should not generate any error. 273 $_ POST['some_field'] = '2323-2005-7766-3554';273 $_REQUEST['some_field'] = '2323-2005-7766-3554'; 274 274 $this->FormValidator->validateccnumber('some_field', null); 275 275 $this->assertFalse($this->FormValidator->anyerrors()); 276 277 // This one is an error! 278 $_ POST['some_field'] = '1234 1234 1234 1234';276 277 // This one is an error! 278 $_REQUEST['some_field'] = '1234 1234 1234 1234'; 279 279 $this->FormValidator->validateccnumber('some_field', null); 280 280 $this->assertTrue($this->FormValidator->anyerrors()); -
trunk/tests/VersionTest.php
r695 r720 111 111 { 112 112 $result = $this->Version->create('test_user_tbl', 'user_id', '1', 'Test User', 'First version of user'); 113 $this->assertSame( 1, $result);113 $this->assertSame('1', $result); 114 114 } 115 115
Note: See TracChangeset
for help on using the changeset viewer.