Skip to content
Snippets Groups Projects
Commit b55e8563 authored by Brett Bieber's avatar Brett Bieber
Browse files

Add some tests for the redirect rules.

parent ae107b8d
No related branches found
No related tags found
No related merge requests found
......@@ -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]
......
<?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
*
*/
--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
--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
<?php
echo $_SERVER['REQUEST_URI'];
?>
\ No newline at end of file
rewrittendir/file1.shtml
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment