开发者

PHPT - Unable to run sample tests that use --POST_RAW--

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


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


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜