I am writing a unit a test for a method which is supposed to be able to locate a file and write to it. PHPUnit has methods to compare two files, whether it exists or not, however I am not able to find any method to check if the file is non empty, or even better is there a method if file size and updated timestamp can be asserted ?
我正在编写一个单元测试一个方法,该方法应该能够找到一个文件并写入它。 PHPUnit有比较两个文件的方法,无论它是否存在,但是我无法找到任何方法来检查文件是否为非空,或者更好的是有一个方法,如果文件大小和更新的时间戳可以断言?
P.S. I know how to do this using php in-built filesize function. I Just want to know if it is possible in PHPUnit
附:我知道如何使用php内置的filesize函数来做到这一点。我只想知道在PHPUnit中是否可行
1 个解决方案
#1
1
For checking if file is not empty you can use this phpunit method:
要检查文件是否为空,您可以使用此phpunit方法:
$this->assertStringNotEqualsFile('/tmp/file', '');
#1
1
For checking if file is not empty you can use this phpunit method:
要检查文件是否为空,您可以使用此phpunit方法:
$this->assertStringNotEqualsFile('/tmp/file', '');