我怎样才能让 phpunit 不吞下 error_log 输出?

Zug*_*alt 4 php phpunit error-log

error_log()从PHPUnit的内部运行不写正常的错误日志文件。我想停止它,以便它写入文件,就像我通过浏览器点击 PHP 一样。

<?php

class exampleTest extends PHPUnit_Framework_TestCase {

    public function testSomething() {
        error_log('This will not be written to the error log, but I wish it was!');
        $this->assertEquals(2, 1+1);
    }

}
Run Code Online (Sandbox Code Playgroud)

我目前使用 php 5.5 版,phpunit 3.7 版。这在 osx 和 ubunutu 上都会发生。这在 Windows 7 上不会发生。

Zug*_*alt 6

所以这被证明是从命令行运行 php 没有记录错误的症状(在此处讨论),并通过确保执行 phpunit 的用户对错误日志具有写入权限来解决。

从命令行调用 php 时使用不同的 ini 文件(此处讨论)的事实也在起作用。