Changeset 289
- Timestamp:
- 11/01/06 19:13:41 (2 years ago)
- Files:
-
- trunk/build/manifests/jelix-lib.mn (modified) (1 diff)
- trunk/build/manifests/testapp.mn (modified) (1 diff)
- trunk/lib/jelix/core/url/jUrl.class.php (modified) (5 diffs)
- trunk/lib/jelix/utils/jFilter.class.php (added)
- trunk/lib/simpletest/authentication.php (modified) (1 diff)
- trunk/lib/simpletest/compatibility.php (modified) (7 diffs)
- trunk/lib/simpletest/dumper.php (modified) (20 diffs)
- trunk/lib/simpletest/expectation.php (modified) (1 diff)
- trunk/lib/simpletest/parser.php (modified) (3 diffs)
- trunk/lib/simpletest/reporter.php (modified) (1 diff)
- trunk/lib/simpletest/scorer.php (modified) (1 diff)
- trunk/lib/simpletest/simpletest.php (modified) (9 diffs)
- trunk/lib/simpletest/test_case.php (modified) (1 diff)
- trunk/lib/simpletest/url.php (modified) (35 diffs)
- trunk/lib/simpletest/VERSION (modified) (1 diff)
- trunk/testapp/modules/unittest/classes/unittestservice.class.php (modified) (1 diff)
- trunk/testapp/modules/unittest/classes/utfilter.class.php (added)
- trunk/testapp/modules/unittest/controllers/default.classic.php (modified) (1 diff)
- trunk/testapp/modules/unittest/templates/menu.tpl (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/build/manifests/jelix-lib.mn
r288 r289 187 187 jMailer.class.php 188 188 jSmtp.class.php 189 * jFilter.class.php 189 190 190 191 cd lib/json trunk/build/manifests/testapp.mn
r276 r289 64 64 utdao2.class.php 65 65 utdao_conditions.class.php 66 utfilter.class.php 66 67 cd testapp/modules/unittest/locales/fr_FR 67 68 testunit.ISO-8859-1.properties trunk/lib/jelix/core/url/jUrl.class.php
r283 r289 196 196 $url = $this->scriptName.$this->pathInfo; 197 197 if (count ($this->params)>0){ 198 $url .='?'. self::_collapseParams($this->params, $forxml);198 $url .='?'.http_build_query($this->params, '', ($forxml?'&':'&')); 199 199 } 200 200 return $url; … … 208 208 */ 209 209 public function collapseParams ($forxml = false) { 210 return self::_collapseParams($this->params, $forxml);210 return http_build_query($this->params, '', ($forxml?'&':'&')); 211 211 } 212 212 … … 223 223 if ($url === false){ 224 224 $url = 'http://'.$_SERVER['HTTP_HOST'].$_SERVER['SCRIPT_NAME'].$GLOBALS['gJCoord']->request->url_path_info.'?'; 225 $url.= self::_collapseParams($_GET,$forxml);225 $url.= http_build_query($_GET, '', ($forxml?'&':'&')); 226 226 } 227 227 return $url; … … 235 235 static function appendToUrlString ($url, $params = array (), $forxml = false){ 236 236 if ((($pos = strpos ( $url, '?')) !== false) && ($pos !== (strlen ($url)-1))){ 237 return $url . ($forxml ? '&' : '&'). jUrl::_collapseParams ($params, $forxml);237 return $url . ($forxml ? '&' : '&').http_build_query($params, '', ($forxml?'&':'&')); 238 238 }else{ 239 return $url . '?'. jUrl::_collapseParams ($params, $forxml);239 return $url . '?'.http_build_query($params, '', ($forxml?'&':'&')); 240 240 } 241 241 } … … 273 273 static function parse($scriptNamePath, $pathinfo, $params ){ 274 274 return jUrl::getEngine()->parse($scriptNamePath,$pathinfo, $params); 275 }276 277 278 /**279 * collapse parameters to generate an url parameters string280 * @param array $params array of parameters281 * @param boolean $forxml if the string has to be html compliant (& for &)282 * @return string the url283 */284 static private function _collapseParams ($params, $forxml = false) {285 $url = '';286 $amp = ($forxml ? '&' : '&');287 foreach ($params as $k=>$v){288 if ($url == ''){289 $url = $k.'='.urlencode($v);290 }else{291 $url .= $amp.$k.'='.urlencode($v);292 }293 }294 return $url;295 275 } 296 276 trunk/lib/simpletest/authentication.php
r276 r289 229 229 * @static 230 230 */ 231 function addBasicHeaders(&$request, $username, $password) {231 static function addBasicHeaders(&$request, $username, $password) { 232 232 if ($username && $password) { 233 233 $request->addHeaderLine( trunk/lib/simpletest/compatibility.php
r275 r289 20 20 * @static 21 21 */ 22 function copy($object) {22 static function copy($object) { 23 23 if (version_compare(phpversion(), '5') >= 0) { 24 24 eval('$copy = clone $object;'); … … 38 38 * @static 39 39 */ 40 function isIdentical($first, $second) {40 static function isIdentical($first, $second) { 41 41 if ($first != $second) { 42 42 return false; … … 56 56 * @static 57 57 */ 58 function _isIdenticalType($first, $second) {58 static function _isIdenticalType($first, $second) { 59 59 if (gettype($first) != gettype($second)) { 60 60 return false; … … 82 82 * @static 83 83 */ 84 function _isArrayOfIdenticalTypes($first, $second) {84 static function _isArrayOfIdenticalTypes($first, $second) { 85 85 if (array_keys($first) != array_keys($second)) { 86 86 return false; … … 105 105 * @static 106 106 */ 107 function isReference(&$first, &$second) {107 static function isReference(&$first, &$second) { 108 108 if (version_compare(phpversion(), '5', '>=') 109 109 && is_object($first)) { … … 133 133 * @static 134 134 */ 135 function isA($object, $class) {135 static function isA($object, $class) { 136 136 if (version_compare(phpversion(), '5') >= 0) { 137 137 if (! class_exists($class, false)) { … … 159 159 * @static 160 160 */ 161 function setTimeout($handle, $timeout) {161 static function setTimeout($handle, $timeout) { 162 162 if (function_exists('stream_set_timeout')) { 163 163 stream_set_timeout($handle, $timeout, 0); trunk/lib/simpletest/dumper.php
r275 r289 12 12 define('TYPE_MATTERS', true); 13 13 } 14 14 15 15 /** 16 16 * Displays variables as text and does diffs. … … 19 19 */ 20 20 class SimpleDumper { 21 21 22 22 /** 23 23 * Renders a variable in a shorter form than print_r(). … … 44 44 return "Unknown"; 45 45 } 46 46 47 47 /** 48 48 * Gets the string representation of a type. … … 96 96 return $this->$method($first, $second, $identical); 97 97 } 98 98 99 99 /** 100 100 * Tests to see if types match. … … 129 129 return ($start > 0 ? "..." : "") . $value . ($start + $size < $length ? "..." : ""); 130 130 } 131 131 132 132 /** 133 133 * Creates a human readable description of the … … 144 144 $this->describeValue($second) . "]"; 145 145 } 146 146 147 147 /** 148 148 * Creates a human readable description of the … … 157 157 return $this->_describeGenericDifference($first, $second); 158 158 } 159 159 160 160 /** 161 161 * Creates a human readable description of the … … 170 170 return $this->_describeGenericDifference($first, $second); 171 171 } 172 172 173 173 /** 174 174 * Creates a human readable description of the … … 191 191 return $message; 192 192 } 193 193 194 194 /** 195 195 * Creates a human readable description of the … … 210 210 abs($first - $second); 211 211 } 212 212 213 213 /** 214 214 * Creates a human readable description of the … … 229 229 abs($first - $second); 230 230 } 231 231 232 232 /** 233 233 * Creates a human readable description of the … … 262 262 return ""; 263 263 } 264 264 265 265 /** 266 266 * Compares two arrays to see if their key lists match. … … 283 283 return ($first_keys == $second_keys); 284 284 } 285 285 286 286 /** 287 287 * Creates a human readable description of the … … 296 296 return $this->_describeGenericDifference($first, $second); 297 297 } 298 298 299 299 /** 300 300 * Creates a human readable description of the … … 315 315 $identical); 316 316 } 317 317 318 318 /** 319 319 * Find the first character position that differs … … 342 342 return $position; 343 343 } 344 344 345 345 /** 346 346 * Sends a formatted dump of a variable to a string. … … 350 350 * @static 351 351 */ 352 function dump($variable) {352 static function dump($variable) { 353 353 ob_start(); 354 354 print_r($variable); … … 365 365 * @static 366 366 */ 367 function getFormattedAssertionLine($stack) {367 static function getFormattedAssertionLine($stack) { 368 368 foreach ($stack as $frame) { 369 369 if (isset($frame['file'])) { … … 380 380 return ''; 381 381 } 382 382 383 383 /** 384 384 * Tries to determine if the method call is an assertion. … … 387 387 * @static 388 388 */ 389 function _stackFrameIsAnAssertion($frame) {389 static function _stackFrameIsAnAssertion($frame) { 390 390 if (($frame['function'] == 'fail') || ($frame['function'] == 'pass')) { 391 391 return true; trunk/lib/simpletest/expectation.php
r276 r289 87 87 * @static 88 88 */ 89 function isExpectation($expectation) {89 static function isExpectation($expectation) { 90 90 return is_object($expectation) && 91 91 SimpleTestCompatibility::isA($expectation, 'SimpleExpectation'); trunk/lib/simpletest/parser.php
r276 r289 587 587 * @static 588 588 */ 589 function &createLexer(&$parser) {589 static function &createLexer(&$parser) { 590 590 $lexer = &new SimpleHtmlLexer($parser); 591 591 return $lexer; … … 697 697 * @static 698 698 */ 699 function decodeHtml($html) {699 static function decodeHtml($html) { 700 700 static $translations; 701 701 if (! isset($translations)) { … … 714 714 * @static 715 715 */ 716 function normalise($html) {716 static function normalise($html) { 717 717 $text = preg_replace('|<!--.*?-->|', '', $html); 718 718 $text = preg_replace('|<img.*?alt\s*=\s*"(.*?)".*?>|', ' \1 ', $text); trunk/lib/simpletest/reporter.php
r276 r289 59 59 * @static 60 60 */ 61 function sendNoCacheHeaders() {61 static function sendNoCacheHeaders() { 62 62 if (! headers_sent()) { 63 63 header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); trunk/lib/simpletest/scorer.php
r276 r289 380 380 * @static 381 381 */ 382 function inCli() {382 static function inCli() { 383 383 return php_sapi_name() == 'cli'; 384 384 } trunk/lib/simpletest/simpletest.php
r275 r289 32 32 * @access public 33 33 */ 34 function getVersion() {34 static function getVersion() { 35 35 $content = file(dirname(__FILE__) . '/VERSION'); 36 36 return trim($content[0]); … … 46 46 * @access public 47 47 */ 48 function ignore($class) {48 static function ignore($class) { 49 49 $registry = &SimpleTest::_getRegistry(); 50 50 $registry['IgnoreList'][strtolower($class)] = true; … … 66 66 * @access public 67 67 */ 68 function ignoreParentsIfIgnored($classes) {68 static function ignoreParentsIfIgnored($classes) { 69 69 $registry = &SimpleTest::_getRegistry(); 70 70 foreach ($classes as $class) { … … 89 89 * @static 90 90 */ 91 function isIgnored($class) {91 static function isIgnored($class) { 92 92 $registry = &SimpleTest::_getRegistry(); 93 93 return isset($registry['IgnoreList'][strtolower($class)]); … … 165 165 * @static 166 166 */ 167 function setCurrent(&$test) {167 static function setCurrent(&$test) { 168 168 $registry = &SimpleTest::_getRegistry(); 169 169 $registry['CurrentTestCase'] = &$test; … … 176 176 * @static 177 177 */ 178 function &getCurrent() {178 static function &getCurrent() { 179 179 $registry = &SimpleTest::_getRegistry(); 180 180 return $registry['CurrentTestCase']; … … 187 187 * @static 188 188 */ 189 function &_getRegistry() {189 static function &_getRegistry() { 190 190 static $registry = false; 191 191 if (! $registry) { … … 201 201 * @static 202 202 */ 203 function _getDefaults() {203 static function _getDefaults() { 204 204 return array( 205 205 'StubBaseClass' => 'SimpleStub', … … 212 212 } 213 213 214 /**215 * @deprecated216 */217 class SimpleTestOptions extends SimpleTest {218 219 /**220 * @deprecated221 */222 function getVersion() {223 return Simpletest::getVersion();224 }225 226 /**227 * @deprecated228 */229 function ignore($class) {230 return Simpletest::ignore($class);231 }232 233 /**234 * @deprecated235 */236 function isIgnored($class) {237 return Simpletest::isIgnored($class);238 }239 240 /**241 * @deprecated242 */243 function setMockBaseClass($mock_base) {244 return Simpletest::setMockBaseClass($mock_base);245 }246 247 /**248 * @deprecated249 */250 function getMockBaseClass() {251 return Simpletest::getMockBaseClass();252 }253 254 /**255 * @deprecated256 */257 function useProxy($proxy, $username = false, $password = false) {258 return Simpletest::useProxy($proxy, $username, $password);259 }260 261 /**262 * @deprecated263 */264 function getDefaultProxy() {265 return Simpletest::getDefaultProxy();266 }267 268 /**269 * @deprecated270 */271 function getDefaultProxyUsername() {272 return Simpletest::getDefaultProxyUsername();273 }274 275 /**276 * @deprecated277 */278 function getDefaultProxyPassword() {279 return Simpletest::getDefaultProxyPassword();280 }281 }282 214 ?> trunk/lib/simpletest/test_case.php
r276 r289 379 379 * @static 380 380 */ 381 function getSize() {381 static function getSize() { 382 382 return 1; 383 383 } trunk/lib/simpletest/url.php
r275 r289 36 36 var $_target; 37 37 var $_raw = false; 38 38 39 39 /** 40 40 * Constructor. Parses URL into sections. … … 58 58 $this->_target = false; 59 59 } 60 60 61 61 /** 62 62 * Extracts the X, Y coordinate pair from an image map. … … 73 73 return array(false, false); 74 74 } 75 75 76 76 /** 77 77 * Extracts the scheme part of an incoming URL. … … 88 88 return false; 89 89 } 90 90 91 91 /** 92 92 * Extracts the username and password from the … … 115 115 return array(false, false); 116 116 } 117 117 118 118 /** 119 119 * Extracts the host part of an incoming URL. … … 144 144 return false; 145 145 } 146 146 147 147 /** 148 148 * Extracts the path information from the incoming … … 160 160 return ''; 161 161 } 162 162 163 163 /** 164 164 * Strips off the request data. … … 175 175 return ''; 176 176 } 177 177 178 178 /** 179 179 * Breaks the request down into an object. … … 194 194 return $request; 195 195 } 196 196 197 197 /** 198 198 * Accessor for protocol part. … … 204 204 return $this->_scheme ? $this->_scheme : $default; 205 205 } 206 206 207 207 /** 208 208 * Accessor for user name. … … 213 213 return $this->_username; 214 214 } 215 215 216 216 /** 217 217 * Accessor for password. … … 222 222 return $this->_password; 223 223 } 224 224 225 225 /** 226 226 * Accessor for hostname and port. … … 232 232 return $this->_host ? $this->_host : $default; 233 233 } 234 234 235 235 /** 236 236 * Accessor for top level domain. … … 242 242 return (isset($path_parts['extension']) ? $path_parts['extension'] : false); 243 243 } 244 244 245 245 /** 246 246 * Accessor for port number. … … 250 250 function getPort() { 251 251 return $this->_port; 252 } 253 252 } 253 254 254 /** 255 255 * Accessor for path. … … 263 263 return $this->_path; 264 264 } 265 265 266 266 /** 267 267 * Accessor for page if any. This may be a … … 276 276 return $matches[1]; 277 277 } 278 278 279 279 /** 280 280 * Gets the path to the page. … … 288 288 return $matches[1]; 289 289 } 290 290 291 291 /** 292 292 * Accessor for fragment at end of URL after the "#". … … 297 297 return $this->_fragment; 298 298 } 299 299 300 300 /** 301 301 * Sets image coordinates. Set to false to clear … … 313 313 $this->_y = (integer)$y; 314 314 } 315 315 316 316 /** 317 317 * Accessor for horizontal image coordinate. … … 322 322 return $this->_x; 323 323 } 324 324 325 325 /** 326 326 * Accessor for vertical image coordinate. … … 331 331 return $this->_y; 332 332 } 333 333 334 334 /** 335 335 * Accessor for current request parameters … … 351 351 return ''; 352 352 } 353 353 354 354 /** 355 355 * Adds an additional parameter to the request. … … 362 362 $this->_request->add($key, $value); 363 363 } 364 364 365 365 /** 366 366 * Adds additional parameters to the request. … … 373 373 $this->_request->merge($parameters); 374 374 } 375 375 376 376 /** 377 377 * Clears down all parameters. … … 382 382 $this->_request = &new SimpleGetEncoding(); 383 383 } 384 384 385 385 /** 386 386 * Gets the frame target if present. Although … … 393 393 return $this->_target; 394 394 } 395 395 396 396 /** 397 397 * Attaches a frame target. … … 403 403 $this->_target = $frame; 404 404 } 405 405 406 406 /** 407 407 * Renders the URL back into a string. … … 426 426 return "$scheme://$identity$host$path$encoded$fragment$coords"; 427 427 } 428 428 429 429 /** 430 430 * Replaces unknown sections to turn a relative … … 457 457 return new SimpleUrl("$scheme://$identity$host$port$path$encoded$fragment$coords"); 458 458 } 459 459 460 460 /** 461 461 * Replaces unknown sections of the path with base parts … … 477 477 return $base->getPath(); 478 478 } 479 479 480 480 /** 481 481 * Simple test to see if a path part is relative. … … 487 487 return (substr($path, 0, 1) != '/'); 488 488 } 489 489 490 490 /** 491 491 * Extracts the username and password for use in rendering … … 500 500 return false; 501 501 } 502 502 503 503 /** 504 504 * Replaces . and .. sections of the path. … … 511 511 return preg_replace('|/\./|', '/', $path); 512 512 } 513 513 514 514 /** 515 515 * A pipe seperated list of all TLDs that result in two part … … 519 519 * @static 520 520 */ 521 function getAllTopLevelDomains() {521 static function getAllTopLevelDomains() { 522 522 return 'com|edu|net|org|gov|mil|int|biz|info|name|pro|aero|coop|museum'; 523 523 } trunk/lib/simpletest/VERSION
r275 r289 1 1.0.1alpha3 1 1.0.1alpha3-jelix trunk/testapp/modules/unittest/classes/unittestservice.class.php
r276 r289 68 68 } 69 69 70 function filterTest(){ 71 $test = jClasses::create("utfilter"); 72 $test->run(new jHtmlRespReporter($this->_rep)); 73 } 74 70 75 } 71 76 ?> trunk/testapp/modules/unittest/controllers/default.classic.php
r250 r289 77 77 } 78 78 79 function testfilter(){ 80 $rep = $this->getResponse('unittest'); 81 $rep->title = 'test unitaires sur jfilter'; 82 83 $ut = jClasses::create("unittestservice"); 84 $ut->init($rep); 85 $ut->filterTest(); 86 87 return $rep; 88 } 79 89 } 80 90 ?> trunk/testapp/modules/unittest/templates/menu.tpl
r276 r289 5 5 <ul> 6 6 <li><a href="?module=unittest&action=testselectoract">selecteurs d'action</a></li> 7 8 7 </ul> 9 8 <h3>jEvent</h3> 10 9 <ul> 11 10 <li><a href="?module=unittest&action=testevent">lancer deux �nements</a></li> 12 13 11 </ul> 14 12 … … 24 22 <li><a href="?module=unittest&action=dao_parser2">Parser (2)</a></li> 25 23 <li><a href="?module=unittest&action=dao_conditions">jDaoConditions</a></li> 24 </ul> 26 25 26 <h3>Utilitaires</h3> 27 <ul> 28 <li><a href="?module=unittest&action=testfilter">jFilter</a></li> 27 29 </ul> 28 30 29 31 30 31 32 <p><a href="?">Retour �'accueil</a></p>
