Changeset 541 for trunk/tests
- Timestamp:
- Aug 12, 2015 12:22:54 AM (9 years ago)
- Location:
- trunk/tests
- Files:
-
- 1 deleted
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tests/AppTest.php
r479 r541 112 112 function test_printraisedmessages() 113 113 { 114 $app =& App::getInstance(); 114 115 ob_start(); 115 116 $this->test_raisemsg(); //had to add this line for phpunit ver. 3.7 /// 116 $app =& App::getInstance();117 117 $app->printraisedmessages(); 118 118 $result = ob_get_clean(); … … 145 145 { 146 146 $app =& App::getInstance(); 147 $app->setParam(array('session_use_trans_sid' => true)); 147 148 ob_start(); 148 149 $app->printhiddensession(); -
trunk/tests/AuthSQLTest.php
r479 r541 71 71 "); 72 72 $_SESSION = AuthSQLTest::$shared_session; 73 74 // Sessions require client IP addr. 75 $_SERVER['REMOTE_ADDR'] = '127.0.0.1'; 73 76 } 74 77 … … 206 209 function test_generatepassword() 207 210 { 208 $result = $this->Auth_SQL->generatepassword( 'xCVcvd');209 $this->assert RegExp('/[bcdfghjklmnprstvwxzBCDFGHJKLMNPRSTVWXZaeiouyAEIOUY0123456789!@#%&*-=+.?][bcdfghjklmnprstvwxzBCDFGHJKLMNPRSTVWXZ][aeiouyAEIOUY][bcdfghjklmnprstvwxz][aeiouy][0123456789]/', $result, 'Generated password does not match intended pattern');211 $result = $this->Auth_SQL->generatepassword(10); 212 $this->assertEquals(14, strlen($result)); 210 213 } 211 214 212 215 function test_encryptpassword() 213 216 { 214 $this->Auth_SQL->setParam(array('encryption_type' => Auth_SQL::ENCRYPT_MD5)); 215 $result = $this->Auth_SQL->encryptpassword('123'); 217 $result = $this->Auth_SQL->encryptpassword('123', null, Auth_SQL::ENCRYPT_MD5); 216 218 $this->assertEquals('202cb962ac59075b964b07152d234b70', $result); 217 218 $this->Auth_SQL->setParam(array('encryption_type' => Auth_SQL::ENCRYPT_MD5_HARDENED)); 219 $result = $this->Auth_SQL->encryptpassword('123' );220 $this->assertEquals(' c55e4ac608a8768ecd758fab971b0646', $result);221 222 $this->Auth_SQL->setParam(array('encryption_type' => Auth_SQL::ENCRYPT_SHA1)); 223 $result = $this->Auth_SQL->encryptpassword('123' );219 $this->assertTrue($this->Auth_SQL->verifyPassword('123', $result, Auth_SQL::ENCRYPT_MD5)); 220 221 $result = $this->Auth_SQL->encryptpassword('123', null, Auth_SQL::ENCRYPT_MD5_HARDENED); 222 $this->assertEquals('1f0f8d357a96eb97f24371ebf53dcaf6', $result); 223 $this->assertTrue($this->Auth_SQL->verifyPassword('123', $result, Auth_SQL::ENCRYPT_MD5_HARDENED)); 224 225 $result = $this->Auth_SQL->encryptpassword('123', null, Auth_SQL::ENCRYPT_SHA1); 224 226 $this->assertEquals('40bd001563085fc35165329ea1ff5c5ecbdbbeef', $result); 225 226 $this->Auth_SQL->setParam(array('encryption_type' => Auth_SQL::ENCRYPT_SHA1_HARDENED)); 227 $result = $this->Auth_SQL->encryptpassword('123' );228 $this->assertEquals(' 33d90af96a5928ac93cbd41fc436e8c55d2768c2', $result);229 230 $this->Auth_SQL->setParam(array('encryption_type' => Auth_SQL::ENCRYPT_PLAINTEXT)); 231 $result = $this->Auth_SQL->encryptpassword('123' );227 $this->assertTrue($this->Auth_SQL->verifyPassword('123', $result, Auth_SQL::ENCRYPT_SHA1)); 228 229 $result = $this->Auth_SQL->encryptpassword('123', null, Auth_SQL::ENCRYPT_SHA1_HARDENED); 230 $this->assertEquals('1d086fcae3dd941e0f1371148502d03e96ab536f', $result); 231 $this->assertTrue($this->Auth_SQL->verifyPassword('123', $result, Auth_SQL::ENCRYPT_SHA1_HARDENED)); 232 233 $result = $this->Auth_SQL->encryptpassword('123', null, Auth_SQL::ENCRYPT_PLAINTEXT); 232 234 $this->assertEquals('123', $result); 233 234 $this->Auth_SQL->setParam(array('encryption_type' => Auth_SQL::ENCRYPT_CRYPT)); 235 $result = $this->Auth_SQL->encryptpassword('123', 'saltstring'); 236 $this->assertEquals('saEZ6MlWYV9nQ', $result); 235 $this->assertTrue($this->Auth_SQL->verifyPassword('123', $result, Auth_SQL::ENCRYPT_PLAINTEXT)); 236 237 $result = $this->Auth_SQL->encryptpassword('123', 'saltstring', Auth_SQL::ENCRYPT_CRYPT); 238 $this->assertTrue($this->Auth_SQL->verifyPassword('123', $result, Auth_SQL::ENCRYPT_CRYPT)); 239 240 if (function_exists('password_hash')) { 241 // Only available in PHP >= 5.5 242 $result = $this->Auth_SQL->encryptpassword('123', 'saltstring', Auth_SQL::ENCRYPT_PASSWORD_BCRYPT); 243 $this->assertTrue($this->Auth_SQL->verifyPassword('123', $result, Auth_SQL::ENCRYPT_PASSWORD_BCRYPT)); 244 245 $result = $this->Auth_SQL->encryptpassword('123', 'saltstring', Auth_SQL::ENCRYPT_PASSWORD_DEFAULT); 246 $this->assertTrue($this->Auth_SQL->verifyPassword('123', $result, Auth_SQL::ENCRYPT_PASSWORD_DEFAULT)); 247 } 237 248 } 238 249 … … 241 252 $db =& DB::getInstance(); 242 253 243 $this->Auth_SQL->setParam(array(' encryption_type' => Auth_SQL::ENCRYPT_SHA1_HARDENED));254 $this->Auth_SQL->setParam(array('hash_type' => Auth_SQL::ENCRYPT_SHA1_HARDENED)); 244 255 $this->Auth_SQL->setpassword(null, '123'); 245 256 $qid = $db->query(" … … 248 259 "); 249 260 list($pass) = mysql_fetch_row($qid); 250 $this->assertEquals(' 33d90af96a5928ac93cbd41fc436e8c55d2768c2', $pass);261 $this->assertEquals('1d086fcae3dd941e0f1371148502d03e96ab536f', $pass); 251 262 } 252 263 -
trunk/tests/LockTest.php
r479 r541 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/>. … … 37 37 38 38 function setUp() 39 { 39 { 40 40 require dirname(__FILE__) . '/_config.inc.php'; 41 41 require_once '../lib/Lock.inc.php'; … … 71 71 ) 72 72 "); 73 74 // Sessions require client IP addr. 75 $_SERVER['REMOTE_ADDR'] = '127.0.0.1'; 76 73 77 $this->Auth_SQL->login('testuser', 'testpass'); 74 78 … … 87 91 { 88 92 $db =& DB::getInstance(); 89 93 90 94 unset($this->Lock); 91 95 unset($this->Auth_SQL); -
trunk/tests/UtilitiesTest.php
r468 r541 1 1 <?php 2 /// FIXME: Tests not implemented.3 return;4 5 2 /** 6 3 * The Strangecode Codebase - a general application development framework for PHP 7 4 * For details visit the project site: <http://trac.strangecode.com/codebase/> 8 5 * Copyright 2001-2012 Strangecode, LLC 9 * 6 * 10 7 * This file is part of The Strangecode Codebase. 11 8 * … … 14 11 * Free Software Foundation, either version 3 of the License, or (at your option) 15 12 * any later version. 16 * 13 * 17 14 * The Strangecode Codebase is distributed in the hope that it will be useful, but 18 15 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 19 16 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more 20 17 * details. 21 * 18 * 22 19 * You should have received a copy of the GNU General Public License along with 23 20 * The Strangecode Codebase. If not, see <http://www.gnu.org/licenses/>. … … 36 33 class UtilitiesTest extends PHPUnit_Framework_TestCase { 37 34 38 var $Utilities;39 40 function UtilitiesTest($name)41 {42 $this->PHPUnit_Framework_TestCase($name);43 }44 45 35 function setUp() 46 36 { 37 define('_CLI', true); 47 38 require dirname(__FILE__) . '/_config.inc.php'; 48 39 require_once '../lib/Utilities.inc.php'; 49 $this->Utilities =& new Utilities(PARAM);40 // $this->Utilities =& new Utilities(PARAM); 50 41 } 51 42 52 43 function tearDown() 53 44 { 54 unset($this->Utilities); 45 $app =& App::getInstance(); 46 $app->stop(); 47 } 48 49 function test_hyperlinkTxt() 50 { 51 $urls = [ 52 ' http://www.asdf.com/ ' => ' <a href="http://www.asdf.com/">www.asdf.com/</a> ', 53 ' www.asdf.com/ ' => ' <a href="http://www.asdf.com/">www.asdf.com/</a> ', 54 ' www.asdf.com/? ' => ' <a href="http://www.asdf.com/">www.asdf.com/</a>? ', 55 ' www.asdf.com/?x=y+z ' => ' <a href="http://www.asdf.com/?x=y+z">www.asdf.com/?x=y+z</a> ', 56 ' www.asdf.com/?x=y+ ' => ' <a href="http://www.asdf.com/?x=y+">www.asdf.com/?x=y+</a> ', 57 ' www.asdf.com/?x= ' => ' <a href="http://www.asdf.com/?x=">www.asdf.com/?x=</a> ', 58 ' www.asdf.com/?x ' => ' <a href="http://www.asdf.com/?x">www.asdf.com/?x</a> ', 59 ' www.asdf.com/?â€ïž=ð¥ ' => ' <a href="http://www.asdf.com/?â€ïž=ð¥">www.asdf.com/?â€ïž=ð¥</a> ', 60 ' www.asdf.com? ' => ' <a href="http://www.asdf.com">www.asdf.com</a>? ', 61 ' www.asdf.com! ' => ' <a href="http://www.asdf.com">www.asdf.com</a>! ', 62 ' www.asdf.com. ' => ' <a href="http://www.asdf.com">www.asdf.com</a>. ', 63 ' `www.asdf.com` ' => ' `www.asdf.com` ', 64 ' "www.asdf.com" ' => ' "www.asdf.com" ', 65 ' <www.asdf.com> ' => ' <<a href="http://www.asdf.com">www.asdf.com</a>> ', 66 ' <http://www.asdf.com> ' => ' <<a href="http://www.asdf.com">www.asdf.com</a>> ', 67 ' (http://www.asdf.com) ' => ' (<a href="http://www.asdf.com">www.asdf.com</a>) ', 68 ' (URL: http://www.asdf.com#1) ' => ' (URL: <a href="http://www.asdf.com#1">www.asdf.com#1</a>) ', 69 ' <a href="http://www.example.com/">Click Here</a> ' => ' <a href="http://www.example.com/">Click Here</a> ', 70 ' <a href="http://www.example.com/">http://www.example.com/</a> ' => ' <a href="http://www.example.com/">http://www.example.com/</a> ', 71 ' <a href=http://www.example.com/>http://www.example.com/</a> ' => ' <a href=http://www.example.com/>http://www.example.com/</a> ', 72 ' <a href=\'http://www.example.com/\' >http://www.example.com/</a> ' => ' <a href=\'http://www.example.com/\' >http://www.example.com/</a> ', 73 ' http://foo.com/blah_blah ' => ' <a href="http://foo.com/blah_blah">foo.com/blah_blah</a> ', 74 ' http://foo.com/blah_blah/ ' => ' <a href="http://foo.com/blah_blah/">foo.com/blah_blah/</a> ', 75 ' http://foo.com/blah_blah_(wikipedia) ' => ' <a href="http://foo.com/blah_blah_(wikipedia">foo.com/blah_blah_(wikipedia</a>) ', 76 ' http://foo.com/blah_blah_(wikipedia)_(again) ' => ' <a href="http://foo.com/blah_blah_(wikipedia)_(again">foo.com/blah_blah_(wikipedia)_(again</a>) ', 77 ' http://www.example.com/wpstyle/?p=364 ' => ' <a href="http://www.example.com/wpstyle/?p=364">www.example.com/wpstyle/?p=364</a> ', 78 ' https://www.example.com/foo/?bar=baz&inga=42&quux ' => ' <a href="https://www.example.com/foo/?bar=baz&inga=42&quux">www.example.com/foo/?bar=baz&inga=42&quux</a> ', 79 ' http://âªdf.ws/123 ' => ' <a href="http://âªdf.ws/123">âªdf.ws/123</a> ', 80 ' http://userid:password@example.com:8080 ' => ' <a href="http://userid:password@example.com:8080">userid:password@example.com:8080</a> ', 81 ' http://userid:password@example.com:8080/ ' => ' <a href="http://userid:password@example.com:8080/">userid:password@example.com:8080/</a> ', 82 ' http://userid@example.com ' => ' <a href="http://userid@example.com">userid@example.com</a> ', 83 ' http://userid@example.com/ ' => ' <a href="http://userid@example.com/">userid@example.com/</a> ', 84 ' http://userid@example.com:8080 ' => ' <a href="http://userid@example.com:8080">userid@example.com:8080</a> ', 85 ' http://userid@example.com:8080/ ' => ' <a href="http://userid@example.com:8080/">userid@example.com:8080/</a> ', 86 ' http://userid:password@example.com ' => ' <a href="http://userid:password@example.com">userid:password@example.com</a> ', 87 ' http://userid:password@example.com/ ' => ' <a href="http://userid:password@example.com/">userid:password@example.com/</a> ', 88 ' http://142.42.1.1/ ' => ' <a href="http://142.42.1.1/">142.42.1.1/</a> ', 89 ' http://142.42.1.1:8080/ ' => ' <a href="http://142.42.1.1:8080/">142.42.1.1:8080/</a> ', 90 ' http://â¡.ws/äš¹ ' => ' <a href="http://â¡.ws/äš¹">â¡.ws/äš¹</a> ', 91 ' http://â.ws ' => ' <a href="http://â.ws">â.ws</a> ', 92 ' http://â.ws/ ' => ' <a href="http://â.ws/">â.ws/</a> ', 93 ' http://foo.com/blah_(wikipedia)#cite-1 ' => ' <a href="http://foo.com/blah_(wikipedia)#cite-1">foo.com/blah_(wikipedia)#cite-1</a> ', 94 ' http://foo.com/blah_(wikipedia)_blah#cite-1 ' => ' <a href="http://foo.com/blah_(wikipedia)_blah#cite-1">foo.com/blah_(wikipedia)_blah#cite-1</a> ', 95 ' http://foo.com/unicode_(âª)_in_parens ' => ' <a href="http://foo.com/unicode_(âª)_in_parens">foo.com/unicode_(âª)_in_parens</a> ', 96 ' http://foo.com/(something)?after=parens ' => ' <a href="http://foo.com/(something)?after=parens">foo.com/(something)?after=parens</a> ', 97 ' http://âº.damowmow.com/ ' => ' <a href="http://âº.damowmow.com/">âº.damowmow.com/</a> ', 98 ' http://code.google.com/events/#&product=browser ' => ' <a href="http://code.google.com/events/#&product=browser">code.google.com/events/#&product=browser</a> ', 99 ' http://j.mp ' => ' <a href="http://j.mp">j.mp</a> ', 100 ' ftp://foo.bar/baz ' => ' <a href="ftp://foo.bar/baz">foo.bar/baz</a> ', 101 ' http://foo.bar/?q=Test%20URL-encoded%20stuff ' => ' <a href="http://foo.bar/?q=Test%20URL-encoded%20stuff">foo.bar/?q=Test%20URL-encoded%20stuff</a> ', 102 ' http://Ù 103 ثاÙ.إختؚار ' => ' <a href="http://Ù 104 ثاÙ.إختؚار">Ù 105 ثاÙ.إختؚار</a> ', 106 ' http://äŸå.æµè¯ ' => ' <a href="http://äŸå.æµè¯">äŸå.æµè¯</a> ', 107 ' http://à€à€Šà€Ÿà€¹à€°à€£.à€ªà€°à¥à€à¥à€·à€Ÿ ' => ' <a href="http://à€à€Šà€Ÿà€¹à€°à€£.à€ªà€°à¥à€à¥à€·à€Ÿ">à€à€Šà€Ÿà€¹à€°à€£.à€ªà€°à¥à€à¥à€·à€Ÿ</a> ', 108 ' http://-.~_!$&\'()*+,;=:%40:80%2f::::::@example.com ' => ' <a href="http://-.~_!$&'()*+,;=:%40:80%2f::::::@example.com">-.~_!$&\'()*+,;=:%40:80%2f::::::@example.com</a> ', 109 ' http://1337.net ' => ' <a href="http://1337.net">1337.net</a> ', 110 ' http://a.b-c.de ' => ' <a href="http://a.b-c.de">a.b-c.de</a> ', 111 ' http://223.255.255.254 ' => ' <a href="http://223.255.255.254">223.255.255.254</a> ', 112 ' http://x and.co OK?' => ' http://x and.co OK?', 113 ' http://foo.bar?q=Spaces should be encoded ' => ' <a href="http://foo.bar?q=Spaces">foo.bar?q=Spaces</a> should be encoded ', 114 ' https://github.com/search?utf8=â&q=gif ' => ' <a href="https://github.com/search?utf8=â&q=gif">github.com/search?utf8=â&q=gif</a> ', 115 ' https://github.com/search?q=gif&utf8=* ' => ' <a href="https://github.com/search?q=gif&utf8=*">github.com/search?q=gif&utf8=*</a> ', 116 ' https://github.com/search?q=gif&utf8=â ' => ' <a href="https://github.com/search?q=gif&utf8=â">github.com/search?q=gif&utf8=â</a> ', 117 118 // These are allowed to fuckup due to limitations in our ability to be omnipotent. 119 ' <a href=http://www.example.com/ > http://www.example.com/</a> ' => ' <a href=http://www.example.com/ > <a href="http://www.example.com/">www.example.com/</a></a> ', 120 ]; 121 foreach ($urls as $input => $expected) { 122 $result = hyperlinkTxt($input, false); 123 $this->assertEquals($expected, $result, sprintf('Failed with input: %s', $input)); 124 } 55 125 } 56 126 -
trunk/tests/phpunit.xml
r468 r541 34 34 <file>PayPalTest.php</file> 35 35 <file>VersionTest.php</file> 36 <file>UtilitiesTest.php</file> 36 37 </testsuite> 37 38 </testsuites> -
trunk/tests/run_tests.sh
r468 r541 31 31 # Config options go in phpunit.xml 32 32 # phpunit --tap | grep -v '^ok ' 33 phpunit --stderr 33 phpunit --stderr || echo "Something went wrong (if there is no output above, check the php_error_log)";
Note: See TracChangeset
for help on using the changeset viewer.