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 = '')
4646 {
4747 $ path = $ this ->componentRegistrar ->getPath (ComponentRegistrar::MODULE , $ moduleName );
4848
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+
4955 if ($ type ) {
5056 if (!in_array ($ type , [
5157 self ::MODULE_ETC_DIR ,
Original file line number Diff line number Diff line change @@ -69,4 +69,17 @@ public function testGetDirModuleSubDirUnknown()
6969
7070 $ this ->_model ->getDir ('Test_Module ' , 'unknown ' );
7171 }
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+ }
7285}
You can’t perform that action at this time.
0 commit comments