When error_log()
is run from within phpunit it isn't written to the normal error log file. I'd like to stop this so that it writes to file as if I was hitting PHP via a browser.
<?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);
}
}
I am currently using php version 5.5, phpunit version 3.7. This happens both on osx and ubunutu. This does not happen on Windows 7.
error_log()
, it'll save it to the PHP system logger, probably ends up in the tmp folder of your PHP installation. If you want to save it somewhere else you can specify a path likeerror_log('Your message', 3, '/path/to/log/file');
– Stoverlog_errors = On
anderror_log = "/var/log/php/php_errors.log"
in my php.ini, error_log() writes to that file. However in PHP unit it doesn't. I don't want to have to adjust all of our error_log calls just to work around phpunit. – Consumedlyvar_dump
(or assert) bothlog_errors
anderror_log
in the test to make sure they are what you expect. – Thump