]> granicus.if.org Git - php/commitdiff
Skip session_regenerate_id_cookie.phpt when there's no cgi
authorMatteo Beccati <mbeccati@php.net>
Fri, 18 Sep 2015 05:51:46 +0000 (07:51 +0200)
committerMatteo Beccati <mbeccati@php.net>
Fri, 18 Sep 2015 05:51:46 +0000 (07:51 +0200)
ext/session/tests/session_regenerate_id_cookie.phpt

index 80375b60b94396a59f77ace67cc83d9897fb9f0a..442e69bf954de743cdcb5d8f9faa5e3f5fc245c2 100644 (file)
@@ -1,7 +1,15 @@
 --TEST--
 Test session_regenerate_id() function : basic functionality
 --SKIPIF--
-<?php include('skipif.inc'); ?>
+<?php
+
+include('skipif.inc');
+
+require __DIR__.'/../../../sapi/cgi/tests/include.inc';
+
+get_cgi_path() or die('skip no cgi');
+
+?>
 --FILE--
 <?php
 
@@ -13,60 +21,7 @@ Test session_regenerate_id() function : basic functionality
 
 echo "*** Testing session_regenerate_id() : basic functionality for cookie ***\n";
 
-/* Taken from sapi/cgi/tests/include.inc */
-function get_cgi_path() /* {{{ */
-{
-       $php = getenv("TEST_PHP_EXECUTABLE");
-
-       $cli = false;
-       $cgi = false;
-
-       if (file_exists($php) && is_executable($php)) {
-               $version = `$php -n -v`;
-               if (strstr($version, "(cli)")) {
-                       /* that's cli */
-                       $cli = true;
-               } else if (strpos($version, "(cgi")) {
-                       /* that's cgi */
-                       return $php;
-               }
-       }
-
-       if ($cli) {
-               /* trying to guess ... */
-               $php_path = $php;
-               for ($i = 0; $i < 2; $i++) {
-                       $slash_pos = strrpos($php_path, "/");
-                       if ($slash_pos) {
-                               $php_path = substr($php_path, 0, $slash_pos);
-                       } else {
-                               return FALSE;
-                       }
-               }
-
-               if ($php_path && is_dir($php_path) && file_exists($php_path."/cgi/php-cgi") && is_executable($php_path."/cgi/php-cgi")) {
-                       /* gotcha */
-                       return $php_path."/cgi/php-cgi";
-               }
-               return false;
-       }
-       /* uhm? what's that then? */
-       return false;
-}
-/* }}} */
-
-function reset_env_vars() /* {{{ */
-{
-       putenv("REDIRECT_STATUS");
-       putenv("QUERY_STRING");
-       putenv("PATH_TRANSLATED");
-       putenv("SCRIPT_FILENAME");
-       putenv("SERVER_SOFTWARE");
-       putenv("SERVER_NAME");
-       putenv("GATEWAY_INTERFACE");
-       putenv("REQUEST_METHOD");
-}
-/* }}} */
+require __DIR__.'/../../../sapi/cgi/tests/include.inc';
 
 $php = get_cgi_path();
 reset_env_vars();