我正在尝试测试写入函数是否写入日志。问题是该函数在成功时不返回任何内容。我试图通过找出最后修改时间来找到成就。这是我编写的脚本。
/** Log file shows the following entries
*8844 Nov-27 15:41:27 [5356] [0;31m[ERROR] Checking Error Logging...!![0m
*8845 Nov-27 15:41:28 [4492] [0;31m[ERROR] Checking Error Logging...!![0m
*
* */
$errorText = "Checking Error Logging...!!";
$stub = $this->getMockForAbstractClass('Log');
$stub->expects($this->any())
->method('Error');
$BW_lastModified = filemtime(LOG_TEXT_FILE);
$this->assertEmpty($stub->Error($errorText));
$AW_lastModified = filemtime(LOG_TEXT_FILE);
$this->assertGreaterThan($BW_lastModified, $AW_lastModified);
问题是 filemtime(LOG_TEXT_FILE) 返回相同的时间。我什至尝试在调用 Error 函数进行写入/修改之前通过编写 sleep(10) 使执行休眠 10 秒。
任何帮助将非常感激。