I know how to set an expected exception while unit testing using PHPUnit's setExpectedException() method and/or its equivalent annotation.
But for some reason I'm not able to do the same while testing some logic around a fopen() here is an example:
class AbstractFileReaderTest extends \PHPUnit_Framework_TestCase
{
public function test_invalidFileException()
{
$filePath = 'incorrect/file/path.csv';
$this->setExpectedException(\Exception::class);
fopen($filePath, "r");
}
}