Skip to content

Commit

Permalink
fixes #10901, PHP required for unit tests, but still allow the tests …
Browse files Browse the repository at this point in the history
…to run
  • Loading branch information
mikesherov authored and dmethvin committed Feb 17, 2012
1 parent 6c2b64d commit 7226cf2
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 13 deletions.
11 changes: 8 additions & 3 deletions test/data/include_js.php
Expand Up @@ -69,8 +69,13 @@
?>
*/

hasPHP = false;

// javascript fallback using src files in case this is not run on a PHP server!
var files = [
// please note that this fallback is for convenience only, and is not fully supported
// i.e. don't expect all of the tests to work properly
var baseURL = document.location.href.replace( /\/test\/.+/, "/"),
files = [
"core",
"callbacks",
"deferred",
Expand All @@ -97,5 +102,5 @@
i = 0;

for ( ; i < len; i++ ) {
document.write("<script src=\"../src/" + files[ i ] + ".js\"><"+"/script>");
}
document.write("<script src=\"" + baseURL + "src/" + files[ i ] + ".js\"><"+"/script>");
}
3 changes: 2 additions & 1 deletion test/data/testinit.js
Expand Up @@ -2,6 +2,7 @@ var jQuery = this.jQuery || "jQuery", // For testing .noConflict()
$ = this.$ || "$",
originaljQuery = jQuery,
original$ = $,
hasPHP = true,
amdDefined;

/**
Expand Down Expand Up @@ -117,5 +118,5 @@ function url(value) {
equal( jQuery.active, 0, "No AJAX requests are still active" );
oldActive = jQuery.active;
}
}
};
}());
11 changes: 2 additions & 9 deletions test/unit/ajax.js
@@ -1,11 +1,6 @@
module("ajax", { teardown: moduleTeardown });

// Safari 3 randomly crashes when running these tests,
// but only in the full suite - you can run just the Ajax
// tests and they'll pass
//if ( !jQuery.browser.safari ) {

if ( !isLocal ) {
if ( !isLocal || hasPHP) {

test("jQuery.ajax() - success callbacks", function() {
expect( 8 );
Expand Down Expand Up @@ -2331,6 +2326,4 @@ test("jQuery.ajax - active counter", function() {
ok( jQuery.active == 0, "ajax active counter should be zero: " + jQuery.active );
});

}

//}
}
6 changes: 6 additions & 0 deletions test/unit/core.js
@@ -1,5 +1,11 @@
module("core", { teardown: moduleTeardown });

test("Unit Testing Environment", function () {
expect(2);
ok( hasPHP, "Running Unit tests without PHP is unsupported! The AJAX tests won't run without it and don't expect all tests to pass without it!" );
ok( !isLocal, "Unit tests shouldn't be run from file://, especially in Chrome. If you must test from file:// with Chrome, run it with the --allow-file-access-from-files flag!" );
});

test("Basic requirements", function() {
expect(7);
ok( Array.prototype.push, "Array.push()" );
Expand Down

0 comments on commit 7226cf2

Please sign in to comment.