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