@@ -20,10 +20,12 @@ class FileLoaderTest extends \PHPUnit_Framework_TestCase
20
20
/**
21
21
* @covers Symfony\Component\Config\Loader\FileLoader
22
22
*/
23
- public function testImport ()
23
+ public function testImportWithFileLocatorDelegation ()
24
24
{
25
25
$ locatorMock = $ this ->getMock ('Symfony\Component\Config\FileLocatorInterface ' );
26
- $ locatorMock ->expects ($ this ->any ())->method ('locate ' )->will ($ this ->onConsecutiveCalls (
26
+
27
+ $ locatorMockForAdditionalLoader = $ this ->getMock ('Symfony\Component\Config\FileLocatorInterface ' );
28
+ $ locatorMockForAdditionalLoader ->expects ($ this ->any ())->method ('locate ' )->will ($ this ->onConsecutiveCalls (
27
29
array ('path/to/file1 ' ), // Default
28
30
array ('path/to/file1 ' , 'path/to/file2 ' ), // First is imported
29
31
array ('path/to/file1 ' , 'path/to/file2 ' ), // Second is imported
@@ -32,8 +34,13 @@ public function testImport()
32
34
));
33
35
34
36
$ fileLoader = new TestFileLoader ($ locatorMock );
37
+ $ fileLoader ->setSupports (false );
35
38
$ fileLoader ->setCurrentDir ('. ' );
36
- $ fileLoader ->setResolver ($ loaderResolver = new LoaderResolver (array ($ fileLoader )));
39
+
40
+ $ additionalLoader = new TestFileLoader ($ locatorMockForAdditionalLoader );
41
+ $ additionalLoader ->setCurrentDir ('. ' );
42
+
43
+ $ fileLoader ->setResolver ($ loaderResolver = new LoaderResolver (array ($ fileLoader , $ additionalLoader )));
37
44
38
45
// Default case
39
46
$ this ->assertSame ('path/to/file1 ' , $ fileLoader ->import ('my_resource ' ));
@@ -66,14 +73,16 @@ public function testImport()
66
73
67
74
class TestFileLoader extends FileLoader
68
75
{
76
+ private $ supports = true ;
77
+
69
78
public function load ($ resource , $ type = null )
70
79
{
71
80
return $ resource ;
72
81
}
73
82
74
83
public function supports ($ resource , $ type = null )
75
84
{
76
- return true ;
85
+ return $ this -> supports ;
77
86
}
78
87
79
88
public function addLoading ($ resource )
@@ -90,4 +99,9 @@ public function clearLoading()
90
99
{
91
100
self ::$ loading = array ();
92
101
}
102
+
103
+ public function setSupports ($ supports )
104
+ {
105
+ $ this ->supports = $ supports ;
106
+ }
93
107
}
0 commit comments