4242namespace TheSeer \fDOM \Tests {
4343
4444 use TheSeer \fDOM \fDOMDocument ;
45+ use TheSeer \fDOM \fDOMException ;
4546
4647 /**
4748 *
@@ -55,7 +56,7 @@ class fDOMDocumentTest extends \PHPUnit\Framework\TestCase {
5556 */
5657 private $ dom ;
5758
58- public function setUp () {
59+ public function setUp (): void {
5960 $ this ->dom = new fDOMDocument ();
6061 }
6162
@@ -74,66 +75,48 @@ public function testGetDomXPathReturnsXPathObject() {
7475 $ this ->assertInstanceOf ('TheSeer\fDOM\fDOMXpath ' , $ this ->dom ->getDomXPath ());
7576 }
7677
77- /**
78- * @expectedException \TheSeer\fDOM\fDOMException
79- */
8078 public function testAttemptingToLoadAnXMLStringWithAnUndefinedEntityThrowsException () {
79+ $ this ->expectException (fDOMException::class);
8180 $ this ->dom ->loadXML ('<?xml version="1.0" ?><root>&undefined;</root> ' );
8281 }
8382
84- /**
85- * @expectedException \TheSeer\fDOM\fDOMException
86- */
8783 public function testAttemptingToLoadAnEmptyXMLStringThrowsException () {
84+ $ this ->expectException (fDOMException::class);
8885 $ this ->dom ->loadXML ('' );
8986 }
9087
91- /**
92- * @expectedException \TheSeer\fDOM\fDOMException
93- */
9488 public function testAttemptingToLoadWithEmptyFilenameThrowsException () {
89+ $ this ->expectException (fDOMException::class);
9590 $ this ->dom ->load ('' );
9691 }
9792
98- /**
99- * @expectedException \TheSeer\fDOM\fDOMException
100- */
10193 public function testAttemptingToLoadHTMLWithAnEmptyFilenameThrowsException () {
94+ $ this ->expectException (fDOMException::class);
10295 $ this ->dom ->loadHTMLFile ('' );
10396 }
10497
105- /**
106- * @expectedException \TheSeer\fDOM\fDOMException
107- */
10898 public function testAttemptingToLoadHMLWithAnEmptyStringThrowsException () {
99+ $ this ->expectException (fDOMException::class);
109100 $ this ->dom ->loadHTML ('' );
110101 }
111102
112- /**
113- * @expectedException \TheSeer\fDOM\fDOMException
114- */
115103 public function testloadingInvalidXMLStringThrowsException () {
104+ $ this ->expectException (fDOMException::class);
116105 $ this ->dom ->loadXML ('<?xml version="1.0" ?><broken> ' );
117106 }
118107
119- /**
120- * @expectedException \TheSeer\fDOM\fDOMException
121- */
122108 public function testTryingToLoadNonExistingFileThrowsException () {
109+ $ this ->expectException (fDOMException::class);
123110 $ this ->dom ->load ('_does_not_exist.xml ' );
124111 }
125112
126- /**
127- * @expectedException \TheSeer\fDOM\fDOMException
128- */
129113 public function testloadingBrokenXMLFileThrowsException () {
114+ $ this ->expectException (fDOMException::class);
130115 $ this ->dom ->load (__DIR__ . '/_data/broken.xml ' );
131116 }
132117
133- /**
134- * @expectedException \TheSeer\fDOM\fDOMException
135- */
136118 public function testAttemptingToLoadAnXMLFileWithAnUndefinedEntityThrowsException () {
119+ $ this ->expectException (fDOMException::class);
137120 $ this ->dom ->load (__DIR__ . '/_data/undefentity.xml ' );
138121 }
139122
@@ -162,11 +145,9 @@ public function testSaveXMLReturnsCorrectXMLString() {
162145 $ this ->assertEquals ($ xml , $ this ->dom ->saveXML ());
163146 }
164147
165- /**
166- * @expectedException \TheSeer\fDOM\fDOMException
167- */
168148 public function testSaveXMLThrowsExceptionWithReferenceToNodeFromOtherDocument () {
169149 $ dom = new fDOMDocument ();
150+ $ this ->expectException (fDOMException::class);
170151 $ this ->dom ->saveXML ($ dom ->createElement ('foo ' ));
171152 }
172153
@@ -192,10 +173,8 @@ public function testRegisteringANamespaceWithPrefixWorks() {
192173 $ this ->assertAttributeEquals (array ('test ' => 'test:uri ' ), 'prefixes ' , $ this ->dom );
193174 }
194175
195- /**
196- * @expectedException \TheSeer\fDOM\fDOMException
197- */
198176 public function testCreatingElementWithInvalidNameThrowsException () {
177+ $ this ->expectException (fDOMException::class);
199178 $ node = $ this ->dom ->createElement ('in valid ' );
200179 }
201180
@@ -216,9 +195,9 @@ public function testCreatingNewElementByprefix() {
216195
217196 /**
218197 * @covers \TheSeer\fDOM\fDOMDocument::createElementPrefix
219- * @expectedException \TheSeer\fDOM\fDOMException
220198 */
221199 public function testTryingToCreateNewElementByprefixWithUndefinedPrefixThrowsException () {
200+ $ this ->expectException (fDOMException::class);
222201 $ this ->dom ->createElementPrefix ('test ' , 'node ' );
223202 }
224203
@@ -228,10 +207,8 @@ public function testSettingContentUnescapedForNewElementRemainsIntact() {
228207 $ this ->assertEquals ('test & demo ' , $ node ->nodeValue );
229208 }
230209
231- /**
232- * @expectedException \TheSeer\fDOM\fDOMException
233- */
234210 public function testSettingContentUnescapedForNewElementThrowsExceptionOnInvalidEntity () {
211+ $ this ->expectException (fDOMException::class);
235212 $ node = $ this ->dom ->createElement ('test ' , "test & demo " );
236213 }
237214
@@ -246,10 +223,8 @@ public function testSettingContentUnescapedForNewElementWithNamespaceRemainsInta
246223 $ this ->assertEquals ('test & demo ' , $ node ->nodeValue );
247224 }
248225
249- /**
250- * @expectedException \TheSeer\fDOM\fDOMException
251- */
252226 public function testSettingContentUnescapedForNewElementWithNamespaceThrowsExceptionOnInvalidEntity () {
227+ $ this ->expectException (fDOMException::class);
253228 $ node = $ this ->dom ->createElementNS ('test:uri ' , 'test ' , "test & demo " );
254229 }
255230
0 commit comments