1 | <?php |
||
49 | class RdfaLiteParserTest extends AbstractTest |
||
50 | { |
||
51 | /** |
||
52 | * Test parsing an RDFa Lite HTML file |
||
53 | */ |
||
54 | public function testRdfaLiteHtmlFile() |
||
55 | { |
||
56 | $things = (new RdfaLite())->parseHtmlFile( |
||
57 | dirname(__DIR__).DIRECTORY_SEPARATOR.'Fixtures'.DIRECTORY_SEPARATOR.'article-rdfa-lite.html' |
||
58 | ); |
||
59 | $this->assertArrayEquals( |
||
60 | $this->castArray( |
||
61 | json_decode( |
||
62 | file_get_contents( |
||
63 | dirname(__DIR__).DIRECTORY_SEPARATOR.'Fixtures'.DIRECTORY_SEPARATOR.'article-rdfa-lite.json' |
||
64 | ) |
||
65 | ) |
||
66 | ), |
||
67 | $this->castArray($things) |
||
68 | ); |
||
69 | } |
||
70 | |||
71 | /** |
||
72 | * Test parsing an RDFa Lite HTML file with types / properties as IRIs |
||
73 | */ |
||
74 | public function testRdfaLiteHtmlFileWithIris() |
||
75 | { |
||
76 | $things = (new RdfaLite(true))->parseHtmlFile( |
||
77 | dirname(__DIR__).DIRECTORY_SEPARATOR.'Fixtures'.DIRECTORY_SEPARATOR.'article-rdfa-lite.html' |
||
78 | ); |
||
79 | $this->assertArrayEquals( |
||
80 | $this->castArray( |
||
81 | json_decode( |
||
82 | file_get_contents( |
||
83 | dirname(__DIR__).DIRECTORY_SEPARATOR.'Fixtures'.DIRECTORY_SEPARATOR |
||
84 | .'article-rdfa-lite-iri.json' |
||
85 | ) |
||
86 | ) |
||
87 | ), |
||
88 | $this->castArray($things) |
||
89 | ); |
||
90 | } |
||
91 | |||
92 | /** |
||
93 | * Test parsing an RDFa Lite DOM |
||
94 | */ |
||
95 | public function testRdfaLiteDom() |
||
96 | { |
||
97 | $htmlDomFactory = new HtmlDocumentFactory(); |
||
98 | $dom = $htmlDomFactory->createDocumentFromSource( |
||
99 | file_get_contents( |
||
100 | dirname(__DIR__).DIRECTORY_SEPARATOR.'Fixtures'.DIRECTORY_SEPARATOR.'article-rdfa-lite.html' |
||
101 | ) |
||
102 | ); |
||
103 | $things = (new RdfaLite())->parseDom($dom); |
||
104 | $this->assertArrayEquals( |
||
105 | $this->castArray( |
||
106 | json_decode( |
||
107 | file_get_contents( |
||
108 | dirname(__DIR__).DIRECTORY_SEPARATOR.'Fixtures'.DIRECTORY_SEPARATOR.'article-rdfa-lite.json' |
||
109 | ) |
||
110 | ) |
||
111 | ), |
||
112 | $this->castArray($things) |
||
113 | ); |
||
114 | } |
||
115 | |||
116 | /** |
||
117 | * Test an invalid file |
||
118 | * |
||
119 | * @expectedException \Jkphl\RdfaLiteMicrodata\Ports\Exceptions\RuntimeException |
||
120 | * @expectedExceptionCode 1487190674 |
||
121 | */ |
||
122 | public function testInvalidFile() |
||
126 | |||
127 | /** |
||
128 | * Test an XML runtime exception |
||
129 | * |
||
130 | * @expectedException \Jkphl\RdfaLiteMicrodata\Ports\Exceptions\RuntimeException |
||
131 | */ |
||
132 | public function testHTMLRuntimeException() |
||
138 | |||
139 | /** |
||
140 | * Test an HTML out of bounds exception |
||
141 | * |
||
142 | * @expectedException \Jkphl\RdfaLiteMicrodata\Ports\Exceptions\OutOfBoundsException |
||
143 | */ |
||
144 | public function testHTMLOutOfBoundsException() |
||
150 | |||
151 | /** |
||
152 | * Test parsing an RDFa Lite XML (XHTML) file |
||
153 | */ |
||
154 | public function testRdfaLiteXmlFile() |
||
171 | |||
172 | |||
173 | /** |
||
174 | * Test an XML runtime exception |
||
175 | * |
||
176 | * @expectedException \Jkphl\RdfaLiteMicrodata\Ports\Exceptions\RuntimeException |
||
177 | */ |
||
178 | public function testXMLRuntimeException() |
||
184 | |||
185 | /** |
||
186 | * Test an XML out of bounds exception |
||
187 | * |
||
188 | * @expectedException \Jkphl\RdfaLiteMicrodata\Ports\Exceptions\OutOfBoundsException |
||
189 | */ |
||
190 | public function testXMLOutOfBoundsException() |
||
196 | } |
||
197 |