Tester\Assert::matchFile PHP Method

matchFile() public static method

Compares results using mask sorted in file.
public static matchFile ( $file, $actual, $description = NULL ) : void
return void
    public static function matchFile($file, $actual, $description = NULL)
    {
        self::$counter++;
        $pattern = @file_get_contents($file);
        // @ is escalated to exception
        if ($pattern === FALSE) {
            throw new \Exception("Unable to read file '{$file}'.");
        } elseif (!is_scalar($actual)) {
            self::fail(self::describe('%1 should match %2', $description), $actual, $pattern);
        } elseif (!self::isMatching($pattern, $actual)) {
            list($pattern, $actual) = self::expandMatchingPatterns($pattern, $actual);
            self::fail(self::describe('%1 should match %2', $description), $actual, $pattern);
        }
    }

Usage Example

Example #1
0
 function testRender()
 {
     Helper::request($this->params);
     ob_start();
     Helper::$grid->render();
     $output = ob_get_clean();
     Assert::matchFile(__DIR__ . "/files/render.expect", $output);
 }
All Usage Examples Of Tester\Assert::matchFile