编程语言
首页 > 编程语言> > 我怎样才能让phpunit不能吞下error_log输出?

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

作者:互联网

当从phpunit中运行error_log()时,它不会写入正常的错误日志文件.我想停止它,以便它写入文件,好像我是通过浏览器访问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);
    }

}

我目前使用的是php 5.5版,phpunit 3.7版.在osx和ubunutu上都会发生这种情况.这不会发生在Windows 7上.

解决方法:

所以这结果是从命令行没有记录错误的PHP运行的症状(讨论here)并且通过确保执行phpunit的用户对错误日志具有写权限来解决.

同样在游戏中是从命令行调用php时使用不同的ini文件(讨论here).

标签:php,phpunit,error-log
来源: https://codeday.me/bug/20190830/1769200.html