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 @@ -46,6 +46,12 @@ public function getDir($moduleName, $type = '')
46
46
{
47
47
$ path = $ this ->componentRegistrar ->getPath (ComponentRegistrar::MODULE , $ moduleName );
48
48
49
+ // An empty $type means it's getting the directory of the module itself.
50
+ if (empty ($ type ) && !isset ($ path )) {
51
+ // Note: do not throw \LogicException, as it would break backwards-compatibility.
52
+ throw new \InvalidArgumentException ("Module ' $ moduleName' is not correctly registered. " );
53
+ }
54
+
49
55
if ($ type ) {
50
56
if (!in_array ($ type , [
51
57
self ::MODULE_ETC_DIR ,
Original file line number Diff line number Diff line change @@ -69,4 +69,17 @@ public function testGetDirModuleSubDirUnknown()
69
69
70
70
$ this ->_model ->getDir ('Test_Module ' , 'unknown ' );
71
71
}
72
+
73
+ /**
74
+ * @expectedException \InvalidArgumentException
75
+ * @expectedExceptionMessage Module 'Test Module' is not correctly registered.
76
+ */
77
+ public function testGetDirModuleIncorrectlyRegistered ()
78
+ {
79
+ $ this ->moduleRegistryMock ->expects ($ this ->once ())
80
+ ->method ('getPath ' )
81
+ ->with ($ this ->identicalTo (ComponentRegistrar::MODULE ), $ this ->identicalTo ('Test Module ' ))
82
+ ->willReturn (null );
83
+ $ this ->_model ->getDir ('Test Module ' );
84
+ }
72
85
}
You can’t perform that action at this time.
0 commit comments