File tree Expand file tree Collapse file tree 2 files changed +29
-2
lines changed
dev/tests/unit/testsuite/Magento/Framework/ObjectManager/Definition/Compiled
lib/internal/Magento/Framework/ObjectManager/Definition Expand file tree Collapse file tree 2 files changed +29
-2
lines changed Original file line number Diff line number Diff line change @@ -31,4 +31,30 @@ public function testGetParametersWithUnpacking()
31
31
$ model = new \Magento \Framework \ObjectManager \Definition \Compiled \Serialized ([$ signatures , $ definitions ]);
32
32
$ this ->assertEquals ($ checkString , $ model ->getParameters ('wonderful ' ));
33
33
}
34
+
35
+ public function testGetParametersWithUndefinedDefinition ()
36
+ {
37
+ $ objectManager = new \Magento \TestFramework \Helper \ObjectManager ($ this );
38
+ $ undefinedDefinitionSignature = new \stdClass ();
39
+ $ className = 'undefinedDefinition ' ;
40
+ $ readerMock = $ this ->getMock (
41
+ '\Magento\Framework\Code\Reader\ClassReader ' ,
42
+ ['getConstructor ' ],
43
+ [],
44
+ '' ,
45
+ false
46
+ );
47
+ $ readerMock ->expects ($ this ->once ())
48
+ ->method ('getConstructor ' )
49
+ ->with ($ className )
50
+ ->willReturn ($ undefinedDefinitionSignature );
51
+ $ model = $ objectManager ->getObject (
52
+ 'Magento\Framework\ObjectManager\Definition\Compiled\Serialized ' ,
53
+ [
54
+ 'definitions ' => [[], []],
55
+ 'reader ' => $ readerMock
56
+ ]
57
+ );
58
+ $ this ->assertEquals ($ undefinedDefinitionSignature , $ model ->getParameters ($ className ));
59
+ }
34
60
}
Original file line number Diff line number Diff line change @@ -23,6 +23,7 @@ abstract class Compiled implements \Magento\Framework\ObjectManager\DefinitionIn
23
23
24
24
/**
25
25
* @param array $definitions
26
+ * @param \Magento\Framework\Code\Reader\ClassReader $reader
26
27
*/
27
28
public function __construct (array $ definitions , \Magento \Framework \Code \Reader \ClassReader $ reader = null )
28
29
{
@@ -56,8 +57,8 @@ abstract protected function _unpack($signature);
56
57
*/
57
58
public function getParameters ($ className )
58
59
{
59
- // if the definition isn't found in the list gathered from the compiled file using reflection to find it
60
- if (!isset ( $ this ->_definitions [ $ className ] )) {
60
+ // if the definition isn't found in the list gathered from the compiled file then using reflection to find it
61
+ if (!array_key_exists ( $ className , $ this ->_definitions )) {
61
62
return $ this ->reader ->getConstructor ($ className );
62
63
}
63
64
You can’t perform that action at this time.
0 commit comments