1717
1818namespace PhpOffice \Common \Tests ;
1919
20+ use Exception ;
21+ use InvalidArgumentException ;
2022use PhpOffice \Common \XMLReader ;
23+ use PHPUnit \Framework \TestCase ;
2124
2225/**
2326 * Test class for XMLReader
2427 *
2528 * @coversDefaultClass \PhpOffice\Common\XMLReader
2629 */
27- class XMLReaderTest extends \ PHPUnit \ Framework \ TestCase
30+ class XMLReaderTest extends TestCase
2831{
2932 /**
3033 * Test reading XML from string
@@ -58,11 +61,12 @@ public function testDomFromZip(): void
5861
5962 /**
6063 * Test that read from non existing archive throws exception
61- *
62- * @expectedException \Exception
6364 */
6465 public function testThrowsExceptionOnNonExistingArchive (): void
6566 {
67+ $ this ->expectException (Exception::class);
68+ $ this ->expectExceptionMessage ('Cannot find archive file. ' );
69+
6670 $ pathResources = PHPOFFICE_COMMON_TESTS_BASE_DIR . DIRECTORY_SEPARATOR . 'resources ' . DIRECTORY_SEPARATOR . 'files ' . DIRECTORY_SEPARATOR ;
6771
6872 $ reader = new XMLReader ();
@@ -86,7 +90,7 @@ public function testCountElements(): void
8690 public function testReturnNullOnNonExistingNode (): void
8791 {
8892 $ reader = new XMLReader ();
89- $ this ->assertEmpty ( $ reader ->getElements ('/element/children ' ));
93+ $ this ->assertCount ( 0 , $ reader ->getElements ('/element/children ' ));
9094 $ reader ->getDomFromString ('<element><child>AAA</child></element> ' );
9195
9296 $ this ->assertNull ($ reader ->getElement ('/element/children ' ));
@@ -125,11 +129,12 @@ public function testShouldParseXmlWithCustomNamespace(): void
125129
126130 /**
127131 * Test that xpath fails if custom namespace is not registered
128- *
129- * @expectedException \InvalidArgumentException
130132 */
131133 public function testShouldThowExceptionIfTryingToRegisterNamespaceBeforeReadingDoc (): void
132134 {
135+ $ this ->expectException (InvalidArgumentException::class);
136+ $ this ->expectExceptionMessage ('Dom needs to be loaded before registering a namespace ' );
137+
133138 $ reader = new XMLReader ();
134139 $ reader ->registerNamespace ('test ' , 'http://phpword.com/my/custom/namespace ' );
135140 }
0 commit comments