I'm trying to test an exception in my code.

```
public function testGetFileThrowsException(){
    $this->expectException(FileNotFoundException::class);
    $file = "db.json";
    $this->review->getData($file);
}

```

The "db.json" file doesn't exist. My goal is tp have the getData() file to throw the FileNotFoundException. Here is the getData() code:

```
public function getData($path){

    if(file_get_contents($path) === false){
        throw new FileNotFoundException;
    }
    return $file;
}

```

The problem is that instead of evaluating to False and throw the exception, the file\_get\_contents function returns:

```
1) CompanyReviewTest::testGetFileThrowsException
file_get_contents(db.json): failed to open stream: No such file or directory

```

So the test doesn't run successfully. Any ideas on why does this happen?