@@ -20,6 +20,31 @@ public function testLoadFile()
20
20
{
21
21
$ fixtures = __DIR__ .'/../Fixtures/Util/ ' ;
22
22
23
+ try {
24
+ XmlUtils::loadFile ($ fixtures );
25
+ $ this ->fail ();
26
+ } catch (\InvalidArgumentException $ e ) {
27
+ $ this ->assertStringContainsString ('is not a file ' , $ e ->getMessage ());
28
+ }
29
+
30
+ try {
31
+ XmlUtils::loadFile ($ fixtures .'non_existing.xml ' );
32
+ $ this ->fail ();
33
+ } catch (\InvalidArgumentException $ e ) {
34
+ $ this ->assertStringContainsString ('is not a file ' , $ e ->getMessage ());
35
+ }
36
+
37
+ try {
38
+ if ('\\' === \DIRECTORY_SEPARATOR ) {
39
+ $ this ->markTestSkipped ('chmod is not supported on Windows ' );
40
+ }
41
+ chmod ($ fixtures .'not_readable.xml ' , 000 );
42
+ XmlUtils::loadFile ($ fixtures .'not_readable.xml ' );
43
+ $ this ->fail ();
44
+ } catch (\InvalidArgumentException $ e ) {
45
+ $ this ->assertStringContainsString ('is not readable ' , $ e ->getMessage ());
46
+ }
47
+
23
48
try {
24
49
XmlUtils::loadFile ($ fixtures .'invalid.xml ' );
25
50
$ this ->fail ();
@@ -165,7 +190,7 @@ public function testLoadEmptyXmlFile()
165
190
$ file = __DIR__ .'/../Fixtures/foo.xml ' ;
166
191
167
192
$ this ->expectException ('InvalidArgumentException ' );
168
- $ this ->expectExceptionMessage (sprintf ('File %s does not contain valid XML, it is empty. ' , $ file ));
193
+ $ this ->expectExceptionMessage (sprintf ('File "%s" does not contain valid XML, it is empty. ' , $ file ));
169
194
170
195
XmlUtils::loadFile ($ file );
171
196
}
@@ -186,7 +211,7 @@ public function testLoadWrongEmptyXMLWithErrorHandler()
186
211
XmlUtils::loadFile ($ file );
187
212
$ this ->fail ('An exception should have been raised ' );
188
213
} catch (\InvalidArgumentException $ e ) {
189
- $ this ->assertEquals (sprintf ('File %s does not contain valid XML, it is empty. ' , $ file ), $ e ->getMessage ());
214
+ $ this ->assertEquals (sprintf ('File "%s" does not contain valid XML, it is empty. ' , $ file ), $ e ->getMessage ());
190
215
}
191
216
} finally {
192
217
restore_error_handler ();
0 commit comments