* @since Class available since 0.7 */ class PassInfoFromRewriteToScriptThroughEnvTester extends CustomTester { /** * Constructor. * * @return void */ public function __construct() { $htaccessFile = <<<'EOD' # Testing if we can pass environment variable from .htaccess to script in a RewriteRule # We pass document root, because that can easily be checked by the script RewriteEngine On RewriteRule ^test\.php$ - [E=PASSTHROUGHENV:%{DOCUMENT_ROOT},L] EOD; $phpFile = <<<'EOD' $item) { if (substr($key, -$len) == $envName) { return $item; } } return false; } $result = getEnvPassedInRewriteRule('PASSTHROUGHENV'); if ($result === false) { echo '0'; exit; } echo ($result == $_SERVER['DOCUMENT_ROOT'] ? '1' : '0'); EOD; $test = [ 'subdir' => 'pass-info-from-rewrite-to-script-through-env', 'files' => [ ['.htaccess', $htaccessFile], ['test.php', $phpFile], ], 'request' => 'test.php', 'interpretation' => [ ['success', 'body', 'equals', '1'], ['failure', 'body', 'equals', '0'], ['inconclusive', 'body', 'begins-with', '<' . '?php'], ['inconclusive'] ] ]; parent::__construct($test); } }