public function testNotExistantFile() { try { $tokenizer = new ezcDocumentBBCodeTokenizer(); $tokens = $tokenizer->tokenizeFile(dirname(__FILE__) . '/files/bbcode/tokenizer/not_existant_file.txt'); $this->fail('Expected ezcBaseFileNotFoundException.'); } catch (ezcBaseFileNotFoundException $e) { /* Expected */ } }
/** * @dataProvider getTestDocuments */ public function testParseFile($from, $to) { if (!is_file($to)) { $this->markTestSkipped("Comparision file '{$to}' not yet defined."); } $tokenizer = new ezcDocumentBBCodeTokenizer(); $parser = new ezcDocumentBBCodeParser(); $parser->options->errorReporting = E_PARSE | E_ERROR | E_WARNING; $ast = $parser->parse($tokenizer->tokenizeFile($from)); $expected = (include $to); // Store test file, to have something to compare on failure $tempDir = $this->createTempDir('bbcode_parser_') . '/'; file_put_contents($tempDir . basename($to), "<?php\n\nreturn " . var_export($ast, true) . ";\n\n"); $this->assertEquals($expected, $ast, 'Extracted ast do not match expected ast.'); // Remove tempdir, when nothing failed. $this->removeTempDir(); }