我已经尝试解决这个问题已有一段时间了。
我有2个测试的简单PHPUnit测试用例。运行它时,得到以下输出:
PHPUnit 3.5.14 by Sebastian Bergmann.
.
因此,第一个断言运行并通过。但是,第二个断言会导致某些PHP错误(异常或其他错误),并且PHPUnit会死掉而没有任何有关可能出错的信息。
这是我的phpunit.xml:
<?xml version="1.0" encoding="UTF-8"?>
<phpunit backupGlobals="false"
backupStaticAttributes="false"
colors="false"
convertErrorsToExceptions="true"
convertNoticesToExceptions="true"
convertWarningsToExceptions="true"
processIsolation="false"
stopOnFailure="true"
syntaxCheck="false"
bootstrap="bootstrap.php.cache"
>
<testsuites>
<testsuite name="Portal Test Suite">
<directory>../src/OneSolution/Portal/*Bundle/Tests</directory>
</testsuite>
</testsuites>
</phpunit>
将syntaxCheck
设置为true
不会提供有关该错误的任何其他信息。但是,它会打印两次(在运行任何测试之前),该The filename, directory name, or volume label syntax is incorrect.
???
因此,有谁知道如何使PHPUnit报告这些错误消息(--verbose
选项也无济于事)?
编辑:我发现了导致测试失败的原因。方法名称有误(我猜我太依赖代码辅助了)。但是,这不能解决主要问题。 PHPUnit不会报告任何警告,错误或异常。
参考方案
好的,因此,如果任何人都无法从PHPUnit命令行获取任何内容或输出不完整,请仔细检查您的php.ini
配置指令:
error_reporting
-对于您的开发环境,应设置为E_ALL | E_STRICT
display_errors
-应设置为On
我试图了解如何将MySQL结果转换为JSON格式,以便以后可以在Javascript中使用此JSON来构建HTML表。但是我的代码只是产生大量的空值,我还不明白为什么。$result = mysqli_query($con, "SELECT * FROM Customers"); $test = json_encode($result);…
PHP Count数组元素 - php嗨,有人可以解释为什么这会返回“数组由0个元素组成”。 :$arr = array(1,3,5); $count = count($arr); if ($count = 0) { echo "An array is empty."; } else { echo "An array has $count elements.…
PHP:从函数返回值并直接回显它? - php这可能是一个愚蠢的问题,但是……的PHPfunction get_info() { $something = "test"; return $something; } html<div class="test"><?php echo get_info(); ?></div> 有没有办…
PHP:将数据从二维数组复制到一维数组的最快方法 - php我有一个巨大的二维PHP数组,带有500万行。$t = [ [ "id" => 1, "name" => "foo" ], [ "id" => 2, "name" => "bar" ] ]; 现在,我必须将此数组的I…
PHP str_replace是否具有大于13个字符的限制? - php直到击中第13个字符为止。一旦str_ireplace在cyper数组中击中“ a”,str_ireplace就停止工作。数组的大小有限制吗?请记住,如果键入“ abgf”,我会得到“ nots”,但是如果键入“ abgrf”,我应该得到“ notes”,那么我就会得到“ notrs”。机架使我的大脑无法解决。$_cypher = array("n…