File tree Expand file tree Collapse file tree 2 files changed +19
-0
lines changed
lib/internal/Magento/Framework/Module Expand file tree Collapse file tree 2 files changed +19
-0
lines changed Original file line number Diff line number Diff line change @@ -45,6 +45,12 @@ public function getDir($moduleName, $type = '')
45
45
{
46
46
$ path = $ this ->componentRegistrar ->getPath (ComponentRegistrar::MODULE , $ moduleName );
47
47
48
+ // An empty $type means it's getting the directory of the module itself.
49
+ if (empty ($ type ) && !isset ($ path )) {
50
+ // Note: do not throw \LogicException, as it would break backwards-compatibility.
51
+ throw new \InvalidArgumentException ("Module ' $ moduleName' is not correctly registered. " );
52
+ }
53
+
48
54
if ($ type ) {
49
55
if (!in_array ($ type , [
50
56
self ::MODULE_ETC_DIR ,
Original file line number Diff line number Diff line change @@ -59,4 +59,17 @@ public function testGetDirModuleSubDirUnknown()
59
59
60
60
$ this ->_model ->getDir ('Test_Module ' , 'unknown ' );
61
61
}
62
+
63
+ /**
64
+ * @expectedException \InvalidArgumentException
65
+ * @expectedExceptionMessage Module 'Test Module' is not correctly registered.
66
+ */
67
+ public function testGetDirModuleIncorrectlyRegistered ()
68
+ {
69
+ $ this ->moduleRegistryMock ->expects ($ this ->once ())
70
+ ->method ('getPath ' )
71
+ ->with ($ this ->identicalTo (ComponentRegistrar::MODULE ), $ this ->identicalTo ('Test Module ' ))
72
+ ->willReturn (null );
73
+ $ this ->_model ->getDir ('Test Module ' );
74
+ }
62
75
}
You can’t perform that action at this time.
0 commit comments