@@ -41,7 +41,7 @@ public function testGetContextByPath($context, $path, $pathValues)
41
41
{
42
42
$ this ->componentRegistrar ->expects ($ this ->any ())
43
43
->method ('getPaths ' )
44
- ->will ( $ this -> returnValueMap ( $ pathValues) );
44
+ ->willReturnMap ( $ pathValues );
45
45
$ this ->context = new Context ($ this ->componentRegistrar );
46
46
$ this ->assertEquals ($ context , $ this ->context ->getContextByPath ($ path ));
47
47
}
@@ -108,10 +108,8 @@ public function testBuildPathToLocaleDirectoryByContext($path, $context, $regist
108
108
$ paths [$ module [1 ]] = $ module [2 ];
109
109
}
110
110
$ this ->componentRegistrar ->expects ($ this ->any ())
111
- ->method ('getPaths ' )
112
- ->with (ComponentRegistrar::MODULE )
113
- ->willReturn ($ paths );
114
- $ this ->componentRegistrar ->expects ($ this ->any ())->method ('getPath ' )->will ($ this ->returnValueMap ($ registrar ));
111
+ ->method ('getPath ' )
112
+ ->willReturnMap ($ registrar );
115
113
$ this ->context = new Context ($ this ->componentRegistrar );
116
114
$ this ->assertEquals ($ path , $ this ->context ->buildPathToLocaleDirectoryByContext ($ context [0 ], $ context [1 ]));
117
115
}
@@ -127,7 +125,11 @@ public function dataProviderPathToLocaleDirectoryByContext()
127
125
[Context::CONTEXT_TYPE_MODULE , 'Magento_Module ' ],
128
126
[[ComponentRegistrar::MODULE , 'Magento_Module ' , BP . '/app/code/Magento/Module ' ]]
129
127
],
130
- ['/i18n/ ' , [Context::CONTEXT_TYPE_THEME , 'theme/test.phtml ' ], []],
128
+ [
129
+ BP . '/app/design/frontend/Magento/luma/i18n/ ' ,
130
+ [Context::CONTEXT_TYPE_THEME , 'rontend/Magento/luma ' ],
131
+ [[ComponentRegistrar::THEME , 'rontend/Magento/luma ' , BP . '/app/design/frontend/Magento/luma ' ]]
132
+ ],
131
133
[BP . '/lib/web/i18n/ ' , [Context::CONTEXT_TYPE_LIB , 'lib/web/module/test.phtml ' ], []],
132
134
];
133
135
}
@@ -138,11 +140,23 @@ public function dataProviderPathToLocaleDirectoryByContext()
138
140
*/
139
141
public function testBuildPathToLocaleDirectoryByContextWithInvalidType ()
140
142
{
141
- $ this ->componentRegistrar ->expects ($ this ->any ())
142
- ->method ('getPaths ' )
143
- ->with (ComponentRegistrar::MODULE )
144
- ->willReturn (['module ' => '/path/to/module ' ]);
143
+ $ this ->componentRegistrar ->expects ($ this ->never ())
144
+ ->method ('getPath ' );
145
145
$ this ->context = new Context ($ this ->componentRegistrar );
146
146
$ this ->context ->buildPathToLocaleDirectoryByContext ('invalid_type ' , 'Magento_Module ' );
147
147
}
148
+
149
+ /**
150
+ * @expectedException \Magento\Setup\Module\I18n\UnregisteredComponentException
151
+ */
152
+ public function testBuildPathToLocaleDirectoryByContextWithUnregisteredComponent ()
153
+ {
154
+ $ moduleName = 'Magento_Module ' ;
155
+ $ this ->componentRegistrar ->expects ($ this ->once ())
156
+ ->method ('getPath ' )
157
+ ->with (ComponentRegistrar::MODULE , $ moduleName )
158
+ ->willReturn (null );
159
+ $ this ->context = new Context ($ this ->componentRegistrar );
160
+ $ this ->context ->buildPathToLocaleDirectoryByContext (ComponentRegistrar::MODULE , $ moduleName );
161
+ }
148
162
}
0 commit comments