Skip to content

Commit

Permalink
Add tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Whissi committed Oct 6, 2016
1 parent 26e6bc0 commit 99847d1
Show file tree
Hide file tree
Showing 15 changed files with 181 additions and 0 deletions.
24 changes: 24 additions & 0 deletions tests/001.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
--TEST--
realpath_turbo: Basic tests
--SKIPIF--
<?php
require_once('skipif.inc');
--FILE--
<?php
var_dump(extension_loaded("realpath_turbo"));
var_dump(phpversion("realpath_turbo"));

// Test for https://github.com/Whissi/realpath_turbo/issues/1
ob_start();
phpinfo(INFO_MODULES);
$phpinfo = ob_get_clean();

$testStr_position = strpos($phpinfo, 'realpath_turbo support');
var_dump(($testStr_position !== false && $testStr_position > 42));

echo "Done\n";
--EXPECTF--
bool(true)
string(%d) "%s"
bool(true)
Done
15 changes: 15 additions & 0 deletions tests/010.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
--TEST--
realpath_turbo: Option realpath_turbo.disable_dangerous_functions (disabled; with disable_functions set)
--SKIPIF--
<?php
require_once('skipif.inc');
--INI--
disable_functions=date
realpath_turbo.disable_dangerous_functions=0
--FILE--
<?php
var_dump(ini_get("realpath_turbo.disable_dangerous_functions"));
var_dump(ini_get("disable_functions"));
--EXPECTF--
string(1) "0"
string(4) "date"
15 changes: 15 additions & 0 deletions tests/011.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
--TEST--
realpath_turbo: Option realpath_turbo.disable_dangerous_functions (disabled; without disable_functions set)
--SKIPIF--
<?php
require_once('skipif.inc');
--INI--
disable_functions=
realpath_turbo.disable_dangerous_functions=0
--FILE--
<?php
var_dump(ini_get("realpath_turbo.disable_dangerous_functions"));
var_dump(ini_get("disable_functions"));
--EXPECTF--
string(1) "0"
string(0) ""
15 changes: 15 additions & 0 deletions tests/012.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
--TEST--
realpath_turbo: Option realpath_turbo.disable_dangerous_functions (enabled; with disable_functions set)
--SKIPIF--
<?php
require_once('skipif.inc');
--INI--
disable_functions=date
realpath_turbo.disable_dangerous_functions=1
--FILE--
<?php
var_dump(ini_get("realpath_turbo.disable_dangerous_functions"));
var_dump(ini_get("disable_functions"));
--EXPECTF--
string(1) "1"
string(17) "link,symlink,date"
15 changes: 15 additions & 0 deletions tests/013.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
--TEST--
realpath_turbo: Option realpath_turbo.disable_dangerous_functions (enabled; without disable_functions set)
--SKIPIF--
<?php
require_once('skipif.inc');
--INI--
disable_functions=
realpath_turbo.disable_dangerous_functions=1
--FILE--
<?php
var_dump(ini_get("realpath_turbo.disable_dangerous_functions"));
var_dump(ini_get("disable_functions"));
--EXPECTF--
string(1) "1"
string(12) "link,symlink"
15 changes: 15 additions & 0 deletions tests/020.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
--TEST--
realpath_turbo: Option realpath_turbo.open_basedir (set; without open_basedir set)
--SKIPIF--
<?php
require_once('skipif.inc');
--INI--
open_basedir=
realpath_turbo.open_basedir="/tmp/realpath_turbo-test"
--FILE--
<?php
var_dump(ini_get("realpath_turbo.open_basedir"));
var_dump(ini_get("open_basedir"));
--EXPECTF--
string(24) "/tmp/realpath_turbo-test"
string(24) "/tmp/realpath_turbo-test"
16 changes: 16 additions & 0 deletions tests/021.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
--TEST--
realpath_turbo: Option realpath_turbo.open_basedir (set; with open_basedir already set)
--SKIPIF--
<?php
require_once('skipif.inc');
--INI--
open_basedir="/tmp/previous-value"
realpath_turbo.open_basedir="/tmp/realpath_turbo-test"
--FILE--
<?php
var_dump(ini_get("realpath_turbo.open_basedir"));
var_dump(ini_get("open_basedir"));
--EXPECTF--
Warning: Unknown: open_basedir already set! Please unset open_basedir and only use realpath_turbo.open_basedir option. realpath_turbo will not have any effect when open_basedir is already set. in %s on line %d

Warning: request_startup() for realpath_turbo module failed in %s on line %d
15 changes: 15 additions & 0 deletions tests/022.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
--TEST--
realpath_turbo: Option realpath_turbo.open_basedir (unset; with open_basedir set)
--SKIPIF--
<?php
require_once('skipif.inc');
--INI--
open_basedir="/tmp/open_basedir-already-set"
realpath_turbo.open_basedir=
--FILE--
<?php
var_dump(ini_get("realpath_turbo.open_basedir"));
var_dump(ini_get("open_basedir"));
--EXPECTF--
string(0) ""
string(29) "/tmp/open_basedir-already-set"
19 changes: 19 additions & 0 deletions tests/100.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
--TEST--
realpath_turbo: Basic functionality (disabled)
--SKIPIF--
<?php
require_once('skipif.inc');
--INI--
open_basedir=.
realpath_turbo.open_basedir=
--FILE--
<?php
var_dump(ini_get("realpath_turbo.open_basedir"));
var_dump(ini_get("open_basedir"));
require_once("test_realpath_turbo_effect.php");
--EXPECTF--
string(0) ""
string(1) "."
bool(false)
bool(false)
string(1) "."
19 changes: 19 additions & 0 deletions tests/101.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
--TEST--
realpath_turbo: Basic functionality (enabled)
--SKIPIF--
<?php
require_once('skipif.inc');
--INI--
open_basedir=
realpath_turbo.open_basedir=.
--FILE--
<?php
var_dump(ini_get("realpath_turbo.open_basedir"));
var_dump(ini_get("open_basedir"));
require_once("test_realpath_turbo_effect.php");
--EXPECTF--
string(1) "."
string(1) "."
bool(false)
bool(true)
string(1) "."
2 changes: 2 additions & 0 deletions tests/include1.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
<?php
require_once('include2.php');
2 changes: 2 additions & 0 deletions tests/include2.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
<?php
require_once('include3.php');
3 changes: 3 additions & 0 deletions tests/include3.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<?php
var_dump(count(realpath_cache_get()) > 0);
var_dump(ini_get('open_basedir'));
1 change: 1 addition & 0 deletions tests/skipif.inc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<?php if (!extension_loaded('realpath_turbo')) die('skip realpath_turbo extension not available');?>
5 changes: 5 additions & 0 deletions tests/test_realpath_turbo_effect.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<?php
clearstatcache(true);
var_dump(count(realpath_cache_get()) > 0);

require_once('include1.php');

0 comments on commit 99847d1

Please sign in to comment.