热门标签 | HotTags
当前位置:  开发笔记 > 编程语言 > 正文

有没有办法在PHPUnit中断言文件不为空?-IsthereawaytoassertfileisnotemptyinPHPUnit?

Iamwritingaunitatestforamethodwhichissupposedtobeabletolocateafileandwritetoi

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', '');

推荐阅读
author-avatar
手机用户2502893535
这个家伙很懒,什么也没留下!
PHP1.CN | 中国最专业的PHP中文社区 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved | 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有