File tree Expand file tree Collapse file tree 1 file changed +56
-0
lines changed Expand file tree Collapse file tree 1 file changed +56
-0
lines changed Original file line number Diff line number Diff line change
1
+ <?php
2
+ declare (strict_types = 1 );
3
+
4
+ namespace Forensic \FeedParser \Test ;
5
+
6
+ use Forensic \FeedParser \XML ;
7
+ use PHPUnit \Framework \TestCase ;
8
+
9
+ class XMLTest extends TestCase
10
+ {
11
+ private $ _xml = null ;
12
+
13
+ public function setup ()
14
+ {
15
+ $ this ->_xml = new XML ();
16
+ }
17
+
18
+ public function testInitialState ()
19
+ {
20
+ $ this ->assertSame (false , $ this ->_xml ->status ());
21
+ $ this ->assertNull ($ this ->_xml ->document ());
22
+ }
23
+
24
+ public function testErronousDocumentParse ()
25
+ {
26
+ $ xml = <<<'XML'
27
+ <?xml version='1.0' standalone='yes'?>
28
+ <movies>
29
+ <movie>
30
+ <titles>PHP: Behind the Parser</title>
31
+ </movie>
32
+ </movies>
33
+ XML;
34
+ $ this ->_xml ->parse ($ xml );
35
+ $ this ->assertGreaterThan (0 , count ($ this ->_xml ->errors ()));
36
+ $ this ->assertFalse ($ this ->_xml ->status ());
37
+ $ this ->assertNull ($ this ->_xml ->document ());
38
+ }
39
+
40
+ public function testCorrectDocumentParse ()
41
+ {
42
+ $ xml = <<<'XML'
43
+ <?xml version='1.0' standalone='yes'?>
44
+ <movies>
45
+ <movie>
46
+ <titles>PHP: Behind the Parser</titles>
47
+ </movie>
48
+ </movies>
49
+ XML;
50
+ $ this ->_xml ->parse ($ xml );
51
+
52
+ $ this ->assertEquals (0 , count ($ this ->_xml ->errors ()));
53
+ $ this ->assertTrue ($ this ->_xml ->status ());
54
+ $ this ->assertInstanceOf ('DOMDocument ' , $ this ->_xml ->document ());
55
+ }
56
+ }
You can’t perform that action at this time.
0 commit comments