assertFileExists()
assertFileExists(string $filename[, string $message = ''])
Reports an error identified by $message if the file specified by $filename does not exist.
assertFileNotExists() is the inverse of this assertion and takes the same arguments.
Example A.23: Usage of assertFileExists()
<?php
use PHPUnit\Framework\TestCase;
class FileExistsTest extends TestCase
{
public function testFailure()
{
$this->assertFileExists('/path/to/file');
}
}
?>
phpunit FileExistsTest PHPUnit 5.6.0 by Sebastian Bergmann and contributors. F Time: 0 seconds, Memory: 4.75Mb There was 1 failure: 1) FileExistsTest::testFailure Failed asserting that file "/path/to/file" exists. /home/sb/FileExistsTest.php:6 FAILURES! Tests: 1, Assertions: 1, Failures: 1.
Please login to continue.