PHPUnit assertFileEquals() Function Last Updated : 17 Aug, 2020 Comments Improve Suggest changes Like Article Like Report The assertFileEquals() function is a builtin function in PHPUnit and is used to assert whether the actual file content is exactly the same as the content of the expected file or not. This assertion will return true in the case if the expected file content is the same as the actual file content else returns false. In case of true the asserted test case got passed else test case got failed. Syntax: assertFileEquals(string $expected, string $actual[, string $message = '']) Parameters: This function accepts three parameters as mentioned above and described below: $expected: This parameter is a string that represents the expected file path.$actual: This parameter is a string that represents the actual file path.$message: This parameter takes a string value. When the test case got failed this string message got displayed as an error message. Below programs illustrate the assertFileEquals() function in PHPUnit: Example 1: PHP <?php use PHPUnit\Framework\TestCase; class GeeksPhpunitTestCase extends TestCase { public function testNegativeTestcaseForassertFileEquals() { $expected = "/home/bittu/php"; $actual = "/home/bittu/Documents"; // Assert function to test whether expected // file content is equal to actual file content or not $this->assertFileEquals( $expected, $actual, "actual file content is not equals to expected file content" ); } } ?> Output: PHPUnit 8.5.8 by Sebastian Bergmann and contributors. F 1 / 1 (100%) Time: 89 ms, Memory: 10.00 MB There was 1 failure: 1) GeeksPhpunitTestCase::testNegativeTestcaseForassertFileEquals actual file content is not equals to expected file content Failed asserting that file "/home/bittu/php" exists. /home/lovely/Documents/php/test.php:17 FAILURES! Tests: 1, Assertions: 1, Failures: 1. Example 2: PHP <?php use PHPUnit\Framework\TestCase; class GeeksPhpunitTestCase extends TestCase { public function testPositiveTestcaseForassertFileEquals() { $expected = "/home/bittu/Documents"; $actual = "/home/bittu/Documents"; // Assert file equal function to test whether expected // file content is equal to actual file content or not $this->assertFileEquals( $expected, $actual, "actual file content is not equals to expected file content" ); } } ?> Output: PHPUnit 8.5.8 by Sebastian Bergmann and contributors. . 1 / 1 (100%) Time: 89 ms, Memory: 10.00 MB OK (1 test, 3 assertions) Reference: https://phpunit.readthedocs.io/en/9.2/assertions.html#assertfileequals Comment More infoAdvertise with us Next Article PHPUnit assertFileEquals() Function S shubham_singh Follow Improve Article Tags : Web Technologies PHP PHP-PHPUnit Similar Reads PHPUnit assertFileNotEquals() Function The assertFileNotEquals() function is a builtin function in PHPUnit and is used to assert whether the actual file content is different from expected file content or not. This assertion will return true in the case if the expected file content is not-equals to actual file content else returns false. 2 min read PHPunit | assertEquals() Function The assertEquals() function is a builtin function in PHPUnit and is used to assert whether the actual obtained value is equals to expected value or not. This assertion will return true in the case if the expected value is the same as the actual value else returns false. In case of true the asserted 2 min read PHPunit | assertNotEquals() Function The assertNotEquals() function is a builtin function in PHPUnit and is used to assert the actual obtained value to be not-equals to expected value. This assertion will return true in the case if the expected value is not-equals to actual value else returns false. In case of true the asserted test ca 2 min read PHPUnit assertFalse() Function The assertFalse() function is a builtin function in PHPUnit and is used to assert the conditional value is true or false. This assertion will return true in the case if the conditional value is true else return false. In case of true the asserted test case got passed else test case got failed. Synta 2 min read PHPUnit assertFileExists() Function The assertFileExists() function is a builtin function in PHPUnit and is used to check whether an file path exists or not. This assertion will return true in the case if given file path exists else return false. In case of true the asserted test case got passed else test case got failed. Syntax: asse 2 min read PHPUnit assertXmlFileEqualsXmlFile() Function The assertXmlFileEqualsXmlFile() function is a builtin function in PHPUnit and is used to assert whether the actual XML file Content is equals to expected XML file content or not. This assertion will return true in the case if the expected XML file content is the same as the actual XML file content 2 min read PHPUnit assertFileIsReadable() Function The assertFileIsReadable() function is a builtin function in PHPUnit and is used to assert whether the assertfile specified is a file name is readable or not. This assertion will return true in the case if either given filename exists and is readable else return false. In case of true the asserted t 2 min read PHPUnit assertLessThanOrEqual() Function The assertLessThanOrEqual() function is a builtin function in PHPUnit and is used to assert whether the actually obtained value is Less than or equal to the expected value or not. This assertion will return true in the case if the actual value is Less than or equal to the expected value else returns 3 min read PHPUnit assertNotFalse() Function The assertNotFalse() function is a builtin function in PHPUnit and is used to assert the conditional value is true. This assertion will return true in the case if the conditional value is true else return false. In case of true, the asserted test case got passed else test case got failed. Syntax : a 2 min read PHPUnit assertFileNotExists() Function The assertFileNotExists() function is a builtin function in PHPUnit and is used to assert whether a file exists at a given path or not. This assertion will return true in the case if the given file path doesnât exist else return false. In case of true the asserted test case got passed else test case 2 min read Like