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

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

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

html - jQuery UI Sortable - Remove placeholder after item is dropped -