Skip to content

Commit

Permalink
Merge pull request #5803 from magento-trigger/trigger-pr-1
Browse files Browse the repository at this point in the history
[trigger] 2.4 bug fixes
  • Loading branch information
zakdma authored Jun 17, 2020
2 parents 5fca50e + e755387 commit 29e1368
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 14 deletions.
8 changes: 0 additions & 8 deletions app/code/Magento/Developer/Model/Logger/Handler/Debug.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,6 @@ class Debug extends \Magento\Framework\Logger\Handler\Debug
*/
private $state;

/**
* @var ScopeConfigInterface
*/
private $scopeConfig;

/**
* @var DeploymentConfig
*/
Expand All @@ -34,22 +29,19 @@ class Debug extends \Magento\Framework\Logger\Handler\Debug
/**
* @param DriverInterface $filesystem
* @param State $state
* @param ScopeConfigInterface $scopeConfig
* @param DeploymentConfig $deploymentConfig
* @param string $filePath
* @throws \Exception
*/
public function __construct(
DriverInterface $filesystem,
State $state,
ScopeConfigInterface $scopeConfig,
DeploymentConfig $deploymentConfig,
$filePath = null
) {
parent::__construct($filesystem, $filePath);

$this->state = $state;
$this->scopeConfig = $scopeConfig;
$this->deploymentConfig = $deploymentConfig;
}

Expand Down
3 changes: 0 additions & 3 deletions app/code/Magento/Developer/Model/Logger/Handler/Syslog.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,10 @@ class Syslog extends \Magento\Framework\Logger\Handler\Syslog
private $deploymentConfig;

/**
* @param ScopeConfigInterface $scopeConfig Scope config
* @param DeploymentConfig $deploymentConfig Deployment config
* @param string $ident The string ident to be added to each message
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
*/
public function __construct(
ScopeConfigInterface $scopeConfig,
DeploymentConfig $deploymentConfig,
string $ident
) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ protected function setUp(): void
$this->deploymentConfigMock = $this->createMock(DeploymentConfig::class);

$this->model = new Syslog(
$this->scopeConfigMock,
$this->deploymentConfigMock,
'Magento'
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,8 @@ public function setInterceptionConfig(\Magento\Framework\Interception\ConfigInte
public function getInstanceType($instanceName)
{
$type = parent::getInstanceType($instanceName);
if ($this->interceptionConfig && $this->interceptionConfig->hasPlugins($instanceName)
&& $this->interceptableValidator->validate($instanceName)
if ($this->interceptionConfig && $this->interceptionConfig->hasPlugins($type)
&& $this->interceptableValidator->validate($type)
) {
return $type . '\\Interceptor';
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,4 +58,23 @@ public function testGetOriginalInstanceTypeReturnsInterceptedClass()
$this->assertEquals('SomeClass\Interceptor', $this->model->getInstanceType('SomeClass'));
$this->assertEquals('SomeClass', $this->model->getOriginalInstanceType('SomeClass'));
}

/**
* Test correct instance type is returned when plugins are created for virtual type parents
*
* @return void
*/
public function testGetInstanceTypeWithPluginOnVirtualTypeParent() : void
{
$reflectionClass = new \ReflectionClass(get_class($this->model));
$reflectionProperty = $reflectionClass->getProperty('_virtualTypes');
$reflectionProperty->setAccessible(true);
$reflectionProperty->setValue($this->model, ['SomeVirtualClass' => 'SomeClass']);

$this->interceptionConfig->expects($this->once())->method('hasPlugins')->with('SomeClass')->willReturn(true);
$this->model->setInterceptionConfig($this->interceptionConfig);

$instanceType = $this->model->getInstanceType('SomeVirtualClass');
$this->assertEquals('SomeClass\Interceptor', $instanceType);
}
}

0 comments on commit 29e1368

Please sign in to comment.