4

This .PHPT test completes: (from PHPT docs)

File: strtr.phpt

--TEST--
strtr() function - basic test for strstr()
--FILE--
<?php
/* Do not change this test it is a README.TESTING example. */
$trans = array("hello"=>"hi", "hi"=>"hello", "a"=>"A", "world"=>"planet");
var_dump(strtr("# hi all, I said hello world! #", $trans));
?>
--EXPECT--
string(32) "# hello All, I sAid hi planet! #"

$ pear run-tests --cgi strtr.phpt

Output:

Running 1 tests
PASS strtr() function - basic test for strstr()[uploadTest.phpt]
TOTAL TIME: 00:00
1 PASSED TESTS
0 SKIPPED TESTS

However, when I try running another example test, like sample006.phpt, and any other test that uses --GET--, --POST--, --POST_RAW--, etc., sections, the tests always fail.

My Big Picture Goal is to test file uploads in PHPUnit by way of PHPT as described in Testing file uploads with PHP. The --POST_RAW-- example used in that article fails for me as well, whereas the other examples pass successfully.

It would appear I have a local config problem, but I have no idea where I would track this down. Not much in Google, unfortunately.

One thing I've noticed between these --POST-- tests failing, and other regular tests failing, is that the regular test failures always populate the *.out file with the failed output of the script. The --POST-- tests that fail do not have anything in the *.out file, even when I am explicitly outputting text.

Do those example PHPT tests using --POST_RAW-- work for anyone else?

Here are my system specs: (php 5.2, os x 10.6)

$ pear -V
PEAR Version: 1.9.1
PHP Version: 5.2.13
Zend Engine Version: 2.2.0
Running on: Darwin mbp.local 10.6.0 Darwin Kernel Version 10.6.0: Wed Nov 10 18:13:17 PST 2010; root:xnu-1504.9.26~3/RELEASE_I386 i386
Ian
  • 11,920
  • 27
  • 61
  • 77
  • The test fails for me as well on PHP 5.3.2-1ubuntu4.7 with PEAR 1.9.1. :( – David Harkness Feb 12 '11 at 01:01
  • Try running it with `php run-tests.php /path/to/test.phpt`. You will have to set the `TEST_PHP_CGI_EXECUTABLE` env variable (or something to that effect) before. – Artefacto Feb 12 '11 at 17:48
  • the --cgi flag i believe is what is required, but i will look into that env var as well. – Ian Feb 12 '11 at 20:29

2 Answers2

2

You need to have the PHP CGI version for those tests to work.

cweiske
  • 30,033
  • 14
  • 133
  • 194
2

You need to provide the php-cgi executable to the --cgi option. Something like this

pear run-tests --cgi=/usr/bin/php-cgi strtr.phpt or pear run-tests --cgi=php-cgi strtr.phpt

I spent nearly a day trying to figure this out, when I read the pear help run-tests documentation it makes sense now but at the time I completely glossed over the fact that it wanted the executable.