Debian Codegraph @

vendor/wikimedia/parsoid/tests/phpunit/Parsoid/ParserTests/TestFileReaderTest.php

raw
1 <?php
2
3 namespace Test\Parsoid\ParserTests;
4
5 use PHPUnit\Framework\TestCase;
6 use Wikimedia\Parsoid\ParserTests\TestFileReader;
7
8 /**
9 * This class aims at testing the TestFileReader (which reads test files)
10 * @coversDefaultClass \Wikimedia\Parsoid\ParserTests\TestFileReader
11 */
12 class TestFileReaderTest extends TestCase {
13
14 /** @covers ::__construct */
15 public function testReadBasicTestFile() {
16 $tf = TestFileReader::read( __DIR__ . '/data/basicTests.txt' );
17 $this->assertCount( 2, $tf->testCases, 'Wrong number of parsed test cases' );
18 $this->assertEquals( [ 'version' => 2 ], $tf->fileOptions, 'Wrong options' );
19 $this->assertNull( $tf->knownFailuresPath, 'Known failure path should be null' );
20 $this->assertNotEquals( $tf->testCases[0]->legacyHtml, $tf->testCases[0]->parsoidHtml,
21 'Expected different HTML for Legacy and Parsoid (two declarations)' );
22 $this->assertEquals( $tf->testCases[1]->legacyHtml, $tf->testCases[1]->parsoidHtml,
23 'Expected same HTML for Legacy and Parsoid (single declaration)' );
24 }
25
26 /** @covers ::__construct */
27 public function testReadWithKnownFailures() {
28 $tf = TestFileReader::read( __DIR__ . '/data/testsWithKnownFailures.txt' );
29 $this->assertEquals( __DIR__ . '/data/testsWithKnownFailures-knownFailures.json',
30 $tf->knownFailuresPath, 'Wrong test known failures file' );
31 $this->assertCount( 0, $tf->testCases[1]->knownFailures,
32 'Expected no known failure read' );
33 $this->assertCount( 2, $tf->testCases[0]->knownFailures,
34 'Expected two known failures read' );
35 }
36
37 /** @covers ::__construct */
38 public function testIllegalVersion() {
39 $this->expectExceptionMessage( 'Duplicate version specification' );
40 TestFileReader::read( __DIR__ . '/data/twoVersionsDecl.txt' );
41 }
42
43 /** @covers ::__construct */
44 public function testNoEndTagInTest() {
45 $this->expectException( 'Wikimedia\WikiPEG\SyntaxError' );
46 TestFileReader::read( __DIR__ . '/data/testNoEndTag.txt' );
47 }
48 }