Skip to content

Commit

Permalink
Made the tests static. A few tests are failing though.
Browse files Browse the repository at this point in the history
  • Loading branch information
balupton committed Mar 30, 2011
1 parent 703124e commit 3d9b69f
Show file tree
Hide file tree
Showing 38 changed files with 1,666 additions and 64 deletions.
22 changes: 16 additions & 6 deletions tests/_header.php → tests.src/_header.php
Original file line number Diff line number Diff line change
@@ -1,18 +1,28 @@
<?php
# Check
if ( empty($_SERVER['REQUEST_URI']) ) {
die('run this in your browser');
}

# Locations
$dir = dirname(__FILE__);
$out = "$dir/../tests";

# Base URL
$relative_url = $_SERVER['REQUEST_URI'];
$relative_url = substr($relative_url,0,strpos($relative_url,'/history.js')).'/history.js/';
$base_url = 'http://'.$_SERVER['HTTP_HOST'].$relative_url;
$tests_url = $base_url.'tests/';

# Dirs
$dirs = array('uncompressed','compressed');
$tests_url = $base_url.'tests';

# Support
$supports = array('html5','html4');
# Compress
$compress = array('uncompressed','compressed');

# Persist
$persists = array('persistant','non-persistant');

# Support
$supports = array('html5','html4');

# Adapter
$adapters = array('jquery','mootools','prototype','zepto');

22 changes: 10 additions & 12 deletions tests/index.php → tests.src/all.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
<?php
# Header
require_once(dirname(__FILE__).'/_header.php');
?><!DOCTYPE html>
<!DOCTYPE html>
<html>
<head>
<title>History.js Test Suite</title>
Expand All @@ -12,7 +9,7 @@
outline:none;
border:none;
}
.dir {
.compress {
padding-bottom:1em;
}
.support {
Expand All @@ -28,8 +25,8 @@
<p>HTML5 Browsers - should pass the HTML4 and HTML5 tests</p>
<p>HTML4 Browsers - should pass the HTML4 tests and fail the HTML5 tests</p>
<?php
foreach ( $dirs as $dir ) :
echo '<div class="dir">';
foreach ( $compress as $compression ) :
echo '<div class="compress">';
foreach ( $supports as $support ) :
echo '<div class="support">';
foreach ( $persists as $persist ) :
Expand All @@ -38,17 +35,18 @@
echo '<div class="adapter">';

# Url
$tests_full_url = $tests_url."${dir}/${support}/${persist}/${adapter}";
$filename = "${compression}-${support}-${persist}-${adapter}.html";
$test_url = $tests_url."/${filename}";

# Titles
# Title
$Support = strtoupper($support);
$Adapter = ucwords($adapter);
$Persist = ucwords($persist);
$Dir = ucwords($dir);
$title = "History.js ${Dir} ${Support} ${Persist} ${Adapter} Test Suite";
$Compression = ucwords($compression);
$title = "History.js ${Compression} ${Support} ${Persist} ${Adapter} Test Suite";

# Render
?><a href="<?=$tests_full_url?>"><?=$title?></a><?php
?><a href="<?=$test_url?>"><?=$title?></a><?php
echo '</div>';
endforeach;
echo '</div>';
Expand Down
53 changes: 11 additions & 42 deletions tests/frame.php → tests.src/each.php
Original file line number Diff line number Diff line change
@@ -1,45 +1,14 @@
<?php
# Header
require_once(dirname(__FILE__).'/_header.php');

# Support
$support = isset($_GET['support']) ? $_GET['support'] : null;
if ( !in_array($support,$supports) ) {
throw new Exception('Unknown support ['.$support.']');
}

# Adapter
$adapter = isset($_GET['adapter']) ? $_GET['adapter'] : null;
if ( !in_array($adapter,$adapters) ) {
throw new Exception('Unknown adapter ['.$adapter.']');
}

# Persist
$persist = isset($_GET['persist']) ? $_GET['persist'] : null;
if ( !in_array($persist,$persists) ) {
throw new Exception('Unknown persist ['.$persist.']');
}

# Dir
$dir = isset($_GET['dir']) ? $_GET['dir'] : null;
if ( !in_array($dir,$dirs) ) {
throw new Exception('Unknown dir ['.$dirs.']');
}

# Url
$tests_full_url = $tests_url."${dir}/${support}/${persist}/${adapter}/";
$filename = "${compression}-${support}-${persist}-${adapter}.html";
$test_url = $tests_url."/${filename}";

# Titles
$Support = strtoupper($support);
$Adapter = ucwords($adapter);
$Persist = ucwords($persist);
$Dir = ucwords($dir);
$title = "History.js ${Dir} ${Support} ${Persist} ${Adapter} Test Suite";

# No Chache
header("Cache-Control: no-store, no-cache, must-revalidate");
header("Cache-Control: post-check=0, pre-check=0", false);
header("Pragma: no-cache");
$Compression = ucwords($compression);
$title = "History.js ${Compression} ${Support} ${Persist} ${Adapter} Test Suite";
?><!DOCTYPE html>
<html>
<head>
Expand All @@ -48,12 +17,12 @@
<meta http-equiv="CACHE-CONTROL" CONTENT="NO-CACHE" />
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
<title><?=$title?></title>
<base href="<?=$tests_url?>" />

<!-- Check -->
<script>
if ( window.document.location.href !== "<?=$tests_full_url?>" ) {
window.document.location.href = "<?=$tests_full_url?>";
var test_url = "<?=$test_url?>";
if ( window.document.location.href !== test_url && window.document.location.href !== test_url.replace(/\.html/,'') ) {
window.document.location.href = test_url;
}
</script>

Expand Down Expand Up @@ -83,12 +52,12 @@

<!-- History.js -->
<?php if ( $persist === 'persistant' ) : ?>
<script src="../scripts/<?=$dir?>/amplify.store.js"></script>
<script src="../scripts/<?=$compression?>/amplify.store.js"></script>
<?php endif; ?>
<script src="../scripts/<?=$dir?>/history.adapter.<?=$adapter?>.js"></script>
<script src="../scripts/<?=$dir?>/history.js"></script>
<script src="../scripts/<?=$compression?>/history.adapter.<?=$adapter?>.js"></script>
<script src="../scripts/<?=$compression?>/history.js"></script>
<?php if ( $support === 'html4' ) : ?>
<script src="../scripts/<?=$dir?>/history.html4.js"></script>
<script src="../scripts/<?=$compression?>/history.html4.js"></script>
<?php endif; ?>

<!-- Tests -->
Expand Down
25 changes: 25 additions & 0 deletions tests.src/index.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<?php
# Header
require_once(dirname(__FILE__).'/_header.php');

# Index
ob_start();
require($dir.'/all.php');
$contents = ob_get_contents();
ob_end_clean();
file_put_contents($out.'/index.html', $contents);

# Each
foreach ( $compress as $compression )
foreach ( $supports as $support )
foreach ( $persists as $persist )
foreach ( $adapters as $adapter ) {
ob_start();
require($dir.'/each.php');
$contents = ob_get_contents();
ob_end_clean();
file_put_contents($out."/${filename}", $contents);
}

# Done
?><html><body><a href="../tests">Tests</a></body></html>
12 changes: 8 additions & 4 deletions tests/.htaccess
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
Options +FollowSymlinks
RewriteEngine On
RewriteBase /

# Clean Adapter
RewriteCond %{REQUEST_FILENAME} !index.php$
RewriteRule ([a-z]+)/([a-z0-9_\-]+)/([a-z0-9_\-]+)/([a-z0-9_\-]+)/?$ products/history.js/tests/frame.php?dir=$1&support=$2&persist=$3&adapter=$4 [NC,L,QSA]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ([^\.]+)$ $1.html [NC,L,QSA]

# To alter the above for your test environment, all you need to do is change "products/history.js" to wherever history.js is located on your webserver. For example for me it's located at "http://localhost/products/history.js" - if for you it is located at "http://localhost/history.js" then you would change "products/history.js" to "history.js"
# Can someone smarter than me make it so:
# http://localhost/history.js/tests/uncompressed-html5-persistant-jquery
# Does not redirect to:
# http://localhost/history.js/tests/uncompressed-html5-persistant-jquery.html
# But still accesses that url
49 changes: 49 additions & 0 deletions tests/compressed-html4-non-persistant-jquery.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Expires" CONTENT="Mon, 06 Jan 1990 00:00:01 GMT" />
<meta http-equiv="PRAGMA" CONTENT="NO-CACHE" />
<meta http-equiv="CACHE-CONTROL" CONTENT="NO-CACHE" />
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
<title>History.js Compressed HTML4 Non-persistant Jquery Test Suite</title>

<!-- Check -->
<script>
if ( window.document.location.href !== "http://localhost/products/history.js/tests/compressed-html4-non-persistant-jquery.html" ) {
window.document.location.href = "http://localhost/products/history.js/tests/compressed-html4-non-persistant-jquery.html";
}
</script>

<!-- Framework -->
<script src="../vendor/jquery.js"></script>

<!-- QUnit -->
<link rel="stylesheet" href="../vendor/qunit/qunit/qunit.css" type="text/css" media="screen">
<script src="../vendor/qunit/qunit/qunit.js"></script>
</head>
<body>
<!-- Elements -->
<h1 id="qunit-header">History.js Compressed HTML4 Non-persistant Jquery Test Suite</h1>
<h2 id="qunit-banner"></h2>
<div id="qunit-testrunner-toolbar"></div>
<h2 id="qunit-userAgent"></h2>
<ol id="qunit-tests"></ol>
<div id="qunit-fixture">test markup</div>
<button onclick="history.back()">back</button><button onclick="history.forward()">forward</button>
<textarea id="log" style="width:100%;height:400px"></textarea>

<!-- FireBug Lite -->
<script>if ( typeof window.console === 'undefined' ) { document.write('<script src=".../vendor/firebug-lite.js"><\/script>'); }</script>

<!-- JSON -->
<script>if ( typeof window.JSON === 'undefined' ) { document.write('<script src="../scripts//Users/balupton/Dropbox/Server/public_html/products/history.js/tests.src/json2.js"><\/script>'); }</script>

<!-- History.js -->
<script src="../scripts/compressed/history.adapter.jquery.js"></script>
<script src="../scripts/compressed/history.js"></script>
<script src="../scripts/compressed/history.html4.js"></script>

<!-- Tests -->
<script src="tests.js"></script>
</body>
</html>
49 changes: 49 additions & 0 deletions tests/compressed-html4-non-persistant-mootools.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Expires" CONTENT="Mon, 06 Jan 1990 00:00:01 GMT" />
<meta http-equiv="PRAGMA" CONTENT="NO-CACHE" />
<meta http-equiv="CACHE-CONTROL" CONTENT="NO-CACHE" />
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
<title>History.js Compressed HTML4 Non-persistant Mootools Test Suite</title>

<!-- Check -->
<script>
if ( window.document.location.href !== "http://localhost/products/history.js/tests/compressed-html4-non-persistant-mootools.html" ) {
window.document.location.href = "http://localhost/products/history.js/tests/compressed-html4-non-persistant-mootools.html";
}
</script>

<!-- Framework -->
<script src="../vendor/mootools.js"></script>

<!-- QUnit -->
<link rel="stylesheet" href="../vendor/qunit/qunit/qunit.css" type="text/css" media="screen">
<script src="../vendor/qunit/qunit/qunit.js"></script>
</head>
<body>
<!-- Elements -->
<h1 id="qunit-header">History.js Compressed HTML4 Non-persistant Mootools Test Suite</h1>
<h2 id="qunit-banner"></h2>
<div id="qunit-testrunner-toolbar"></div>
<h2 id="qunit-userAgent"></h2>
<ol id="qunit-tests"></ol>
<div id="qunit-fixture">test markup</div>
<button onclick="history.back()">back</button><button onclick="history.forward()">forward</button>
<textarea id="log" style="width:100%;height:400px"></textarea>

<!-- FireBug Lite -->
<script>if ( typeof window.console === 'undefined' ) { document.write('<script src=".../vendor/firebug-lite.js"><\/script>'); }</script>

<!-- JSON -->
<script>if ( typeof window.JSON === 'undefined' ) { document.write('<script src="../scripts//Users/balupton/Dropbox/Server/public_html/products/history.js/tests.src/json2.js"><\/script>'); }</script>

<!-- History.js -->
<script src="../scripts/compressed/history.adapter.mootools.js"></script>
<script src="../scripts/compressed/history.js"></script>
<script src="../scripts/compressed/history.html4.js"></script>

<!-- Tests -->
<script src="tests.js"></script>
</body>
</html>
49 changes: 49 additions & 0 deletions tests/compressed-html4-non-persistant-prototype.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Expires" CONTENT="Mon, 06 Jan 1990 00:00:01 GMT" />
<meta http-equiv="PRAGMA" CONTENT="NO-CACHE" />
<meta http-equiv="CACHE-CONTROL" CONTENT="NO-CACHE" />
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
<title>History.js Compressed HTML4 Non-persistant Prototype Test Suite</title>

<!-- Check -->
<script>
if ( window.document.location.href !== "http://localhost/products/history.js/tests/compressed-html4-non-persistant-prototype.html" ) {
window.document.location.href = "http://localhost/products/history.js/tests/compressed-html4-non-persistant-prototype.html";
}
</script>

<!-- Framework -->
<script src="../vendor/prototype.js"></script>

<!-- QUnit -->
<link rel="stylesheet" href="../vendor/qunit/qunit/qunit.css" type="text/css" media="screen">
<script src="../vendor/qunit/qunit/qunit.js"></script>
</head>
<body>
<!-- Elements -->
<h1 id="qunit-header">History.js Compressed HTML4 Non-persistant Prototype Test Suite</h1>
<h2 id="qunit-banner"></h2>
<div id="qunit-testrunner-toolbar"></div>
<h2 id="qunit-userAgent"></h2>
<ol id="qunit-tests"></ol>
<div id="qunit-fixture">test markup</div>
<button onclick="history.back()">back</button><button onclick="history.forward()">forward</button>
<textarea id="log" style="width:100%;height:400px"></textarea>

<!-- FireBug Lite -->
<script>if ( typeof window.console === 'undefined' ) { document.write('<script src=".../vendor/firebug-lite.js"><\/script>'); }</script>

<!-- JSON -->
<script>if ( typeof window.JSON === 'undefined' ) { document.write('<script src="../scripts//Users/balupton/Dropbox/Server/public_html/products/history.js/tests.src/json2.js"><\/script>'); }</script>

<!-- History.js -->
<script src="../scripts/compressed/history.adapter.prototype.js"></script>
<script src="../scripts/compressed/history.js"></script>
<script src="../scripts/compressed/history.html4.js"></script>

<!-- Tests -->
<script src="tests.js"></script>
</body>
</html>
Loading

0 comments on commit 3d9b69f

Please sign in to comment.