php - How to set expected exception in PHPUnit for incorrect file path in fopen()? -


i know how set expected exception while unit testing using phpunit's setexpectedexception() method and/or equivalent annotation.

but reason i'm not able same while testing logic around fopen() here example:

class abstractfilereadertest extends \phpunit_framework_testcase {     public function test_invalidfileexception()     {         $filepath = 'incorrect/file/path.csv';          $this->setexpectedexception(\exception::class);          fopen($filepath, "r");     } } 

for unit test on file system it's better use vfsstream

vfsstream stream wrapper virtual file system , tests it's cleaner solution write there real file system.


Comments

Popular posts from this blog

java - Andrioid studio start fail: Fatal error initializing 'null' -

android - Gradle sync Error:Configuration with name 'default' not found -

StringGrid issue in Delphi XE8 firemonkey mobile app -