diff options
Diffstat (limited to 'test/data')
-rw-r--r-- | test/data/errorWithText.php | 5 | ||||
-rw-r--r-- | test/data/headers.php | 16 | ||||
-rw-r--r-- | test/data/jsonp.php | 4 | ||||
-rw-r--r-- | test/data/params_html.php | 6 | ||||
-rw-r--r-- | test/data/testinit.js | 49 |
5 files changed, 67 insertions, 13 deletions
diff --git a/test/data/errorWithText.php b/test/data/errorWithText.php new file mode 100644 index 000000000..abd873217 --- /dev/null +++ b/test/data/errorWithText.php @@ -0,0 +1,5 @@ +<?php + +header("HTTP/1.0 400 Bad Request"); + +echo "plain text message";
\ No newline at end of file diff --git a/test/data/headers.php b/test/data/headers.php index f2c21c0cc..d500b16f4 100644 --- a/test/data/headers.php +++ b/test/data/headers.php @@ -4,17 +4,13 @@ header( "Sample-Header: Hello World" ); $headers = array(); -foreach( $_SERVER as $key => $value ) { - - if ( substr( $key , 0 , 5 ) == "HTTP_" ) { - - $key = str_replace( "_" , "-" , substr( $key , 5) ); - $headers[ $key ] = $value; +foreach( $_SERVER as $key => $value ) { - } - -} + $key = str_replace( "_" , "-" , substr( $key , 0 , 5 ) == "HTTP_" ? substr( $key , 5 ) : $key ); + $headers[ $key ] = $value; + +} foreach( explode( "_" , $_GET[ "keys" ] ) as $key ) { - echo "$key: " . $headers[ strtoupper( $key ) ] . "\n"; + echo "$key: " . @$headers[ strtoupper( $key ) ] . "\n"; } diff --git a/test/data/jsonp.php b/test/data/jsonp.php index 9ae1d8487..6c13d72e9 100644 --- a/test/data/jsonp.php +++ b/test/data/jsonp.php @@ -1,6 +1,10 @@ <?php error_reporting(0); $callback = $_REQUEST['callback']; +if ( ! $callback ) { + $callback = explode("?",end(explode("/",$_SERVER['REQUEST_URI']))); + $callback = $callback[0]; +} $json = $_REQUEST['json']; if($json) { echo $callback . '([ {"name": "John", "age": 21}, {"name": "Peter", "age": 25 } ])'; diff --git a/test/data/params_html.php b/test/data/params_html.php index 0bab00f29..e88ef1521 100644 --- a/test/data/params_html.php +++ b/test/data/params_html.php @@ -1,12 +1,12 @@ <div id="post"> -<?php +<?php foreach( $_POST as $key=>$value ) echo "<b id='$key'>$value</b>"; -?> +?> </div> <div id="get"> <?php foreach( $_GET as $key=>$value ) echo "<b id='$key'>$value</b>"; -?> +?> </div>
\ No newline at end of file diff --git a/test/data/testinit.js b/test/data/testinit.js index a66f71d25..c478390d5 100644 --- a/test/data/testinit.js +++ b/test/data/testinit.js @@ -45,3 +45,52 @@ function t(a,b,c) { function url(value) { return value + (/\?/.test(value) ? "&" : "?") + new Date().getTime() + "" + parseInt(Math.random()*100000); } + +(function () { + // Store the old counts so that we only assert on tests that have actually leaked, + // instead of asserting every time a test has leaked sometime in the past + var oldCacheLength = 0, + oldFragmentsLength = 0, + oldTimersLength = 0, + oldActive = 0; + + /** + * Ensures that tests have cleaned up properly after themselves. Should be passed as the + * teardown function on all modules' lifecycle object. + */ + this.moduleTeardown = function () { + var i, fragmentsLength = 0, cacheLength = 0; + + // Allow QUnit.reset to clean up any attached elements before checking for leaks + QUnit.reset(); + + for ( i in jQuery.cache ) { + ++cacheLength; + } + + jQuery.fragments = {}; + + for ( i in jQuery.fragments ) { + ++fragmentsLength; + } + + // Because QUnit doesn't have a mechanism for retrieving the number of expected assertions for a test, + // if we unconditionally assert any of these, the test will fail with too many assertions :| + if ( cacheLength !== oldCacheLength ) { + equals( cacheLength, oldCacheLength, "No unit tests leak memory in jQuery.cache" ); + oldCacheLength = cacheLength; + } + if ( fragmentsLength !== oldFragmentsLength ) { + equals( fragmentsLength, oldFragmentsLength, "No unit tests leak memory in jQuery.fragments" ); + oldFragmentsLength = fragmentsLength; + } + if ( jQuery.timers.length !== oldTimersLength ) { + equals( jQuery.timers.length, oldTimersLength, "No timers are still running" ); + oldTimersLength = jQuery.timers.length; + } + if ( jQuery.active !== oldActive ) { + equals( jQuery.active, 0, "No AJAX requests are still active" ); + oldActive = jQuery.active; + } + } +}());
\ No newline at end of file |