1111use SimpleSAML \XML \Exception \RuntimeException ;
1212use SimpleSAML \XML \Exception \UnparseableXMLException ;
1313
14+ use function sprintf ;
15+
1416class DOMDocumentFactoryTest extends \PHPUnit \Framework \TestCase
1517{
1618 /**
1719 * @group domdocument
1820 * @return void
1921 */
20- public function testNotXmlStringRaisesAnException () : void
22+ public function testNotXmlStringRaisesAnException (): void
2123 {
2224 $ this ->expectException (UnparseableXMLException::class);
2325 DOMDocumentFactory::fromString ('this is not xml ' );
@@ -28,7 +30,7 @@ public function testNotXmlStringRaisesAnException() : void
2830 * @group domdocument
2931 * @return void
3032 */
31- public function testXmlStringIsCorrectlyLoaded () : void
33+ public function testXmlStringIsCorrectlyLoaded (): void
3234 {
3335 $ xml = '<root/> ' ;
3436
@@ -41,7 +43,7 @@ public function testXmlStringIsCorrectlyLoaded() : void
4143 /**
4244 * @return void
4345 */
44- public function testFileThatDoesNotExistIsNotAccepted () : void
46+ public function testFileThatDoesNotExistIsNotAccepted (): void
4547 {
4648 $ this ->expectException (IOException::class);
4749 $ filename = 'DoesNotExist.ext ' ;
@@ -53,7 +55,7 @@ public function testFileThatDoesNotExistIsNotAccepted() : void
5355 * @group domdocument
5456 * @return void
5557 */
56- public function testFileThatDoesNotContainXMLCannotBeLoaded () : void
58+ public function testFileThatDoesNotContainXMLCannotBeLoaded (): void
5759 {
5860 $ this ->expectException (UnparseableXMLException::class);
5961 $ file = realpath (dirname (__FILE__ )) . DIRECTORY_SEPARATOR . 'domdocument_invalid_xml.xml ' ;
@@ -65,7 +67,7 @@ public function testFileThatDoesNotContainXMLCannotBeLoaded() : void
6567 * @group domdocument
6668 * @return void
6769 */
68- public function testFileWithValidXMLCanBeLoaded () : void
70+ public function testFileWithValidXMLCanBeLoaded (): void
6971 {
7072 $ file = realpath (dirname (__FILE__ )) . DIRECTORY_SEPARATOR . 'domdocument_valid_xml.xml ' ;
7173
@@ -79,7 +81,7 @@ public function testFileWithValidXMLCanBeLoaded() : void
7981 * @group domdocument
8082 * @return void
8183 */
82- public function testFileThatContainsDocTypeIsNotAccepted () : void
84+ public function testFileThatContainsDocTypeIsNotAccepted (): void
8385 {
8486 $ this ->expectException (RuntimeException::class, 'Dangerous XML detected, DOCTYPE nodes are not allowed in the XML body ' );
8587 $ file = realpath (dirname (__FILE__ )) . DIRECTORY_SEPARATOR . 'domdocument_doctype.xml ' ;
@@ -93,7 +95,7 @@ public function testFileThatContainsDocTypeIsNotAccepted() : void
9395 * @group domdocument
9496 * @return void
9597 */
96- public function testStringThatContainsDocTypeIsNotAccepted () : void
98+ public function testStringThatContainsDocTypeIsNotAccepted (): void
9799 {
98100 $ this ->expectException (RuntimeException::class, 'Dangerous XML detected, DOCTYPE nodes are not allowed in the XML body ' );
99101 $ xml = '<!DOCTYPE foo [<!ELEMENT foo ANY > <!ENTITY xxe SYSTEM "file:///dev/random" >]><foo /> ' ;
@@ -123,12 +125,12 @@ public function testStringThatContainsDocTypeIsNotAccepted2(): void
123125 * @group domdocument
124126 * @return void
125127 */
126- public function testEmptyFileIsNotValid () : void
128+ public function testEmptyFileIsNotValid (): void
127129 {
128130 $ this ->expectException (RuntimeException::class, 'does not have content ' );
129131 $ file = realpath (dirname (__FILE__ )) . DIRECTORY_SEPARATOR . 'domdocument_empty.xml ' ;
130132 $ this ->expectException (RuntimeException::class);
131- $ this ->expectExceptionMessage ('File "/home/runner/work/saml2/saml2/tests/SAML2/domdocument_empty.xml " does not have content ' );
133+ $ this ->expectExceptionMessage (sprintf ( 'File "%s " does not have content ' , $ file ) );
132134 DOMDocumentFactory::fromFile ($ file );
133135 }
134136
@@ -137,7 +139,7 @@ public function testEmptyFileIsNotValid() : void
137139 * @group domdocument
138140 * @return void
139141 */
140- public function testEmptyStringIsNotValid () : void
142+ public function testEmptyStringIsNotValid (): void
141143 {
142144 $ this ->expectException (AssertionFailedException::class);
143145 $ this ->expectExceptionMessage ('Expected a non-whitespace string. Got: "" ' );
0 commit comments