Skip to content

Commit b7ece8c

Browse files
committed
Revert "Organizes the php scripts used for testing better, so that the whole logic of a unit, server-side and client-side, is contained within the unit itself. Nearly all ajax unit tests take advantage of the new 'framework'. Lots of files got deleted because they became redundant or weren't used anymore."
This reverts commit 228ab3d.
1 parent 6df2900 commit b7ece8c

38 files changed

+1301
-828
lines changed

test/.jshintrc

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -41,15 +41,11 @@
4141
"ajaxTest": true,
4242
"testIframe": true,
4343
"testIframeWithCallback": true,
44-
"createComplexHTML": true,
4544
"createDashboardXML": true,
46-
"createWithFriesXML": true,
4745
"createXMLFragment": true,
4846
"moduleTeardown": true,
49-
"testBar": true,
5047
"testFoo": true,
51-
"url": true,
52-
"service": true,
48+
"url": true,
5349
"t": true,
5450
"q": true,
5551
"amdDefined": true,

test/data/ajax/echo/index.php

Lines changed: 0 additions & 43 deletions
This file was deleted.

test/data/ajax/headers/cache/index.php

Lines changed: 0 additions & 30 deletions
This file was deleted.

test/data/ajax/headers/request/index.php

Lines changed: 0 additions & 12 deletions
This file was deleted.

test/data/ajax/headers/response/index.php

Lines changed: 0 additions & 5 deletions
This file was deleted.

test/data/atom+xml.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
<?php header("Content-type: atom+xml") ?>
2+
<root>
3+
<element />
4+
</root>

test/data/badcall.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
undefined();

test/data/badjson.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{bad: toTheBone}

test/data/cleanScript.html

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
<script>
2+
<!--
3+
ok( true, "script within html comments executed" );
4+
-->
5+
</script>
6+
<script>
7+
<![CDATA[
8+
ok( true, "script within CDATA executed" );
9+
]]>
10+
</script>

test/data/dashboard.xml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<dashboard>
3+
<locations class="foo">
4+
<location for="bar" checked="different">
5+
<infowindowtab>
6+
<tab title="Location"><![CDATA[blabla]]></tab>
7+
<tab title="Users"><![CDATA[blublu]]></tab>
8+
</infowindowtab>
9+
</location>
10+
</locations>
11+
</dashboard>

test/data/echoData.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
<?php echo file_get_contents('php://input'); ?>

test/data/echoQuery.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
<?php echo $_SERVER['QUERY_STRING']; ?>

test/data/errorWithText.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
<?php
2+
3+
header("HTTP/1.0 400 Bad Request");
4+
5+
echo "plain text message";

test/data/etag.php

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
<?php
2+
error_reporting(0);
3+
4+
$ts = $_REQUEST['ts'];
5+
$etag = md5($ts);
6+
7+
$ifNoneMatch = isset($_SERVER['HTTP_IF_NONE_MATCH']) ? stripslashes($_SERVER['HTTP_IF_NONE_MATCH']) : false;
8+
if ($ifNoneMatch == $etag) {
9+
header('HTTP/1.0 304 Not Modified');
10+
die; // stop processing
11+
}
12+
13+
header("Etag: " . $etag);
14+
15+
if ( $ifNoneMatch ) {
16+
echo "OK: " . $etag;
17+
} else {
18+
echo "FAIL";
19+
}
20+
21+
?>

test/data/evalScript.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
ok( "<?php echo $_SERVER['REQUEST_METHOD'] ?>" === "GET", "request method is <?php echo $_SERVER['REQUEST_METHOD'] ?>" );

test/data/headers.php

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
<?php
2+
3+
header( "Sample-Header: Hello World" );
4+
header( "Empty-Header: " );
5+
header( "Sample-Header2: Hello World 2" );
6+
7+
$headers = array();
8+
9+
foreach( $_SERVER as $key => $value ) {
10+
11+
$key = str_replace( "_" , "-" , substr( $key , 0 , 5 ) == "HTTP_" ? substr( $key , 5 ) : $key );
12+
$headers[ $key ] = $value;
13+
14+
}
15+
16+
foreach( explode( "_" , $_GET[ "keys" ] ) as $key ) {
17+
echo "$key: " . @$headers[ strtoupper( $key ) ] . "\n";
18+
}

test/data/if_modified_since.php

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
<?php
2+
error_reporting(0);
3+
4+
$ts = $_REQUEST['ts'];
5+
6+
$ifModifiedSince = isset($_SERVER['HTTP_IF_MODIFIED_SINCE']) ? stripslashes($_SERVER['HTTP_IF_MODIFIED_SINCE']) : false;
7+
if ($ifModifiedSince == $ts) {
8+
header('HTTP/1.0 304 Not Modified');
9+
die; // stop processing
10+
}
11+
12+
header("Last-Modified: " . $ts);
13+
14+
if ( $ifModifiedSince ) {
15+
echo "OK: " . $ts;
16+
} else {
17+
echo "FAIL";
18+
}
19+
20+
?>

test/data/json.php

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<?php
2+
error_reporting(0);
3+
if ( $_REQUEST['header'] ) {
4+
header("Content-type: application/json");
5+
}
6+
7+
$json = $_REQUEST['json'];
8+
if($json) {
9+
echo '[ {"name": "John", "age": 21}, {"name": "Peter", "age": 25 } ]';
10+
} else {
11+
echo '{ "data": {"lang": "en", "length": 25} }';
12+
}
13+
?>

test/data/json_obj.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{ "data": {"lang": "en", "length": 25} }

test/data/jsonp.php

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<?php
2+
error_reporting(0);
3+
$callback = $_REQUEST['callback'];
4+
if ( ! $callback ) {
5+
$callback = explode("?",end(explode("/",$_SERVER['REQUEST_URI'])));
6+
$callback = $callback[0];
7+
}
8+
$json = $_REQUEST['json'];
9+
if($json) {
10+
echo $callback . '([ {"name": "John", "age": 21}, {"name": "Peter", "age": 25 } ])';
11+
} else {
12+
echo $callback . '({ "data": {"lang": "en", "length": 25} })';
13+
}
14+
?>

test/data/name.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
ERROR <script type="text/javascript">ok( true, "name.html retrieved" );</script>

test/data/name.php

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
<?php
2+
error_reporting(0);
3+
$wait = $_REQUEST['wait'];
4+
if($wait) {
5+
sleep($wait);
6+
}
7+
$xml = $_REQUEST['xml'];
8+
if($xml) {
9+
header("Content-type: text/xml");
10+
$result = ($xml == "5-2") ? "3" : "?";
11+
echo "<math><calculation>$xml</calculation><result>$result</result></math>";
12+
die();
13+
}
14+
$name = $_REQUEST['name'];
15+
if($name == 'foo') {
16+
echo "bar";
17+
die();
18+
} else if($name == 'peter') {
19+
echo "pan";
20+
die();
21+
}
22+
23+
echo 'ERROR <script type="text/javascript">ok( true, "name.php executed" );</script>';
24+
?>

test/data/params_html.php

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
<div id="post">
2+
<?php
3+
foreach( $_POST as $key=>$value )
4+
echo "<b id='$key'>$value</b>";
5+
?>
6+
</div>
7+
<div id="get">
8+
<?php
9+
foreach( $_GET as $key=>$value )
10+
echo "<b id='$key'>$value</b>";
11+
?>
12+
</div>

test/data/script.php

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
<?php
2+
error_reporting(0);
3+
if ( $_REQUEST['header'] ) {
4+
if ( $_REQUEST['header'] == "ecma" ) {
5+
header("Content-type: application/ecmascript");
6+
} else {
7+
header("Content-type: text/javascript");
8+
}
9+
}
10+
?>
11+
ok( true, "Script executed correctly." );

test/data/statusText.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
<?php
2+
3+
header( "HTTP/1.0 $_GET[status] $_GET[text]" );
4+
5+
?>

test/data/test.html

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
html text<br/>
2+
<script type="text/javascript">/* <![CDATA[ */
3+
testFoo = "foo"; jQuery('#foo').html('foo');
4+
ok( true, "test.html executed" );
5+
/* ]]> */</script>
6+
<script src="data/test.js"></script>
7+
blabla

test/data/test.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
var testBar = "bar";
2+
jQuery('#ap').html('bar');
3+
ok( true, "test.js executed");

test/data/test.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
html text<br/>
2+
<script type="text/javascript">/* <![CDATA[ */
3+
testFoo = "foo"; jQuery('#foo').html('foo');
4+
ok( true, "test.php executed" );
5+
/* ]]> */</script>
6+
<script src="data/test.js?<?php srand(); echo time() . '' . rand(); ?>"></script>
7+
blabla

test/data/test2.html

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
<script type="text/javascript">
2+
var testFoo = "foo";
3+
jQuery('#foo').html('foo');
4+
ok( true, "test2.html executed" );
5+
</script>

test/data/test3.html

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
<div class="user">This is a user</div>
2+
<div class="user">This is a user</div>
3+
<div class="teacher">This is a teacher</div>

0 commit comments

Comments
 (0)