1
1
<?php
2
2
/**
3
- * Copyright © Magento, Inc. All rights reserved.
4
- * See COPYING.txt for license details .
3
+ * Copyright 2015 Adobe
4
+ * All Rights Reserved .
5
5
*/
6
6
declare (strict_types=1 );
7
7
10
10
use Magento \Framework \App \Cache \Manager ;
11
11
use Magento \Framework \App \Interception \Cache \CompiledConfig ;
12
12
use Magento \Framework \Interception \Config \Config ;
13
+ use Magento \Framework \Interception \ObjectManager \ConfigInterface ;
13
14
use Magento \Framework \ObjectManager \InterceptableValidator ;
14
15
use Magento \Setup \Module \Di \Code \Generator \InterceptionConfigurationBuilder ;
15
16
use Magento \Setup \Module \Di \Code \Generator \PluginList ;
16
17
use Magento \Setup \Module \Di \Code \Reader \Type ;
17
18
use PHPUnit \Framework \MockObject \MockObject ;
18
19
use PHPUnit \Framework \TestCase ;
19
- use stdClass ;
20
20
21
21
class InterceptionConfigurationBuilderTest extends TestCase
22
22
{
@@ -50,25 +50,30 @@ class InterceptionConfigurationBuilderTest extends TestCase
50
50
*/
51
51
private $ interceptableValidator ;
52
52
53
+ /**
54
+ * @var MockObject
55
+ */
56
+ private $ omConfig ;
57
+
53
58
protected function setUp (): void
54
59
{
55
- $ this ->interceptionConfig =
56
- $ this ->createPartialMock (Config::class, ['hasPlugins ' ]);
60
+ $ this ->interceptionConfig = $ this ->createPartialMock (Config::class, ['hasPlugins ' ]);
57
61
$ this ->pluginList = $ this ->createPartialMock (
58
62
PluginList::class,
59
63
['setInterceptedClasses ' , 'setScopePriorityScheme ' , 'getPluginsConfig ' ]
60
64
);
61
65
$ this ->cacheManager = $ this ->createMock (Manager::class);
62
- $ this ->interceptableValidator =
63
- $ this ->createMock (InterceptableValidator ::class);
66
+ $ this ->interceptableValidator = $ this -> createMock (InterceptableValidator::class);
67
+ $ this -> omConfig = $ this ->createMock (ConfigInterface ::class);
64
68
65
69
$ this ->typeReader = $ this ->createPartialMock (Type::class, ['isConcrete ' ]);
66
70
$ this ->model = new InterceptionConfigurationBuilder (
67
71
$ this ->interceptionConfig ,
68
72
$ this ->pluginList ,
69
73
$ this ->typeReader ,
70
74
$ this ->cacheManager ,
71
- $ this ->interceptableValidator
75
+ $ this ->interceptableValidator ,
76
+ $ this ->omConfig
72
77
);
73
78
}
74
79
@@ -106,6 +111,13 @@ public function testGetInterceptionConfiguration($plugins)
106
111
->method ('getPluginsConfig ' )
107
112
->willReturn (['instance ' => $ plugins ]);
108
113
114
+ $ this ->omConfig ->expects ($ this ->any ())
115
+ ->method ('getOriginalInstanceType ' )
116
+ ->willReturnMap ([
117
+ ['stdClass ' , 'stdClass ' ],
118
+ ['virtualTypeClass ' , 'stdClass ' ],
119
+ ]);
120
+
109
121
$ this ->model ->addAreaCode ('areaCode ' );
110
122
$ this ->model ->getInterceptionConfiguration ($ definedClasses );
111
123
}
@@ -115,11 +127,15 @@ public function testGetInterceptionConfiguration($plugins)
115
127
*/
116
128
public static function getInterceptionConfigurationDataProvider ()
117
129
{
118
- $ someInstance = new stdClass ();
119
130
return [
120
131
[null ],
121
- [['plugin ' => ['instance ' => $ someInstance ]]],
122
- [['plugin ' => ['instance ' => $ someInstance ], 'plugin2 ' => ['instance ' => $ someInstance ]]]
132
+ [['plugin ' => ['instance ' => 'stdClass ' ]]],
133
+ [[
134
+ 'plugin ' => ['instance ' => 'stdClass ' ],
135
+ 'plugin1 ' => ['instance ' => 'stdClass ' ],
136
+ 'plugin2 ' => ['instance ' => 'virtualTypeClass ' ]
137
+ ]],
138
+ [['plugin ' => ['instance ' => 'virtualTypeClass ' ]]],
123
139
];
124
140
}
125
141
}
0 commit comments