File tree Expand file tree Collapse 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 Expand file tree Collapse file tree 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
2121 */
2222 private $ state ;
2323
24- /**
25- * @var ScopeConfigInterface
26- */
27- private $ scopeConfig ;
28-
2924 /**
3025 * @var DeploymentConfig
3126 */
@@ -34,22 +29,19 @@ class Debug extends \Magento\Framework\Logger\Handler\Debug
3429 /**
3530 * @param DriverInterface $filesystem
3631 * @param State $state
37- * @param ScopeConfigInterface $scopeConfig
3832 * @param DeploymentConfig $deploymentConfig
3933 * @param string $filePath
4034 * @throws \Exception
4135 */
4236 public function __construct (
4337 DriverInterface $ filesystem ,
4438 State $ state ,
45- ScopeConfigInterface $ scopeConfig ,
4639 DeploymentConfig $ deploymentConfig ,
4740 $ filePath = null
4841 ) {
4942 parent ::__construct ($ filesystem , $ filePath );
5043
5144 $ this ->state = $ state ;
52- $ this ->scopeConfig = $ scopeConfig ;
5345 $ this ->deploymentConfig = $ deploymentConfig ;
5446 }
5547
Original file line number Diff line number Diff line change @@ -29,13 +29,10 @@ class Syslog extends \Magento\Framework\Logger\Handler\Syslog
2929 private $ deploymentConfig ;
3030
3131 /**
32- * @param ScopeConfigInterface $scopeConfig Scope config
3332 * @param DeploymentConfig $deploymentConfig Deployment config
3433 * @param string $ident The string ident to be added to each message
35- * @SuppressWarnings(PHPMD.UnusedFormalParameter)
3634 */
3735 public function __construct (
38- ScopeConfigInterface $ scopeConfig ,
3936 DeploymentConfig $ deploymentConfig ,
4037 string $ ident
4138 ) {
Original file line number Diff line number Diff line change @@ -44,7 +44,6 @@ protected function setUp(): void
4444 $ this ->deploymentConfigMock = $ this ->createMock (DeploymentConfig::class);
4545
4646 $ this ->model = new Syslog (
47- $ this ->scopeConfigMock ,
4847 $ this ->deploymentConfigMock ,
4948 'Magento '
5049 );
Original file line number Diff line number Diff line change @@ -58,8 +58,8 @@ public function setInterceptionConfig(\Magento\Framework\Interception\ConfigInte
5858 public function getInstanceType ($ instanceName )
5959 {
6060 $ 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 )
6363 ) {
6464 return $ type . '\\Interceptor ' ;
6565 }
Original file line number Diff line number Diff line change @@ -58,4 +58,23 @@ public function testGetOriginalInstanceTypeReturnsInterceptedClass()
5858 $ this ->assertEquals ('SomeClass\Interceptor ' , $ this ->model ->getInstanceType ('SomeClass ' ));
5959 $ this ->assertEquals ('SomeClass ' , $ this ->model ->getOriginalInstanceType ('SomeClass ' ));
6060 }
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+ }
6180}
You can’t perform that action at this time.
0 commit comments