From a8d1fb52d1dadbd6d4aa4ea50f6f27a967030aa4 Mon Sep 17 00:00:00 2001 From: Florian Pritz Date: Thu, 5 Feb 2015 21:38:22 +0100 Subject: Add Test-More Signed-off-by: Florian Pritz --- .../third_party/test-more-php/Test-More-OO.php | 441 +++++++++++++++++++++ .../third_party/test-more-php/Test-More.php | 41 ++ .../third_party/test-more-php/Test-Simple-OO.php | 232 +++++++++++ .../third_party/test-more-php/Test-Simple.php | 18 + .../third_party/test-more-php/t/PHProvable.pl | 35 ++ application/third_party/test-more-php/t/badlib.php | 5 + .../third_party/test-more-php/t/borklib.php | 5 + .../third_party/test-more-php/t/goodlib.php | 5 + .../third_party/test-more-php/t/goodpage.php | 5 + .../t/testertests_bail_badplan_negative.php | 9 + .../t/testertests_bail_badplan_noninteger.php | 9 + .../test-more-php/t/testertests_bundle.php | 42 ++ .../t/testertests_deprecated_comparisons.php | 27 ++ .../t/testertests_deprecated_comparisons.pl | 25 ++ .../test-more-php/t/testertests_exit_0.php | 8 + .../test-more-php/t/testertests_exit_fail_260.php | 14 + .../test-more-php/t/testertests_exit_fail_5.php | 14 + .../test-more-php/t/testertests_func_ok.php | 24 ++ .../t/testertests_func_ok.php_Test-More.out | 24 ++ .../t/testertests_func_ok.php_Test-Simple.out | 16 + .../test-more-php/t/testertests_func_ok.pl | 24 ++ .../t/testertests_func_ok.pl_Test-More.out | 24 ++ .../t/testertests_func_ok.pl_Test-Simple.out | 24 ++ .../test-more-php/t/testertests_func_skip.php | 11 + .../test-more-php/t/testertests_func_skip.pl | 9 + .../t/testertests_include_ok_badlib.php | 21 + .../t/testertests_include_ok_fatal.php | 17 + .../test-more-php/t/testertests_interp.php | 10 + .../test-more-php/t/testertests_interp_env.php | 19 + .../test-more-php/t/testertests_interp_set.php | 18 + .../test-more-php/t/testertests_is_deeply.php | 31 ++ .../t/testertests_require_ok_badlib.php | 12 + .../t/testertests_require_ok_borklib.php | 12 + .../t/testertests_require_ok_missing.php | 12 + application/third_party/test-more-php/t/try.php | 7 + 35 files changed, 1250 insertions(+) create mode 100755 application/third_party/test-more-php/Test-More-OO.php create mode 100755 application/third_party/test-more-php/Test-More.php create mode 100755 application/third_party/test-more-php/Test-Simple-OO.php create mode 100755 application/third_party/test-more-php/Test-Simple.php create mode 100755 application/third_party/test-more-php/t/PHProvable.pl create mode 100755 application/third_party/test-more-php/t/badlib.php create mode 100755 application/third_party/test-more-php/t/borklib.php create mode 100755 application/third_party/test-more-php/t/goodlib.php create mode 100755 application/third_party/test-more-php/t/goodpage.php create mode 100755 application/third_party/test-more-php/t/testertests_bail_badplan_negative.php create mode 100755 application/third_party/test-more-php/t/testertests_bail_badplan_noninteger.php create mode 100755 application/third_party/test-more-php/t/testertests_bundle.php create mode 100755 application/third_party/test-more-php/t/testertests_deprecated_comparisons.php create mode 100755 application/third_party/test-more-php/t/testertests_deprecated_comparisons.pl create mode 100755 application/third_party/test-more-php/t/testertests_exit_0.php create mode 100755 application/third_party/test-more-php/t/testertests_exit_fail_260.php create mode 100755 application/third_party/test-more-php/t/testertests_exit_fail_5.php create mode 100755 application/third_party/test-more-php/t/testertests_func_ok.php create mode 100755 application/third_party/test-more-php/t/testertests_func_ok.php_Test-More.out create mode 100755 application/third_party/test-more-php/t/testertests_func_ok.php_Test-Simple.out create mode 100755 application/third_party/test-more-php/t/testertests_func_ok.pl create mode 100755 application/third_party/test-more-php/t/testertests_func_ok.pl_Test-More.out create mode 100755 application/third_party/test-more-php/t/testertests_func_ok.pl_Test-Simple.out create mode 100755 application/third_party/test-more-php/t/testertests_func_skip.php create mode 100755 application/third_party/test-more-php/t/testertests_func_skip.pl create mode 100755 application/third_party/test-more-php/t/testertests_include_ok_badlib.php create mode 100755 application/third_party/test-more-php/t/testertests_include_ok_fatal.php create mode 100755 application/third_party/test-more-php/t/testertests_interp.php create mode 100755 application/third_party/test-more-php/t/testertests_interp_env.php create mode 100755 application/third_party/test-more-php/t/testertests_interp_set.php create mode 100755 application/third_party/test-more-php/t/testertests_is_deeply.php create mode 100755 application/third_party/test-more-php/t/testertests_require_ok_badlib.php create mode 100755 application/third_party/test-more-php/t/testertests_require_ok_borklib.php create mode 100755 application/third_party/test-more-php/t/testertests_require_ok_missing.php create mode 100755 application/third_party/test-more-php/t/try.php (limited to 'application') diff --git a/application/third_party/test-more-php/Test-More-OO.php b/application/third_party/test-more-php/Test-More-OO.php new file mode 100755 index 000000000..195c27b00 --- /dev/null +++ b/application/third_party/test-more-php/Test-More-OO.php @@ -0,0 +1,441 @@ +plan(2); + $t->ok(1 + 1 = 2, 'One plus one equals two'); + $t->ok( doSomethingAndReturnTrue() , 'doSomethingAndReturnTrue() successful'); + + Procedural Example: + require_once('Test-More.php'); + plan(2); + ok(1 + 1 = 2, 'One plus one equals two'); + ok( doSomethingAndReturnTrue() , 'doSomethingAndReturnTrue() successful'); + + From a browser + If you are running Test-Simple on a web server and want slightly more web-readable + output, call the web_output() method/function. + + Updates + Updates will be posted to the Google code page: + http://code.google.com/p/test-more-php/ + + Bugs + Please file bug reports via the Issues tracker at the google code page. + + Acknowledgements + Michael G Schwern: http://search.cpan.org/~mschwern/Test-Simple/ + Chris Shiflet: http://shiflett.org/code/test-more.php + + Author + Copyright RJ Herrick 2009, 2010 + +*/ + +require_once('Test-Simple-OO.php'); + +class TestMore extends TestSimple { + +/* Test-More extensions */ + private $interp; + + function pass ($name = NULL) { + return $this->ok(TRUE, $name); + } + + function fail ($name = NULL) { + return $this->ok(FALSE, $name); + } + + function _compare ($operator, $thing1, $thing2, $name = NULL) { + // Test.php's cmp_ok function accepts coderefs, hmmm + + $result = eval("return (\$thing1 $operator \$thing2);"); + + return $this->ok($result, $name); + } + + function is ($thing1, $thing2, $name = NULL) { + $pass = $this->_compare ('==',$thing1,$thing2,$name); + if (!$pass) { + $this->diag(" got: '$thing1'", + " expected: '$thing2'"); + } + return $pass; + } + + function isnt ($thing1, $thing2, $name = NULL) { + $pass = $this->_compare ('!=',$thing1,$thing2,$name); + if (!$pass) { + $this->diag(" got: '$thing1'", + " expected: '$thing2'"); + } + return $pass; + } + + function like ($string, $pattern, $name = NULL) { + $pass = preg_match($pattern, $string); + + $ok = $this->ok($pass, $name); + + if (!$ok) { + $this->diag(" '$string'"); + $this->diag(" doesn't match '$pattern'"); + } + + return $ok; + } + + function unlike ($string, $pattern, $name = NULL) { + $pass = !preg_match($pattern, $string); + + $ok = $this->ok($pass, $name); + + if (!$ok) { + $this->diag(" '$string'"); + $this->diag(" matches '$pattern'"); + } + + return $ok; + } + + function cmp_ok ($thing1, $operator, $thing2, $name = NULL) { + eval("\$pass = (\$thing1 $operator \$thing2);"); + + ob_start(); + var_dump($thing1); + $_thing1 = trim(ob_get_clean()); + + ob_start(); + var_dump($thing2); + $_thing2 = trim(ob_get_clean()); + + $ok = $this->ok($pass, $name); + + if (!$ok) { + $this->diag(" got: $_thing1"); + $this->diag(" expected: $_thing2"); + } + + return $ok; + } + + function can_ok ($object, $methods) { + $pass = TRUE; + $errors = array(); + if (!is_array($methods)) $methods = array($methods); + + foreach ($methods as $method) { + if (!method_exists($object, $method)) { + $pass = FALSE; + $errors[] = " method_exists(\$object, $method) failed"; + } + } + + $ok = $this->ok($pass, "method_exists(\$object, ...)"); + + if (!$ok) { + $this->diag($errors); + } + + return $ok; + } + + function isa_ok ($object, $expected_class, $object_name = 'The object') { + $got_class = get_class($object); + + if (version_compare(phpversion(), '5', '>=')) { + $pass = ($got_class == $expected_class); + } else { + $pass = ($got_class == strtolower($expected_class)); + } + + if ($pass) { + $ok = $this->ok(TRUE, "$object_name isa $expected_class"); + } else { + $ok = $this->ok(FALSE, "$object_name isn't a '$expected_class' it's a '$got_class'"); + } + + return $ok; + } + + function _include_fatal_error_handler ($buffer) { + + // Finish successfully? Carry on. + if ($buffer === 'included OK') return ''; + + $module = $this->LastModuleTested; + + // Inside ob_start, won't see the output + $this->ok(FALSE,"include $module"); + + $message = trim($buffer); + $unrunmsg = ''; + + if ( is_int($this->NumberOfTests) ) { + $unrun = $this->NumberOfTests - (int)$this->TestsRun; + $plural = $unrun == 1 ? '' : 's'; + $unrunmsg = "# Looks like ${unrun} planned test${plural} never ran.\n"; + } + + $gasp = $this->LastFail . "\n" + . "# Tried to include '$module'\n" + . "# $message\n" + . $unrunmsg + . "# Looks like 1 test aborted before it could finish due to a fatal error!\n" + . "Bail out! Terminating prematurely due to fatal error.\n" + ; + + return $gasp; + } + + function _include_ok ($module,$type) { + $path = null; + $full_path = null; + $retval = 999; + + // Resolve full path, nice to know although only necessary on windows + foreach (explode(PATH_SEPARATOR,get_include_path()) as $prefix) { + // Repeat existance test and find full path + $full_path = realpath($prefix.DIRECTORY_SEPARATOR.$module); + $lines = @file($full_path); + // Stop on success + if ($lines) { + $path = $full_path; + break; + } + } + // Make sure, if we would include it, it's not going to choke on syntax + $error = false; + if ($path) { + @exec('"'.$this->interp().'" -l '.$path, $bunk, $retval); + if ($retval===0) { + // Prep in case we hit error handler + $this->Backtrace = debug_backtrace(); + $this->LastModuleTested = $module; + ob_start(array($this,'_include_fatal_error_handler')); + if ($type === 'include') { + $done = (include $module); + } else if ($type === 'require') { + $done = (require $module); + } else { + $this->bail("Second argument to _include_ok() must be 'require' or 'include'"); + } + echo "included OK"; + ob_end_flush(); + if (!$done) $error = " Unable to $type '$module'"; + } else { + $error = " Syntax check for '$module' failed"; + } + } else { + $error = " Cannot find ${type}d file '$module'"; + } + + $pass = !$retval && $done; + $ok = $this->ok($pass, "$type $module" ); + if ($error) $this->diag($error); + if ($error && $path) $this->diag(" Resolved $module as $full_path"); + return $ok; + } + + function include_ok ($module) { + // Test success of including file, but continue testing if possible even if unable to include + + return $this->_include_ok($module,'include'); + } + + + function require_ok ($module) { + // As include_ok() but exit gracefully if requirement missing + + $ok = $this->_include_ok($module,'require'); + + // Stop testing if we fail a require test + // Not a bail because you asked for it + if ($ok == FALSE) { + $this->diag(" Exiting due to missing requirement."); + exit(); + } + + return $ok; + } + + function skip($why, $num) { + + if ($num < 0) $num = 0; + + $this->Skips += $num; + $this->SkipReason = $why; + + return TRUE; + } + + function eq_array ($thing1, $thing2) { + // Deprecated comparison function provided for compatibility + // Look only at values, order is important + $this->diag(" ! eq_array() is a deprecated comparison function provided for compatibility. Use array_diff() or similar instead."); + return !array_diff($thing1, $thing2); + } + + function eq_hash ($thing1, $thing2) { + // Deprecated comparison function provided for compatibility + // Look at keys and values, order is NOT important + $this->diag(" ! eq_hash() is a deprecated comparison function provided for compatibility. Use array_diff() or similar instead."); + return !array_diff_assoc($thing1, $thing2); + } + + function eq_set ($thing1, $thing2, $name = NULL) { + // Deprecated comparison function provided for compatibility + // Look only at values, duplicates are NOT important + $this->diag(" ! eq_set() is a deprecated comparison function provided for compatibility. Use array_diff() or similar instead."); + $a = $thing1; + sort($a); + $b = $thing2; + sort($b); + return !array_diff($a, $b); + } + + function is_deeply ($thing1, $thing2, $name = NULL) { + + $pass = $this->_compare_deeply($thing1, $thing2, $name); + + $ok = $this->ok($pass,$name); + + if (!$ok) { + foreach(array($thing1,$thing2) as $it){ + ob_start(); + var_dump($it); + $dump = ob_get_clean(); + #$stringified[] = implode("\n#",explode("\n",$dump)); + $stringified[] = str_replace("\n","\n# ",$dump); + } + $this->diag(" wanted: ".$stringified[0]); + $this->diag(" got: ".$stringified[1]); + } + + return $ok; + } + + function isnt_deeply ($thing1, $thing2, $name = NULL) { + + $pass = !$this->_compare_deeply($thing1, $thing2, $name); + + $ok = $this->ok($pass,$name); + + if (!$ok) $this->diag("Structures are identical.\n"); + + return $ok; + } + + function _compare_deeply ($thing1, $thing2) { + + if (is_array($thing1) && is_array($thing2)) { + if ((count($thing1) === count($thing2)) && !array_diff_key($thing1,$thing2)) { + foreach(array_keys($thing1) as $key){ + $pass = $this->_compare_deeply($thing1[$key],$thing2[$key]); + if(!$pass) { + return FALSE; + } + } + return TRUE; + + } else { + return FALSE; + } + + } else { + return $thing1 === $thing2; + } + } + + function todo ($why, $howmany) { + // Marks tests as expected to fail, then runs them anyway + + if ($howmany < 0) $howmany = 0; + + $this->Todo = $howmany; + $this->TodoReason = $why; + + return TRUE; + } + + function todo_skip ($why, $howmany) { + // Marks tests as expected to fail, then skips them, as they are expected to also create fatal errors + + $this->todo($why, $howmany); + $this->skip($why, $howmany); + + return TRUE; + } + + function todo_start ($why) { + // as starting a TODO block in Perl- instead of using todo() to set a number of tests, all + // tests until todo_end are expected to fail and run anyway + + $this->TodoBlock = FALSE; + $this->TodoReason = $why; + + return TRUE; + } + + function todo_end () { + // as ending a SKIP block in Perl + + $this->TodoBlock = FALSE; + unset($this->TodoReason); + + return TRUE; + } + + function interp ($new_interp_command=NULL) { + // Return the command used to invoke the PHP interpreter, such as for exec() + + if ($new_interp_command == NULL && $this->interp == '') { + // In some situations you might need to specify a php interpreter. + if ( isset($_SERVER['PHP']) ) { + $new_interp_command = escapeshellcmd($_SERVER['PHP']); + } else { + $new_interp_command = 'php'; + } + } + if ($new_interp_command != $this->interp) { + $this->interp = $new_interp_command; + + // Check that we can use the interpreter + @exec('"'.$this->interp.'" -v', $bunk, $retval); + if ($retval!==0) $this->bail("Unable to run PHP interpreter with '$this->interp'. Try setting the PHP environmant variable to the path of the interpreter."); + } + + return $this->interp; + } + + +} + +?> diff --git a/application/third_party/test-more-php/Test-More.php b/application/third_party/test-more-php/Test-More.php new file mode 100755 index 000000000..3cdf1ad37 --- /dev/null +++ b/application/third_party/test-more-php/Test-More.php @@ -0,0 +1,41 @@ + diff --git a/application/third_party/test-more-php/Test-Simple-OO.php b/application/third_party/test-more-php/Test-Simple-OO.php new file mode 100755 index 000000000..e91a5645b --- /dev/null +++ b/application/third_party/test-more-php/Test-Simple-OO.php @@ -0,0 +1,232 @@ +plan(2); + $t->ok(1 + 1 = 2, 'One plus one equals two'); + $t->ok( doSomethingAndReturnTrue() , 'doSomethingAndReturnTrue() successful'); + + Procedural Example: + require_once('Test-Simple'); + plan(2); + ok(1 + 1 = 2, 'One plus one equals two'); + ok( doSomethingAndReturnTrue() , 'doSomethingAndReturnTrue() successful'); + + From a browser + If you are running Test-Simple on a web server and want slightly more web-readable + output, call the web_output() method/function. + + Updates + Updates will be posted to the Google code page: + http://code.google.com/p/test-more-php/ + + Bugs + Please file bug reports via the Issues tracker at the google code page. + + Acknowledgements + Michael G Schwern: http://search.cpan.org/~mschwern/Test-Simple/ + Chris Shiflet: http://shiflett.org/code/test-more.php + + Author + Copyright RJ Herrick 2009, 2010 + +*/ + +class TestSimple { + + protected $Results = array('Failed'=>NULL,'Passed'=>NULL); + protected $TestName = array(); + protected $TestsRun = 0; + protected $Skips; + protected $NumberOfTests; + protected $Filter; + + protected $notes; + + function plan ($NumberOfTests = NULL, $SkipReason = '') { + // Get/set intended number of tests + + if ( is_int($this->NumberOfTests) && !is_null($NumberOfTests) ) $this->diag('The plan was already output.'); + + if ( $NumberOfTests === 'no_plan' ) { + // Equivalent to done_testing() at end of test script + $this->NumberOfTests = $NumberOfTests; + return; + } else if ( $NumberOfTests === 'skip_all' ) { + // Equivalent to done_testing() at end of test script + $this->NumberOfTests = $NumberOfTests; + $this->SkipAllReason = $SkipReason; + $this->diag("Skipping all tests: $SkipReason"); + exit(); + } + + // Return current value if no params passed (query to the plan) + if ( !func_num_args() && isset($this->NumberOfTests) ) return $this->NumberOfTests; + + // Number of tests looks acceptable + if (!is_int($NumberOfTests) || 0 > $NumberOfTests) $this->bail( "Number of tests must be a positive integer. You gave it '$NumberOfTests'" ); + + // If just reporting + $skipinfo = ''; + if ($this->NumberOfTests === 'skip_all') $skipinfo = ' # '.$this->SkipAllReason; + + echo "1..${NumberOfTests}${skipinfo}\n"; + $this->NumberOfTests = $NumberOfTests; + + return; + } + + function ok ($Result = NULL, $TestName = NULL) { + // Confirm param 1 is true (in the PHP sense) + // Unload the buffer regularly + if ($this->Filter) { + ob_flush(); + } + + $this->CurrentTestNumber++; + $this->TestsRun++; + + if ($this->Skips) { + $this->Skips--; + $this->TestsSkipped++; + echo('ok '.$this->CurrentTestNumber.' # skip '.$this->SkipReason."\n"); + return TRUE; + } + + if ($this->NumberOfTests === 'skip_all') { + $this->TestsSkipped++; + $this->diag("SKIP '$TestName'"); + echo('ok '.$this->CurrentTestNumber." # skip\n"); + return TRUE; + } + + if ( func_num_args() == 0 ) $this->bail('You must pass ok() a result to evaluate.'); + if ( func_num_args() == 2 ) $this->TestName[$this->CurrentTestNumber] = $TestName; + if ( func_num_args() > 2 ) $this->bail('Wrong number of arguments passed to ok()'); + + $verdict = $Result ? 'Passed' : 'Failed'; + + $this->Results[$verdict]++; + #$this->TestResult[$this->CurrentTestNumber] = $verdict; + + $caption = isset($this->TestName[$this->CurrentTestNumber]) ? $this->TestName[$this->CurrentTestNumber] : ''; + + $title = $this->CurrentTestNumber + . (isset($this->TestName[$this->CurrentTestNumber]) ? (' - '.$this->TestName[$this->CurrentTestNumber]) : ''); + + if ($verdict === 'Passed') { + echo "ok $title\n"; + return TRUE; + + } else { + echo $this->LastFail = "not ok $title\n"; + + $stack = isset($this->Backtrace) ? $this->Backtrace : debug_backtrace(); + $call = array_pop($stack); + $file = basename($call['file']); + $line = $call['line']; + unset($this->Backtrace); + + if ($caption) { + $this->diag(" Failed test '$caption'"," at $file line $line."); + $this->LastFail .= "# Failed test '$caption'\n# at $file line $line."; + } else { + $this->diag(" Failed test at $file line $line."); + $this->LastFail .= "# Failed test at $file line $line."; + } + + return FALSE; + } + } + + function done_testing () { + // Change of plans (if there was one in the first place) + $this->plan((int)$this->TestsRun); + exit(); + } + + function bail ($message = '') { + // Problem running the program + TestSimple::_bail($message); + } + + static function _bail ($message = '') { + echo "Bail out! $message\n"; + exit(255); + } + + function diag() { + // Print a diagnostic comment + $diagnostics = func_get_args(); + $msg = ''; + foreach ($diagnostics as $line) $msg .= "# ".str_replace("\n","\n# ",$line)."\n"; + echo $msg; + if ($this->Filter) ob_flush(); + return $msg; + } + + function __destruct () { + // Parting remarks and proper exit code + + # if ($this->NumberOfTests === 'no_plan') done_testing(); + # if ($this->NumberOfTests === 'skip_all') plan(0); + + if ($this->TestsRun && !isset($this->NumberOfTests)) { + echo "# Tests were run but no plan() was declared and done_testing() was not seen.\n"; + } else { + if ($this->TestsRun !== $this->NumberOfTests) echo("# Looks like you planned ".(int)$this->NumberOfTests .' tests but ran '.(int)$this->TestsRun.".\n"); + + if ($this->Results['Failed']) echo("# Looks like you failed ". $this->Results['Failed'] .' tests of '.(int)$this->TestsRun.".\n"); + } + + // an extension to help debug + if ($this->notes) echo $this->notes; + + if ($this->Filter) ob_end_flush(); + + $retval = ($this->Results['Failed'] > 254) ? 254 : $this->Results['Failed']; + exit($retval); + } + + function web_output($callback = NULL) { + // Basic web formatting (newlines) of output via ob filter + if (isset($callback)) $this->Filter = $callback; + if (!isset($this->Filter)) $this->Filter = create_function('$string','$output = str_replace("\n","
\n",$string); return $output;'); + ob_start($this->Filter); + } + +} + +?> diff --git a/application/third_party/test-more-php/Test-Simple.php b/application/third_party/test-more-php/Test-Simple.php new file mode 100755 index 000000000..5005383df --- /dev/null +++ b/application/third_party/test-more-php/Test-Simple.php @@ -0,0 +1,18 @@ + diff --git a/application/third_party/test-more-php/t/PHProvable.pl b/application/third_party/test-more-php/t/PHProvable.pl new file mode 100755 index 000000000..1d2295895 --- /dev/null +++ b/application/third_party/test-more-php/t/PHProvable.pl @@ -0,0 +1,35 @@ +#!/bin/env perl + +# PHProveable.pl +# +# A wrapper/dummy for +# +# This script allows you to use the prove program with PHP test scripts +# that output TAP, such as those written with Test-Simple or Test-More, +# without requiring that the php test script be writen with a UNIX style +# shebang line pointing to the processor: +# +# #!/bin/env php +# +# USAGE: +# Your PHP test script should be named like this: TESTSCRIPTNAME.t.php. +# You can either copy this file and name it TESTSCRIPTNAME.t or call it +# explicitly as the first and only argument: +# PHProvable.pl TESTSCRIPTNAME.t.php +# The first method means you end up with a stub for each PHP script, +# although on a system with symlinks you can use a symlink instead of +# copying PHProveable: +# ln -s PHPRoveable.pl TESTSCRIPTNAME.t +# The stub method allows you to just run `prove` in a directory and have +# it look for a /t directory, then find your *.t stubs and run them as +# usual. +# +# NOTES: +# Yeah, there are many ways to skin a cat. You could just leave the .php +# off your test script and add the shebang line, but then you can't just +# run the script via CGI without the shebang showing up as extra content, +# and it won't work on windows via the CLI. + +my $script = $ARGV[0] ? $ARGV[0] : "$0.php"; +my $php_interp = $ENV{'PHP'} ? $ENV{'PHP'} : 'php'; +exec("$php_interp $script"); diff --git a/application/third_party/test-more-php/t/badlib.php b/application/third_party/test-more-php/t/badlib.php new file mode 100755 index 000000000..ef7ee536a --- /dev/null +++ b/application/third_party/test-more-php/t/badlib.php @@ -0,0 +1,5 @@ + diff --git a/application/third_party/test-more-php/t/borklib.php b/application/third_party/test-more-php/t/borklib.php new file mode 100755 index 000000000..da1ed4da9 --- /dev/null +++ b/application/third_party/test-more-php/t/borklib.php @@ -0,0 +1,5 @@ + diff --git a/application/third_party/test-more-php/t/goodlib.php b/application/third_party/test-more-php/t/goodlib.php new file mode 100755 index 000000000..5b2140962 --- /dev/null +++ b/application/third_party/test-more-php/t/goodlib.php @@ -0,0 +1,5 @@ + diff --git a/application/third_party/test-more-php/t/goodpage.php b/application/third_party/test-more-php/t/goodpage.php new file mode 100755 index 000000000..ce38cb818 --- /dev/null +++ b/application/third_party/test-more-php/t/goodpage.php @@ -0,0 +1,5 @@ + diff --git a/application/third_party/test-more-php/t/testertests_bail_badplan_negative.php b/application/third_party/test-more-php/t/testertests_bail_badplan_negative.php new file mode 100755 index 000000000..81488367a --- /dev/null +++ b/application/third_party/test-more-php/t/testertests_bail_badplan_negative.php @@ -0,0 +1,9 @@ + diff --git a/application/third_party/test-more-php/t/testertests_bail_badplan_noninteger.php b/application/third_party/test-more-php/t/testertests_bail_badplan_noninteger.php new file mode 100755 index 000000000..843b13d31 --- /dev/null +++ b/application/third_party/test-more-php/t/testertests_bail_badplan_noninteger.php @@ -0,0 +1,9 @@ + diff --git a/application/third_party/test-more-php/t/testertests_bundle.php b/application/third_party/test-more-php/t/testertests_bundle.php new file mode 100755 index 000000000..91bf79569 --- /dev/null +++ b/application/third_party/test-more-php/t/testertests_bundle.php @@ -0,0 +1,42 @@ +', 10, 'cmp_ok() is ok'); + can_ok($__Test, 'plan' ); + isa_ok($__Test, 'TestMore', 'Default Testing object'); + include_ok('t/goodlib.php'); + require_ok('t/goodpage.php'); + + $foo = array(1,'B','third'); + $oof = array('third','B',1); + + $bar = array('q'=>23,'Y'=>42,); + $rab = array('Y'=>42,'q'=>23,); + + is_deeply($foo,$foo,'is_deeply() is ok'); + isnt_deeply($foo,$bar,'isnt_deeply() is ok'); + + /* + function skip($SkipReason, $num) { + function todo ($why, $howmany) { + function todo_skip ($why, $howmany) { + function todo_start ($why) { + function todo_end () { + */ + + diag("Should fail 1 test, testing fail()"); + done_testing(); +?> diff --git a/application/third_party/test-more-php/t/testertests_deprecated_comparisons.php b/application/third_party/test-more-php/t/testertests_deprecated_comparisons.php new file mode 100755 index 000000000..3fb42ee6d --- /dev/null +++ b/application/third_party/test-more-php/t/testertests_deprecated_comparisons.php @@ -0,0 +1,27 @@ +1,1=>'B',2=>'third'); + $oof = array(0=>'third',1=>'B',2=>1); + + + + $bar = array('q'=>23,'Y'=>42,); + $rab = array('Y'=>42,'q'=>23,); + + + + ok(eq_array($foo,$oof),'eq_array() with misordered array is ok'); + ok(eq_array($bar,$rab),'eq_array() with misordered assoc is ok'); + ok(eq_hash($foo,$oof),'eq_hash() with misordered array is ok'); + ok(eq_hash($bar,$rab),'eq_hash() with misordered assoc is ok'); + ok(eq_set($foo,$oof),'eq_set() with misordered array is ok'); + ok(eq_set($bar,$rab),'eq_set() with misordered assoc is ok'); + + done_testing(); + +?> diff --git a/application/third_party/test-more-php/t/testertests_deprecated_comparisons.pl b/application/third_party/test-more-php/t/testertests_deprecated_comparisons.pl new file mode 100755 index 000000000..2bea27ec4 --- /dev/null +++ b/application/third_party/test-more-php/t/testertests_deprecated_comparisons.pl @@ -0,0 +1,25 @@ +#!/bin/env perl + use strict; + use warnings; + use Test::More ('no_plan'); + + diag('Test of deprecated Test::More functions provided for compatibility completeness.'); + + my $foo = [1,'B','third']; + my $oof = ['third','B',1]; + my $foo_h = {0=>1,1=>'B',2=>'third'}; + my $oof_h = {0=>'third',1=>'B',2=>1}; + + my $bar = [23,42,]; + my $rab = [42,23,]; + my $bar_h = {'q'=>23,'Y'=>42,}; + my $rab_h = {'Y'=>42,'q'=>23,}; + + ok(eq_array($foo,$oof),'eq_array() with misordered array is ok'); + ok(eq_array($bar,$rab),'eq_array() with misordered assoc is ok'); + ok(eq_hash($foo_h,$oof_h),'eq_hash() with misordered array is ok'); + ok(eq_hash($bar_h,$rab_h),'eq_hash() with misordered assoc is ok'); + ok(eq_set($foo,$oof),'eq_set() with misordered array is ok'); + ok(eq_set($bar,$rab),'eq_set() with misordered assoc is ok'); + + done_testing(); diff --git a/application/third_party/test-more-php/t/testertests_exit_0.php b/application/third_party/test-more-php/t/testertests_exit_0.php new file mode 100755 index 000000000..7b407016f --- /dev/null +++ b/application/third_party/test-more-php/t/testertests_exit_0.php @@ -0,0 +1,8 @@ + diff --git a/application/third_party/test-more-php/t/testertests_exit_fail_260.php b/application/third_party/test-more-php/t/testertests_exit_fail_260.php new file mode 100755 index 000000000..7737ba0ae --- /dev/null +++ b/application/third_party/test-more-php/t/testertests_exit_fail_260.php @@ -0,0 +1,14 @@ + diff --git a/application/third_party/test-more-php/t/testertests_exit_fail_5.php b/application/third_party/test-more-php/t/testertests_exit_fail_5.php new file mode 100755 index 000000000..4b6596746 --- /dev/null +++ b/application/third_party/test-more-php/t/testertests_exit_fail_5.php @@ -0,0 +1,14 @@ + diff --git a/application/third_party/test-more-php/t/testertests_func_ok.php b/application/third_party/test-more-php/t/testertests_func_ok.php new file mode 100755 index 000000000..1561faf91 --- /dev/null +++ b/application/third_party/test-more-php/t/testertests_func_ok.php @@ -0,0 +1,24 @@ + diff --git a/application/third_party/test-more-php/t/testertests_func_ok.php_Test-More.out b/application/third_party/test-more-php/t/testertests_func_ok.php_Test-More.out new file mode 100755 index 000000000..d06ec52d4 --- /dev/null +++ b/application/third_party/test-more-php/t/testertests_func_ok.php_Test-More.out @@ -0,0 +1,24 @@ +# OK +# (No message for next test) +ok 1 +ok 2 - 1 is ok +ok 3 - TRUE is ok +ok 4 - 'string' is ok +# Not OK +# (No message for next test) +not ok 5 +# Failed test at testertests_func_ok.php line 18. +not ok 6 - 0 is not ok +# Failed test '0 is not ok' +# at testertests_func_ok.php line 19. +not ok 7 - FALSE is not ok +# Failed test 'FALSE is not ok' +# at testertests_func_ok.php line 20. +not ok 8 - '' is not ok +# Failed test ''' is not ok' +# at testertests_func_ok.php line 21. +not ok 9 - NULL is not ok +# Failed test 'NULL is not ok' +# at testertests_func_ok.php line 22. +1..9 +# Looks like you failed 5 tests of 9. diff --git a/application/third_party/test-more-php/t/testertests_func_ok.php_Test-Simple.out b/application/third_party/test-more-php/t/testertests_func_ok.php_Test-Simple.out new file mode 100755 index 000000000..771678b8e --- /dev/null +++ b/application/third_party/test-more-php/t/testertests_func_ok.php_Test-Simple.out @@ -0,0 +1,16 @@ +# OK +# (No message for next test) +ok 1 +ok 2 - 1 is ok +ok 3 - TRUE is ok +ok 4 - 'string' is ok +# Not OK +# (No message for next test) +not ok 5 +not ok 6 - 0 is not ok +not ok 7 - FALSE is not ok +not ok 8 - '' is not ok +not ok 9 - NULL is not ok +1..9 + +# Looks like you failed 5 tests of 9. diff --git a/application/third_party/test-more-php/t/testertests_func_ok.pl b/application/third_party/test-more-php/t/testertests_func_ok.pl new file mode 100755 index 000000000..e87d97bb1 --- /dev/null +++ b/application/third_party/test-more-php/t/testertests_func_ok.pl @@ -0,0 +1,24 @@ +#!/bin/env perl + use strict; + use warnings; + + my $lib = defined($ENV{'TESTLIB'}) ? $ENV{'TESTLIB'} : 'Test::Simple'; + eval "use $lib;"; + + print "# OK\n"; + print "# (No message for next test)\n"; + ok(1); + ok(1,"1 is ok"); + ok( !0,"TRUE is ok"); + ok('string',"'string' is ok"); + + print "# Not OK\n"; + print "# (No message for next test)\n"; + ok(0); + ok(0,"0 is not ok"); + ok( !1,"FALSE is not ok"); + ok('',"'' is not ok"); + ok(undef,"undef is not ok"); + + done_testing(); + diff --git a/application/third_party/test-more-php/t/testertests_func_ok.pl_Test-More.out b/application/third_party/test-more-php/t/testertests_func_ok.pl_Test-More.out new file mode 100755 index 000000000..e72f09462 --- /dev/null +++ b/application/third_party/test-more-php/t/testertests_func_ok.pl_Test-More.out @@ -0,0 +1,24 @@ +# OK +# (No message for next test) +ok 1 +ok 2 - 1 is ok +ok 3 - TRUE is ok +ok 4 - 'string' is ok +# Not OK +# (No message for next test) +not ok 5 +# Failed test at testertests_func_ok.pl line 18. +not ok 6 - 0 is not ok +# Failed test '0 is not ok' +# at testertests_func_ok.pl line 19. +not ok 7 - FALSE is not ok +# Failed test 'FALSE is not ok' +# at testertests_func_ok.pl line 20. +not ok 8 - '' is not ok +# Failed test ''' is not ok' +# at testertests_func_ok.pl line 21. +not ok 9 - undef is not ok +# Failed test 'undef is not ok' +# at testertests_func_ok.pl line 22. +1..9 +# Looks like you failed 5 tests of 9. diff --git a/application/third_party/test-more-php/t/testertests_func_ok.pl_Test-Simple.out b/application/third_party/test-more-php/t/testertests_func_ok.pl_Test-Simple.out new file mode 100755 index 000000000..54c1e576a --- /dev/null +++ b/application/third_party/test-more-php/t/testertests_func_ok.pl_Test-Simple.out @@ -0,0 +1,24 @@ +# OK +# (No message for next test) +ok 1 +ok 2 - 1 is ok +ok 3 - !0 is ok +ok 4 - 'string' is ok +# Not OK +# (No message for next test) +not ok 5 +# Failed test at testertests_func_ok.pl line 17. +not ok 6 - 0 is not ok +# Failed test '0 is not ok' +# at testertests_func_ok.pl line 18. +not ok 7 - !1 is not ok +# Failed test '!1 is not ok' +# at testertests_func_ok.pl line 19. +not ok 8 - '' is not ok +# Failed test ''' is not ok' +# at testertests_func_ok.pl line 20. +not ok 9 - undef is not ok +# Failed test 'undef is not ok' +# at testertests_func_ok.pl line 21. +Undefined subroutine &main::done_testing called at testertests_func_ok.pl line 23. +# Tests were run but no plan was declared and done_testing() was not seen. diff --git a/application/third_party/test-more-php/t/testertests_func_skip.php b/application/third_party/test-more-php/t/testertests_func_skip.php new file mode 100755 index 000000000..1a5f03823 --- /dev/null +++ b/application/third_party/test-more-php/t/testertests_func_skip.php @@ -0,0 +1,11 @@ + diff --git a/application/third_party/test-more-php/t/testertests_func_skip.pl b/application/third_party/test-more-php/t/testertests_func_skip.pl new file mode 100755 index 000000000..4f3c545b0 --- /dev/null +++ b/application/third_party/test-more-php/t/testertests_func_skip.pl @@ -0,0 +1,9 @@ +#!/bin/env perl + use strict; + use warnings; + use Test::More; + plan(tests=>2); + + skip("Test: Skip one",1); + fail("Gets skipped"); + pass("Gets run ok"); diff --git a/application/third_party/test-more-php/t/testertests_include_ok_badlib.php b/application/third_party/test-more-php/t/testertests_include_ok_badlib.php new file mode 100755 index 000000000..52764fb53 --- /dev/null +++ b/application/third_party/test-more-php/t/testertests_include_ok_badlib.php @@ -0,0 +1,21 @@ + diff --git a/application/third_party/test-more-php/t/testertests_include_ok_fatal.php b/application/third_party/test-more-php/t/testertests_include_ok_fatal.php new file mode 100755 index 000000000..982cd5caf --- /dev/null +++ b/application/third_party/test-more-php/t/testertests_include_ok_fatal.php @@ -0,0 +1,17 @@ + diff --git a/application/third_party/test-more-php/t/testertests_interp.php b/application/third_party/test-more-php/t/testertests_interp.php new file mode 100755 index 000000000..f646f81d8 --- /dev/null +++ b/application/third_party/test-more-php/t/testertests_interp.php @@ -0,0 +1,10 @@ +plan(1); + + $t->is( $t->interp(),'php',"interp defaults to php"); + +?> diff --git a/application/third_party/test-more-php/t/testertests_interp_env.php b/application/third_party/test-more-php/t/testertests_interp_env.php new file mode 100755 index 000000000..8c12f0a12 --- /dev/null +++ b/application/third_party/test-more-php/t/testertests_interp_env.php @@ -0,0 +1,19 @@ +plan(1); + + if (strpos(strtoupper($_SERVER['OS']),'WINDOWS') !== FALSE) { + // Should also accept extension + $newinterp = 'php.exe'; + } else { + // Fair guess + $newinterp = '/usr/local/bin/php'; + } + + $_SERVER['PHP'] = $newinterp; + $t->is( $t->interp(),$newinterp,"set valid alternate interp via PHP environment variable ($newinterp)"); + +?> diff --git a/application/third_party/test-more-php/t/testertests_interp_set.php b/application/third_party/test-more-php/t/testertests_interp_set.php new file mode 100755 index 000000000..6e5fa2276 --- /dev/null +++ b/application/third_party/test-more-php/t/testertests_interp_set.php @@ -0,0 +1,18 @@ +plan(1); + + if (strpos(strtoupper($_SERVER['OS']),'WINDOWS') !== FALSE) { + // Should also accept extension + $newinterp = 'php.exe'; + } else { + // Fair guess + $newinterp = '/usr/local/bin/php'; + } + + $t->is( $t->interp($newinterp),$newinterp,"set valid alternate interp by passing arg: interp($newinterp)"); + +?> diff --git a/application/third_party/test-more-php/t/testertests_is_deeply.php b/application/third_party/test-more-php/t/testertests_is_deeply.php new file mode 100755 index 000000000..de30f2b82 --- /dev/null +++ b/application/third_party/test-more-php/t/testertests_is_deeply.php @@ -0,0 +1,31 @@ +1,1=>'abc')); + + diag("Denials:"); + + isnt_deeply(NULL, TRUE, 'NULL !== TRUE'); + isnt_deeply(NULL, FALSE, 'NULL !== FALSE'); + isnt_deeply(NULL, 0, 'NULL !== 0'); + isnt_deeply(NULL, '', "NULL !== ''"); + isnt_deeply(0, FALSE, '0 !== FALSE'); + isnt_deeply(1, TRUE, '1 !== TRUE'); + +?> diff --git a/application/third_party/test-more-php/t/testertests_require_ok_badlib.php b/application/third_party/test-more-php/t/testertests_require_ok_badlib.php new file mode 100755 index 000000000..12d0e8b7e --- /dev/null +++ b/application/third_party/test-more-php/t/testertests_require_ok_badlib.php @@ -0,0 +1,12 @@ + diff --git a/application/third_party/test-more-php/t/testertests_require_ok_borklib.php b/application/third_party/test-more-php/t/testertests_require_ok_borklib.php new file mode 100755 index 000000000..4472ca795 --- /dev/null +++ b/application/third_party/test-more-php/t/testertests_require_ok_borklib.php @@ -0,0 +1,12 @@ + diff --git a/application/third_party/test-more-php/t/testertests_require_ok_missing.php b/application/third_party/test-more-php/t/testertests_require_ok_missing.php new file mode 100755 index 000000000..087d5d0c0 --- /dev/null +++ b/application/third_party/test-more-php/t/testertests_require_ok_missing.php @@ -0,0 +1,12 @@ + diff --git a/application/third_party/test-more-php/t/try.php b/application/third_party/test-more-php/t/try.php new file mode 100755 index 000000000..1ca9c2410 --- /dev/null +++ b/application/third_party/test-more-php/t/try.php @@ -0,0 +1,7 @@ +#!/usr/bin/env php + -- cgit v1.2.3-24-g4f1b