File tree 5 files changed +21
-14
lines changed
app/code/Magento/Developer
Test/Unit/Model/Logger/Handler
lib/internal/Magento/Framework/Interception
Test/Unit/ObjectManager/Config 5 files changed +21
-14
lines changed Original file line number Diff line number Diff line change @@ -21,11 +21,6 @@ class Debug extends \Magento\Framework\Logger\Handler\Debug
21
21
*/
22
22
private $ state ;
23
23
24
- /**
25
- * @var ScopeConfigInterface
26
- */
27
- private $ scopeConfig ;
28
-
29
24
/**
30
25
* @var DeploymentConfig
31
26
*/
@@ -34,22 +29,19 @@ class Debug extends \Magento\Framework\Logger\Handler\Debug
34
29
/**
35
30
* @param DriverInterface $filesystem
36
31
* @param State $state
37
- * @param ScopeConfigInterface $scopeConfig
38
32
* @param DeploymentConfig $deploymentConfig
39
33
* @param string $filePath
40
34
* @throws \Exception
41
35
*/
42
36
public function __construct (
43
37
DriverInterface $ filesystem ,
44
38
State $ state ,
45
- ScopeConfigInterface $ scopeConfig ,
46
39
DeploymentConfig $ deploymentConfig ,
47
40
$ filePath = null
48
41
) {
49
42
parent ::__construct ($ filesystem , $ filePath );
50
43
51
44
$ this ->state = $ state ;
52
- $ this ->scopeConfig = $ scopeConfig ;
53
45
$ this ->deploymentConfig = $ deploymentConfig ;
54
46
}
55
47
Original file line number Diff line number Diff line change @@ -29,13 +29,10 @@ class Syslog extends \Magento\Framework\Logger\Handler\Syslog
29
29
private $ deploymentConfig ;
30
30
31
31
/**
32
- * @param ScopeConfigInterface $scopeConfig Scope config
33
32
* @param DeploymentConfig $deploymentConfig Deployment config
34
33
* @param string $ident The string ident to be added to each message
35
- * @SuppressWarnings(PHPMD.UnusedFormalParameter)
36
34
*/
37
35
public function __construct (
38
- ScopeConfigInterface $ scopeConfig ,
39
36
DeploymentConfig $ deploymentConfig ,
40
37
string $ ident
41
38
) {
Original file line number Diff line number Diff line change @@ -44,7 +44,6 @@ protected function setUp(): void
44
44
$ this ->deploymentConfigMock = $ this ->createMock (DeploymentConfig::class);
45
45
46
46
$ this ->model = new Syslog (
47
- $ this ->scopeConfigMock ,
48
47
$ this ->deploymentConfigMock ,
49
48
'Magento '
50
49
);
Original file line number Diff line number Diff line change @@ -58,8 +58,8 @@ public function setInterceptionConfig(\Magento\Framework\Interception\ConfigInte
58
58
public function getInstanceType ($ instanceName )
59
59
{
60
60
$ type = parent ::getInstanceType ($ instanceName );
61
- if ($ this ->interceptionConfig && $ this ->interceptionConfig ->hasPlugins ($ instanceName )
62
- && $ this ->interceptableValidator ->validate ($ instanceName )
61
+ if ($ this ->interceptionConfig && $ this ->interceptionConfig ->hasPlugins ($ type )
62
+ && $ this ->interceptableValidator ->validate ($ type )
63
63
) {
64
64
return $ type . '\\Interceptor ' ;
65
65
}
Original file line number Diff line number Diff line change @@ -58,4 +58,23 @@ public function testGetOriginalInstanceTypeReturnsInterceptedClass()
58
58
$ this ->assertEquals ('SomeClass\Interceptor ' , $ this ->model ->getInstanceType ('SomeClass ' ));
59
59
$ this ->assertEquals ('SomeClass ' , $ this ->model ->getOriginalInstanceType ('SomeClass ' ));
60
60
}
61
+
62
+ /**
63
+ * Test correct instance type is returned when plugins are created for virtual type parents
64
+ *
65
+ * @return void
66
+ */
67
+ public function testGetInstanceTypeWithPluginOnVirtualTypeParent () : void
68
+ {
69
+ $ reflectionClass = new \ReflectionClass (get_class ($ this ->model ));
70
+ $ reflectionProperty = $ reflectionClass ->getProperty ('_virtualTypes ' );
71
+ $ reflectionProperty ->setAccessible (true );
72
+ $ reflectionProperty ->setValue ($ this ->model , ['SomeVirtualClass ' => 'SomeClass ' ]);
73
+
74
+ $ this ->interceptionConfig ->expects ($ this ->once ())->method ('hasPlugins ' )->with ('SomeClass ' )->willReturn (true );
75
+ $ this ->model ->setInterceptionConfig ($ this ->interceptionConfig );
76
+
77
+ $ instanceType = $ this ->model ->getInstanceType ('SomeVirtualClass ' );
78
+ $ this ->assertEquals ('SomeClass\Interceptor ' , $ instanceType );
79
+ }
61
80
}
You can’t perform that action at this time.
0 commit comments