diff --git a/README b/README index 229448d408804b61b618eb0b04407a514239c8de..7a036732c98d403f8de40ba5ad91e0b53a24cb85 100644 --- a/README +++ b/README @@ -16,7 +16,7 @@ RewriteCond %{QUERY_STRING} !mobile=no$ RewriteCond %{HTTP_COOKIE} !^.*wdn_mobile=no.*$ [NC] # If iPad user, don't auto-redirect to mobile -RewriteCond %{HTTP_USER_AGENT} !ipad [NC] +RewriteCond %{HTTP_USER_AGENT} !iPad [NC] # if the browser accepts these mime-types, it's definitely mobile, or pretending to be RewriteCond %{HTTP_ACCEPT} "text\/vnd\.wap\.wml|application\/vnd\.wap\.xhtml\+xml" [NC,OR] diff --git a/tests/config.sample.php b/tests/config.sample.php new file mode 100644 index 0000000000000000000000000000000000000000..f72a3b39bc05e125df9f1318334e8943173cfde2 --- /dev/null +++ b/tests/config.sample.php @@ -0,0 +1,12 @@ +<?php + +// To run the tests, they must be web-accessible. Set this to the path. +$baseURL = 'http://ucommbieber.unl.edu/workspace/wdnmobile/tests/'; + + +/* + * You also must place the rewrite rules inside .htaccess in rewrittendir. + * + * Be sure to set the redirect url to rewritetarget + * + */ diff --git a/tests/redirected_uas.phpt b/tests/redirected_uas.phpt new file mode 100644 index 0000000000000000000000000000000000000000..d450441b300611af11b58117ba5d4b497b3b6251 --- /dev/null +++ b/tests/redirected_uas.phpt @@ -0,0 +1,37 @@ +--TEST-- +Apache rewrite rules test +--FILE-- +<?php +require_once __DIR__ . '/config.inc.php'; + +$path = parse_url($baseURL, PHP_URL_PATH); + +$redirected_uas = array(); +$redirected_uas[] = 'iPhone'; + +foreach ($redirected_uas as $ua) { + + // Create a stream + $opts = array( + 'http'=>array( + 'max_redirects' => 3, + 'method' => 'GET', + 'user_agent' => $ua, + ) + ); + + $context = stream_context_create($opts); + + // Open the file using the HTTP headers set above + $data = file_get_contents($baseURL . 'rewrittendir/file1.shtml', false, $context); + + if ($data !== $path . 'rewritetarget/index.php?view=proxy&u='.$baseURL.'rewrittendir/file1.shtml') { + echo $data; + } + +} + +?> +===DONE=== +--EXPECT-- +===DONE=== \ No newline at end of file diff --git a/tests/rewrite_rules.phpt b/tests/rewrite_rules.phpt new file mode 100644 index 0000000000000000000000000000000000000000..da1f2d585ab8534bf6203562057377a0f5c80295 --- /dev/null +++ b/tests/rewrite_rules.phpt @@ -0,0 +1,15 @@ +--TEST-- +Apache rewrite rules test +--FILE-- +<?php +require_once __DIR__ . '/config.inc.php'; + +$data = file_get_contents($baseURL . 'rewrittendir/file1.shtml'); +if ($data !== 'rewrittendir/file1.shtml') { + echo $data; +} + +?> +===DONE=== +--EXPECT-- +===DONE=== \ No newline at end of file diff --git a/tests/rewritetarget/index.php b/tests/rewritetarget/index.php new file mode 100644 index 0000000000000000000000000000000000000000..1096be6eec466fd4e17c61110f5f13fa7869c194 --- /dev/null +++ b/tests/rewritetarget/index.php @@ -0,0 +1,3 @@ +<?php +echo $_SERVER['REQUEST_URI']; +?> \ No newline at end of file diff --git a/tests/rewrittendir/file1.shtml b/tests/rewrittendir/file1.shtml new file mode 100644 index 0000000000000000000000000000000000000000..369cd0468b1012022f1f0b5c9e512d3463b3e6d5 --- /dev/null +++ b/tests/rewrittendir/file1.shtml @@ -0,0 +1 @@ +rewrittendir/file1.shtml \ No newline at end of file