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

javascript - Create websocket without connecting -

how to do line continuation in perl debugger for entering raw multi-line text (EOT)? -

Android SDK Manager freezes after installation of OSX 10.11 El Capitan public Beta -