Skip to content

Commit b68e622

Browse files
Merge remote-tracking branch 'techdivision/MC-24726' into trigger-pr-1
2 parents 6346439 + 658fb06 commit b68e622

File tree

2 files changed

+21
-2
lines changed

2 files changed

+21
-2
lines changed

lib/internal/Magento/Framework/Interception/ObjectManager/Config/Developer.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff 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
}

lib/internal/Magento/Framework/Interception/Test/Unit/ObjectManager/Config/DeveloperTest.php

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff 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
}

0 commit comments

Comments
 (0)