【发布时间】:2011-06-25 20:58:36
【问题描述】:
这个 .PHPT 测试完成:(from PHPT docs)
文件: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
输出:
Running 1 tests
PASS strtr() function - basic test for strstr()[uploadTest.phpt]
TOTAL TIME: 00:00
1 PASSED TESTS
0 SKIPPED TESTS
但是,当我尝试运行另一个示例测试(例如 sample006.phpt)以及使用 --GET--、--POST--、--POST_RAW-- 等部分的任何其他测试时,测试总是失败。
我的大目标是通过Testing file uploads with PHP 中描述的PHPT 测试PHPUnit 中的文件上传。那篇文章中使用的--POST_RAW-- 示例对我来说也失败了,而其他示例则成功通过。
看起来我有一个本地配置问题,但我不知道我会在哪里找到它。不幸的是,在 Google 中并不多。
我注意到在这些 --POST-- 测试失败和其他常规测试失败之间的一件事是,常规测试失败总是使用脚本的失败输出填充 *.out 文件。失败的--POST-- 测试在*.out 文件中没有任何内容,即使我明确输出文本也是如此。
这些使用 --POST_RAW-- 的示例 PHPT 测试对其他人有效吗?
这是我的系统规格:(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
【问题讨论】:
-
在 PHP 5.3.2-1ubuntu4.7 和 PEAR 1.9.1 上测试对我来说也失败了。 :(
-
尝试使用
php run-tests.php /path/to/test.phpt运行它。您必须在之前设置TEST_PHP_CGI_EXECUTABLE环境变量(或类似的东西)。 -
我认为 --cgi 标志是必需的,但我也会研究那个 env var。
标签: php unit-testing post phpunit phpt