@@ -14,6 +14,11 @@ class PopulatorTest extends \PHPUnit_Framework_TestCase
14
14
/** @var \Magento\Framework\App\Filesystem\DirectoryList | \PHPUnit_Framework_MockObject_MockObject */
15
15
protected $ mockDirectoryList ;
16
16
17
+ /**
18
+ * @var \Magento\Framework\Component\ComponentRegistrar|\PHPUnit_Framework_MockObject_MockObject
19
+ */
20
+ protected $ componentRegistrar ;
21
+
17
22
public function setUp ()
18
23
{
19
24
$ this ->mockDirectoryList = $ this ->getMockBuilder ('\Magento\Framework\App\Filesystem\DirectoryList ' )
@@ -23,6 +28,8 @@ public function setUp()
23
28
$ this ->mockDirectoryList ->expects ($ this ->any ())
24
29
->method ('getPath ' )
25
30
->willReturnArgument (0 );
31
+
32
+ $ this ->componentRegistrar = $ this ->getMock ('Magento\Framework\Component\ComponentRegistrar ' , [], [], '' , false );
26
33
}
27
34
28
35
public function testPopulateMappings ()
@@ -31,32 +38,38 @@ public function testPopulateMappings()
31
38
->disableOriginalConstructor ()
32
39
->getMock ();
33
40
34
- $ mockAutoloader ->expects ($ this ->at (0 ))
41
+ $ mockAutoloader ->expects ($ this ->at (0 ))->method ('addPsr4 ' )->with ('Magento \\A \\' , ['/path/to/a/ ' ], true );
42
+ $ mockAutoloader ->expects ($ this ->at (1 ))->method ('addPsr4 ' )->with ('Magento \\B \\' , ['/path/to/b/ ' ], true );
43
+ $ mockAutoloader ->expects ($ this ->at (2 ))->method ('addPsr4 ' )->with ('Magento \\C \\' , ['/path/to/c/ ' ], true );
44
+ $ mockAutoloader ->expects ($ this ->at (3 ))
35
45
->method ('addPsr4 ' )
36
- ->with (
37
- 'Magento \\' ,
38
- [DirectoryList::ROOT . '/app/code/Magento/ ' , DirectoryList::GENERATION . '/Magento/ ' ],
39
- true
40
- );
41
- $ mockAutoloader ->expects ($ this ->at (1 ))
46
+ ->with ('Magento \\' , [DirectoryList::GENERATION . '/Magento/ ' ], true );
47
+ $ mockAutoloader ->expects ($ this ->at (4 ))
42
48
->method ('addPsr0 ' )
43
49
->with ('Apache_ ' , DirectoryList::LIB_INTERNAL , true );
44
- $ mockAutoloader ->expects ($ this ->at (2 ))
50
+ $ mockAutoloader ->expects ($ this ->at (5 ))
45
51
->method ('addPsr0 ' )
46
52
->with ('Cm_ ' , DirectoryList::LIB_INTERNAL , true );
47
- $ mockAutoloader ->expects ($ this ->at (3 ))
53
+ $ mockAutoloader ->expects ($ this ->at (6 ))
48
54
->method ('addPsr0 ' )
49
55
->with ('Credis_ ' , DirectoryList::LIB_INTERNAL , true );
50
- $ mockAutoloader ->expects ($ this ->at (4 ))
56
+ $ mockAutoloader ->expects ($ this ->at (7 ))
51
57
->method ('addPsr0 ' )
52
58
->with ('Less_ ' , DirectoryList::LIB_INTERNAL , true );
53
- $ mockAutoloader ->expects ($ this ->at (5 ))
59
+ $ mockAutoloader ->expects ($ this ->at (8 ))
54
60
->method ('addPsr0 ' )
55
61
->with ('Symfony \\' , DirectoryList::LIB_INTERNAL , true );
56
- $ mockAutoloader ->expects ($ this ->at (6 ))
62
+ $ mockAutoloader ->expects ($ this ->at (9 ))
57
63
->method ('addPsr0 ' )
58
64
->with ('' , [DirectoryList::GENERATION ]);
59
65
60
- Populator::populateMappings ($ mockAutoloader , $ this ->mockDirectoryList );
66
+ $ moduleDirs = [
67
+ 'Magento_A ' => '/path/to/a ' ,
68
+ 'Magento_B ' => '/path/to/b ' ,
69
+ 'Magento_C ' => '/path/to/c ' ,
70
+ ];
71
+ $ this ->componentRegistrar ->expects ($ this ->once ())->method ('getPaths ' )->willReturn ($ moduleDirs );
72
+
73
+ Populator::populateMappings ($ mockAutoloader , $ this ->mockDirectoryList , $ this ->componentRegistrar );
61
74
}
62
75
}
0 commit comments