From ba918182c7af01b13a1c975867579f37be1bba0c Mon Sep 17 00:00:00 2001 From: Kristof Ringleff Date: Wed, 14 Jan 2015 11:50:15 +1300 Subject: [PATCH 1/7] extra tests for current interception behavior --- .../Interception/Fixture/Intercepted.php | 25 ++++ .../Fixture/Intercepted/FirstPlugin.php | 88 ++++++++++++ .../Fixture/Intercepted/Plugin.php | 40 ++++++ .../Framework/Interception/TwoPluginTest.php | 125 ++++++++++++++++++ 4 files changed, 278 insertions(+) create mode 100644 dev/tests/integration/testsuite/Magento/Framework/Interception/Fixture/Intercepted/FirstPlugin.php create mode 100644 dev/tests/integration/testsuite/Magento/Framework/Interception/TwoPluginTest.php diff --git a/dev/tests/integration/testsuite/Magento/Framework/Interception/Fixture/Intercepted.php b/dev/tests/integration/testsuite/Magento/Framework/Interception/Fixture/Intercepted.php index 84988bbba5b03..6b9a318344cb7 100644 --- a/dev/tests/integration/testsuite/Magento/Framework/Interception/Fixture/Intercepted.php +++ b/dev/tests/integration/testsuite/Magento/Framework/Interception/Fixture/Intercepted.php @@ -49,4 +49,29 @@ public function K($param1) { return '' . $param1 . ''; } + + public function V($param1) + { + return '' . $param1 . ''; + } + + public function W($param1) + { + return '' . $param1 . ''; + } + + public function X($param1) + { + return '' . $param1 . ''; + } + + public function Y($param1) + { + return '' . $param1 . ''; + } + + public function Z($param1) + { + return '' . $param1 . ''; + } } diff --git a/dev/tests/integration/testsuite/Magento/Framework/Interception/Fixture/Intercepted/FirstPlugin.php b/dev/tests/integration/testsuite/Magento/Framework/Interception/Fixture/Intercepted/FirstPlugin.php new file mode 100644 index 0000000000000..4c2d39a51d0ff --- /dev/null +++ b/dev/tests/integration/testsuite/Magento/Framework/Interception/Fixture/Intercepted/FirstPlugin.php @@ -0,0 +1,88 @@ +' . $next($param1) . ''; + } + + public function aroundD(Intercepted $subject, \Closure $next, $param1) + { + $this->_counter++; + return '' . $this->_counter . ': ' . $next($param1) . ''; + } + + public function aroundK(Intercepted $subject, \Closure $next, $param1) + { + $result = $subject->C($param1); + return '' . $subject->F($result) . ''; + } + + public function beforeG(Intercepted $subject, $param1) + { + return ['' . $param1 . '']; + } + + public function aroundG(Intercepted $subject, \Closure $next, $param1) + { + return $next('' . $param1 . ''); + } + + public function afterG(Intercepted $subject, $result) + { + return '' . $result . ''; + } + + public function beforeV(Intercepted $subject, $param1) + { + return ['']; + } + + public function aroundV(Intercepted $subject, \Closure $next, $param1) + { + return '' . $param1 . ''; + } + + public function beforeW(Intercepted $subject, $param1) + { + return ['']; + } + + public function aroundW(Intercepted $subject, \Closure $next, $param1) + { + return '' . $param1 . ''; + } + + public function afterW(Intercepted $subject, $result) + { + return ''; + } + + public function beforeX(Intercepted $subject, $param1) + { + return ['']; + } + + public function aroundY(Intercepted $subject, \Closure $next, $param1) + { + return '' . $param1 . ''; + } + + public function afterZ(Intercepted $subject, $result) + { + return ''; + } +} diff --git a/dev/tests/integration/testsuite/Magento/Framework/Interception/Fixture/Intercepted/Plugin.php b/dev/tests/integration/testsuite/Magento/Framework/Interception/Fixture/Intercepted/Plugin.php index 06e04190ae49b..ecfc2133fec2c 100644 --- a/dev/tests/integration/testsuite/Magento/Framework/Interception/Fixture/Intercepted/Plugin.php +++ b/dev/tests/integration/testsuite/Magento/Framework/Interception/Fixture/Intercepted/Plugin.php @@ -45,4 +45,44 @@ public function afterG(Intercepted $subject, $result) { return '' . $result . ''; } + + public function beforeV(Intercepted $subject, $param1) + { + return ['']; + } + + public function aroundV(Intercepted $subject, \Closure $next, $param1) + { + return '' . $param1 . ''; + } + + public function beforeW(Intercepted $subject, $param1) + { + return ['']; + } + + public function aroundW(Intercepted $subject, \Closure $next, $param1) + { + return '' . $param1 . ''; + } + + public function afterW(Intercepted $subject, $result) + { + return ''; + } + + public function beforeX(Intercepted $subject, $param1) + { + return ['']; + } + + public function aroundY(Intercepted $subject, \Closure $next, $param1) + { + return '' . $param1 . ''; + } + + public function afterZ(Intercepted $subject, $result) + { + return ''; + } } diff --git a/dev/tests/integration/testsuite/Magento/Framework/Interception/TwoPluginTest.php b/dev/tests/integration/testsuite/Magento/Framework/Interception/TwoPluginTest.php new file mode 100644 index 0000000000000..0601f01cb5431 --- /dev/null +++ b/dev/tests/integration/testsuite/Magento/Framework/Interception/TwoPluginTest.php @@ -0,0 +1,125 @@ +_configReader = $this->getMock('Magento\Framework\Config\ReaderInterface'); + $this->_configReader->expects( + $this->any() + )->method( + 'read' + )->will( + $this->returnValue( + [ + 'Magento\Framework\Interception\Fixture\Intercepted' => [ + 'plugins' => [ + 'first' => [ + 'instance' => 'Magento\Framework\Interception\Fixture\Intercepted\FirstPlugin', + 'sortOrder' => 10, + ], 'second' => [ + 'instance' => 'Magento\Framework\Interception\Fixture\Intercepted\Plugin', + 'sortOrder' => 20, + ] + ], + ] + ] + ) + ); + + $areaList = $this->getMock('Magento\Framework\App\AreaList', [], [], '', false); + $areaList->expects($this->any())->method('getCodes')->will($this->returnValue([])); + $configScope = new \Magento\Framework\Config\Scope($areaList, 'global'); + $cache = $this->getMock('Magento\Framework\Config\CacheInterface'); + $cache->expects($this->any())->method('load')->will($this->returnValue(false)); + $definitions = new \Magento\Framework\ObjectManager\Definition\Runtime(); + $relations = new \Magento\Framework\ObjectManager\Relations\Runtime(); + $interceptionConfig = new Config\Config( + $this->_configReader, + $configScope, + $cache, + $relations, + $config, + $definitions + ); + $interceptionDefinitions = new Definition\Runtime(); + $this->_objectManager = new \Magento\Framework\ObjectManager\ObjectManager( + $factory, + $config, + [ + 'Magento\Framework\Config\CacheInterface' => $cache, + 'Magento\Framework\Config\ScopeInterface' => $configScope, + 'Magento\Framework\Config\ReaderInterface' => $this->_configReader, + 'Magento\Framework\ObjectManager\RelationsInterface' => $relations, + 'Magento\Framework\ObjectManager\ConfigInterface' => $config, + 'Magento\Framework\Interception\ObjectManager\ConfigInterface' => $config, + 'Magento\Framework\ObjectManager\DefinitionInterface' => $definitions, + 'Magento\Framework\Interception\DefinitionInterface' => $interceptionDefinitions + ] + ); + $factory->setObjectManager($this->_objectManager); + $config->setInterceptionConfig($interceptionConfig); + $config->extend( + [ + 'preferences' => [ + 'Magento\Framework\Interception\PluginListInterface' => + 'Magento\Framework\Interception\PluginList\PluginList', + 'Magento\Framework\Interception\ChainInterface' => 'Magento\Framework\Interception\Chain\Chain', + ], + ] + ); + } + + public function testPluginBeforeWins() + { + $subject = $this->_objectManager->create('Magento\Framework\Interception\Fixture\Intercepted'); + $this->assertEquals('', $subject->X('test')); + } + + public function testPluginAroundWins() + { + $subject = $this->_objectManager->create('Magento\Framework\Interception\Fixture\Intercepted'); + $this->assertEquals('test', $subject->Y('test')); + } + + public function testPluginAfterWins() + { + $subject = $this->_objectManager->create('Magento\Framework\Interception\Fixture\Intercepted'); + $this->assertEquals('', $subject->Z('test')); + } + + public function testPluginBeforeAroundWins() + { + $subject = $this->_objectManager->create('Magento\Framework\Interception\Fixture\Intercepted'); + $this->assertEquals('', $subject->V('test')); + } + public function testPluginBeforeAroundAfterWins() + { + $subject = $this->_objectManager->create('Magento\Framework\Interception\Fixture\Intercepted'); + $this->assertEquals('', $subject->W('test')); + } +} From 2d08d0ddb134d0138397e10c2539c359c93576b1 Mon Sep 17 00:00:00 2001 From: Kristof Ringleff Date: Wed, 14 Jan 2015 19:59:43 +1300 Subject: [PATCH 2/7] remove duplication --- .../Framework/Interception/GeneralTest.php | 62 ++++++------ .../Framework/Interception/TwoPluginTest.php | 94 +++---------------- 2 files changed, 49 insertions(+), 107 deletions(-) diff --git a/dev/tests/integration/testsuite/Magento/Framework/Interception/GeneralTest.php b/dev/tests/integration/testsuite/Magento/Framework/Interception/GeneralTest.php index bd54fecae3c2f..6f11d6c9dbf2f 100644 --- a/dev/tests/integration/testsuite/Magento/Framework/Interception/GeneralTest.php +++ b/dev/tests/integration/testsuite/Magento/Framework/Interception/GeneralTest.php @@ -24,6 +24,30 @@ class GeneralTest extends \PHPUnit_Framework_TestCase protected $_objectManager; public function setUp() + { + $this->setUpInterceptionConfig( + [ + 'Magento\Framework\Interception\Fixture\InterceptedInterface' => [ + 'plugins' => [ + 'first' => [ + 'instance' => 'Magento\Framework\Interception\Fixture\Intercepted\InterfacePlugin', + 'sortOrder' => 10, + ], + ], + ], + 'Magento\Framework\Interception\Fixture\Intercepted' => [ + 'plugins' => [ + 'second' => [ + 'instance' => 'Magento\Framework\Interception\Fixture\Intercepted\Plugin', + 'sortOrder' => 20, + ], + ], + ], + ] + ); + } + + public function setUpInterceptionConfig($pluginConfig) { $config = new \Magento\Framework\Interception\ObjectManager\Config\Developer(); $factory = new \Magento\Framework\ObjectManager\Factory\Dynamic\Developer($config, null); @@ -34,26 +58,7 @@ public function setUp() )->method( 'read' )->will( - $this->returnValue( - [ - 'Magento\Framework\Interception\Fixture\InterceptedInterface' => [ - 'plugins' => [ - 'first' => [ - 'instance' => 'Magento\Framework\Interception\Fixture\Intercepted\InterfacePlugin', - 'sortOrder' => 10, - ], - ], - ], - 'Magento\Framework\Interception\Fixture\Intercepted' => [ - 'plugins' => [ - 'second' => [ - 'instance' => 'Magento\Framework\Interception\Fixture\Intercepted\Plugin', - 'sortOrder' => 20, - ], - ], - ], - ] - ) + $this->returnValue($pluginConfig) ); $areaList = $this->getMock('Magento\Framework\App\AreaList', [], [], '', false); @@ -76,14 +81,14 @@ public function setUp() $factory, $config, [ - 'Magento\Framework\Config\CacheInterface' => $cache, - 'Magento\Framework\Config\ScopeInterface' => $configScope, - 'Magento\Framework\Config\ReaderInterface' => $this->_configReader, - 'Magento\Framework\ObjectManager\RelationsInterface' => $relations, - 'Magento\Framework\ObjectManager\ConfigInterface' => $config, + 'Magento\Framework\Config\CacheInterface' => $cache, + 'Magento\Framework\Config\ScopeInterface' => $configScope, + 'Magento\Framework\Config\ReaderInterface' => $this->_configReader, + 'Magento\Framework\ObjectManager\RelationsInterface' => $relations, + 'Magento\Framework\ObjectManager\ConfigInterface' => $config, 'Magento\Framework\Interception\ObjectManager\ConfigInterface' => $config, - 'Magento\Framework\ObjectManager\DefinitionInterface' => $definitions, - 'Magento\Framework\Interception\DefinitionInterface' => $interceptionDefinitions + 'Magento\Framework\ObjectManager\DefinitionInterface' => $definitions, + 'Magento\Framework\Interception\DefinitionInterface' => $interceptionDefinitions ] ); $factory->setObjectManager($this->_objectManager); @@ -93,7 +98,8 @@ public function setUp() 'preferences' => [ 'Magento\Framework\Interception\PluginListInterface' => 'Magento\Framework\Interception\PluginList\PluginList', - 'Magento\Framework\Interception\ChainInterface' => 'Magento\Framework\Interception\Chain\Chain', + 'Magento\Framework\Interception\ChainInterface' => + 'Magento\Framework\Interception\Chain\Chain', ], ] ); diff --git a/dev/tests/integration/testsuite/Magento/Framework/Interception/TwoPluginTest.php b/dev/tests/integration/testsuite/Magento/Framework/Interception/TwoPluginTest.php index 0601f01cb5431..33217909e079f 100644 --- a/dev/tests/integration/testsuite/Magento/Framework/Interception/TwoPluginTest.php +++ b/dev/tests/integration/testsuite/Magento/Framework/Interception/TwoPluginTest.php @@ -5,91 +5,26 @@ */ namespace Magento\Framework\Interception; -use Magento\Framework\ObjectManager\Config\Config as ObjectManagerConfig; - /** - * Class GeneralTest - * @SuppressWarnings(PHPMD.CouplingBetweenObjects) + * Class TwoPluginTest */ -class TwoPluginTest extends \PHPUnit_Framework_TestCase +class TwoPluginTest extends GeneralTest { - /** - * @var \PHPUnit_Framework_MockObject_MockObject - */ - protected $_configReader; - - /** - * @var \Magento\Framework\ObjectManagerInterface - */ - protected $_objectManager; - public function setUp() { - $config = new \Magento\Framework\Interception\ObjectManager\Config\Developer(); - $factory = new \Magento\Framework\ObjectManager\Factory\Dynamic\Developer($config, null); - - $this->_configReader = $this->getMock('Magento\Framework\Config\ReaderInterface'); - $this->_configReader->expects( - $this->any() - )->method( - 'read' - )->will( - $this->returnValue( - [ - 'Magento\Framework\Interception\Fixture\Intercepted' => [ - 'plugins' => [ - 'first' => [ - 'instance' => 'Magento\Framework\Interception\Fixture\Intercepted\FirstPlugin', - 'sortOrder' => 10, - ], 'second' => [ - 'instance' => 'Magento\Framework\Interception\Fixture\Intercepted\Plugin', - 'sortOrder' => 20, - ] - ], - ] - ] - ) - ); - - $areaList = $this->getMock('Magento\Framework\App\AreaList', [], [], '', false); - $areaList->expects($this->any())->method('getCodes')->will($this->returnValue([])); - $configScope = new \Magento\Framework\Config\Scope($areaList, 'global'); - $cache = $this->getMock('Magento\Framework\Config\CacheInterface'); - $cache->expects($this->any())->method('load')->will($this->returnValue(false)); - $definitions = new \Magento\Framework\ObjectManager\Definition\Runtime(); - $relations = new \Magento\Framework\ObjectManager\Relations\Runtime(); - $interceptionConfig = new Config\Config( - $this->_configReader, - $configScope, - $cache, - $relations, - $config, - $definitions - ); - $interceptionDefinitions = new Definition\Runtime(); - $this->_objectManager = new \Magento\Framework\ObjectManager\ObjectManager( - $factory, - $config, - [ - 'Magento\Framework\Config\CacheInterface' => $cache, - 'Magento\Framework\Config\ScopeInterface' => $configScope, - 'Magento\Framework\Config\ReaderInterface' => $this->_configReader, - 'Magento\Framework\ObjectManager\RelationsInterface' => $relations, - 'Magento\Framework\ObjectManager\ConfigInterface' => $config, - 'Magento\Framework\Interception\ObjectManager\ConfigInterface' => $config, - 'Magento\Framework\ObjectManager\DefinitionInterface' => $definitions, - 'Magento\Framework\Interception\DefinitionInterface' => $interceptionDefinitions - ] - ); - $factory->setObjectManager($this->_objectManager); - $config->setInterceptionConfig($interceptionConfig); - $config->extend( + $this->setUpInterceptionConfig( [ - 'preferences' => [ - 'Magento\Framework\Interception\PluginListInterface' => - 'Magento\Framework\Interception\PluginList\PluginList', - 'Magento\Framework\Interception\ChainInterface' => 'Magento\Framework\Interception\Chain\Chain', - ], + 'Magento\Framework\Interception\Fixture\Intercepted' => [ + 'plugins' => [ + 'first' => [ + 'instance' => 'Magento\Framework\Interception\Fixture\Intercepted\FirstPlugin', + 'sortOrder' => 10, + ], 'second' => [ + 'instance' => 'Magento\Framework\Interception\Fixture\Intercepted\Plugin', + 'sortOrder' => 20, + ] + ], + ] ] ); } @@ -117,6 +52,7 @@ public function testPluginBeforeAroundWins() $subject = $this->_objectManager->create('Magento\Framework\Interception\Fixture\Intercepted'); $this->assertEquals('', $subject->V('test')); } + public function testPluginBeforeAroundAfterWins() { $subject = $this->_objectManager->create('Magento\Framework\Interception\Fixture\Intercepted'); From 0ead4b876133fbda2f4bec3bda25584dd929358d Mon Sep 17 00:00:00 2001 From: Kristof Ringleff Date: Wed, 14 Jan 2015 21:01:45 +1300 Subject: [PATCH 3/7] fix inheritance --- .../Framework/Interception/AbstractPlugin.php | 73 ++++++++++++++++ .../Framework/Interception/GeneralTest.php | 86 ++++--------------- .../Framework/Interception/TwoPluginTest.php | 2 +- 3 files changed, 89 insertions(+), 72 deletions(-) create mode 100644 dev/tests/integration/testsuite/Magento/Framework/Interception/AbstractPlugin.php diff --git a/dev/tests/integration/testsuite/Magento/Framework/Interception/AbstractPlugin.php b/dev/tests/integration/testsuite/Magento/Framework/Interception/AbstractPlugin.php new file mode 100644 index 0000000000000..5201891a8c226 --- /dev/null +++ b/dev/tests/integration/testsuite/Magento/Framework/Interception/AbstractPlugin.php @@ -0,0 +1,73 @@ +_configReader = $this->getMock('Magento\Framework\Config\ReaderInterface'); + $this->_configReader->expects( + $this->any() + )->method( + 'read' + )->will( + $this->returnValue($pluginConfig) + ); + + $areaList = $this->getMock('Magento\Framework\App\AreaList', [], [], '', false); + $areaList->expects($this->any())->method('getCodes')->will($this->returnValue([])); + $configScope = new \Magento\Framework\Config\Scope($areaList, 'global'); + $cache = $this->getMock('Magento\Framework\Config\CacheInterface'); + $cache->expects($this->any())->method('load')->will($this->returnValue(false)); + $definitions = new \Magento\Framework\ObjectManager\Definition\Runtime(); + $relations = new \Magento\Framework\ObjectManager\Relations\Runtime(); + $interceptionConfig = new Config\Config( + $this->_configReader, + $configScope, + $cache, + $relations, + $config, + $definitions + ); + $interceptionDefinitions = new Definition\Runtime(); + $this->_objectManager = new \Magento\Framework\ObjectManager\ObjectManager( + $factory, + $config, + [ + 'Magento\Framework\Config\CacheInterface' => $cache, + 'Magento\Framework\Config\ScopeInterface' => $configScope, + 'Magento\Framework\Config\ReaderInterface' => $this->_configReader, + 'Magento\Framework\ObjectManager\RelationsInterface' => $relations, + 'Magento\Framework\ObjectManager\ConfigInterface' => $config, + 'Magento\Framework\Interception\ObjectManager\ConfigInterface' => $config, + 'Magento\Framework\ObjectManager\DefinitionInterface' => $definitions, + 'Magento\Framework\Interception\DefinitionInterface' => $interceptionDefinitions + ] + ); + $factory->setObjectManager($this->_objectManager); + $config->setInterceptionConfig($interceptionConfig); + $config->extend( + [ + 'preferences' => [ + 'Magento\Framework\Interception\PluginListInterface' => + 'Magento\Framework\Interception\PluginList\PluginList', + 'Magento\Framework\Interception\ChainInterface' => + 'Magento\Framework\Interception\Chain\Chain', + ], + ] + ); + } +} diff --git a/dev/tests/integration/testsuite/Magento/Framework/Interception/GeneralTest.php b/dev/tests/integration/testsuite/Magento/Framework/Interception/GeneralTest.php index 6f11d6c9dbf2f..bcd6c751e4af6 100644 --- a/dev/tests/integration/testsuite/Magento/Framework/Interception/GeneralTest.php +++ b/dev/tests/integration/testsuite/Magento/Framework/Interception/GeneralTest.php @@ -11,7 +11,7 @@ * Class GeneralTest * @SuppressWarnings(PHPMD.CouplingBetweenObjects) */ -class GeneralTest extends \PHPUnit_Framework_TestCase +class GeneralTest extends AbstractPlugin { /** * @var \PHPUnit_Framework_MockObject_MockObject @@ -27,80 +27,24 @@ public function setUp() { $this->setUpInterceptionConfig( [ - 'Magento\Framework\Interception\Fixture\InterceptedInterface' => [ - 'plugins' => [ - 'first' => [ - 'instance' => 'Magento\Framework\Interception\Fixture\Intercepted\InterfacePlugin', - 'sortOrder' => 10, + 'Magento\Framework\Interception\Fixture\InterceptedInterface' => + [ + 'plugins' => [ + 'first' => [ + 'instance' => 'Magento\Framework\Interception\Fixture\Intercepted\InterfacePlugin', + 'sortOrder' => 10, + ], ], ], - ], - 'Magento\Framework\Interception\Fixture\Intercepted' => [ - 'plugins' => [ - 'second' => [ - 'instance' => 'Magento\Framework\Interception\Fixture\Intercepted\Plugin', - 'sortOrder' => 20, + 'Magento\Framework\Interception\Fixture\Intercepted' => + [ + 'plugins' => [ + 'second' => [ + 'instance' => 'Magento\Framework\Interception\Fixture\Intercepted\Plugin', + 'sortOrder' => 20, + ], ], ], - ], - ] - ); - } - - public function setUpInterceptionConfig($pluginConfig) - { - $config = new \Magento\Framework\Interception\ObjectManager\Config\Developer(); - $factory = new \Magento\Framework\ObjectManager\Factory\Dynamic\Developer($config, null); - - $this->_configReader = $this->getMock('Magento\Framework\Config\ReaderInterface'); - $this->_configReader->expects( - $this->any() - )->method( - 'read' - )->will( - $this->returnValue($pluginConfig) - ); - - $areaList = $this->getMock('Magento\Framework\App\AreaList', [], [], '', false); - $areaList->expects($this->any())->method('getCodes')->will($this->returnValue([])); - $configScope = new \Magento\Framework\Config\Scope($areaList, 'global'); - $cache = $this->getMock('Magento\Framework\Config\CacheInterface'); - $cache->expects($this->any())->method('load')->will($this->returnValue(false)); - $definitions = new \Magento\Framework\ObjectManager\Definition\Runtime(); - $relations = new \Magento\Framework\ObjectManager\Relations\Runtime(); - $interceptionConfig = new Config\Config( - $this->_configReader, - $configScope, - $cache, - $relations, - $config, - $definitions - ); - $interceptionDefinitions = new Definition\Runtime(); - $this->_objectManager = new \Magento\Framework\ObjectManager\ObjectManager( - $factory, - $config, - [ - 'Magento\Framework\Config\CacheInterface' => $cache, - 'Magento\Framework\Config\ScopeInterface' => $configScope, - 'Magento\Framework\Config\ReaderInterface' => $this->_configReader, - 'Magento\Framework\ObjectManager\RelationsInterface' => $relations, - 'Magento\Framework\ObjectManager\ConfigInterface' => $config, - 'Magento\Framework\Interception\ObjectManager\ConfigInterface' => $config, - 'Magento\Framework\ObjectManager\DefinitionInterface' => $definitions, - 'Magento\Framework\Interception\DefinitionInterface' => $interceptionDefinitions - ] - ); - $factory->setObjectManager($this->_objectManager); - $config->setInterceptionConfig($interceptionConfig); - $config->extend( - [ - 'preferences' => [ - 'Magento\Framework\Interception\PluginListInterface' => - 'Magento\Framework\Interception\PluginList\PluginList', - 'Magento\Framework\Interception\ChainInterface' => - 'Magento\Framework\Interception\Chain\Chain', - ], ] ); } diff --git a/dev/tests/integration/testsuite/Magento/Framework/Interception/TwoPluginTest.php b/dev/tests/integration/testsuite/Magento/Framework/Interception/TwoPluginTest.php index 33217909e079f..8a0c2e8c1e9ba 100644 --- a/dev/tests/integration/testsuite/Magento/Framework/Interception/TwoPluginTest.php +++ b/dev/tests/integration/testsuite/Magento/Framework/Interception/TwoPluginTest.php @@ -8,7 +8,7 @@ /** * Class TwoPluginTest */ -class TwoPluginTest extends GeneralTest +class TwoPluginTest extends AbstractPlugin { public function setUp() { From 6e9947fcfa6997f6225edee2e1bdc5ad4dd44022 Mon Sep 17 00:00:00 2001 From: Kristof Ringleff Date: Thu, 15 Jan 2015 07:30:40 +1300 Subject: [PATCH 4/7] fix W return values --- .../Interception/Fixture/Intercepted/FirstPlugin.php | 4 ++-- .../Framework/Interception/Fixture/Intercepted/Plugin.php | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/dev/tests/integration/testsuite/Magento/Framework/Interception/Fixture/Intercepted/FirstPlugin.php b/dev/tests/integration/testsuite/Magento/Framework/Interception/Fixture/Intercepted/FirstPlugin.php index 4c2d39a51d0ff..a98e48ef926c9 100644 --- a/dev/tests/integration/testsuite/Magento/Framework/Interception/Fixture/Intercepted/FirstPlugin.php +++ b/dev/tests/integration/testsuite/Magento/Framework/Interception/Fixture/Intercepted/FirstPlugin.php @@ -58,12 +58,12 @@ public function aroundV(Intercepted $subject, \Closure $next, $param1) public function beforeW(Intercepted $subject, $param1) { - return ['']; + return ['']; } public function aroundW(Intercepted $subject, \Closure $next, $param1) { - return '' . $param1 . ''; + return '' . $param1 . ''; } public function afterW(Intercepted $subject, $result) diff --git a/dev/tests/integration/testsuite/Magento/Framework/Interception/Fixture/Intercepted/Plugin.php b/dev/tests/integration/testsuite/Magento/Framework/Interception/Fixture/Intercepted/Plugin.php index ecfc2133fec2c..df0eb523b96d6 100644 --- a/dev/tests/integration/testsuite/Magento/Framework/Interception/Fixture/Intercepted/Plugin.php +++ b/dev/tests/integration/testsuite/Magento/Framework/Interception/Fixture/Intercepted/Plugin.php @@ -58,12 +58,12 @@ public function aroundV(Intercepted $subject, \Closure $next, $param1) public function beforeW(Intercepted $subject, $param1) { - return ['']; + return ['']; } public function aroundW(Intercepted $subject, \Closure $next, $param1) { - return '' . $param1 . ''; + return '' . $param1 . ''; } public function afterW(Intercepted $subject, $result) From 7d44c20c7b9dd4c32848e4098c20f22f6f363302 Mon Sep 17 00:00:00 2001 From: Christopher O'Toole Date: Thu, 22 Jan 2015 16:43:10 -0600 Subject: [PATCH 5/7] MAGETWO-32870: [GITHUB] extra tests for current interception behavior #965 - Fixed license headers - Moved fields from GeneralTest to AbstractPlugin --- .../Framework/Interception/AbstractPlugin.php | 17 +++++++++++++---- .../Framework/Interception/GeneralTest.php | 11 ----------- .../Framework/Interception/TwoPluginTest.php | 4 ++-- 3 files changed, 15 insertions(+), 17 deletions(-) diff --git a/dev/tests/integration/testsuite/Magento/Framework/Interception/AbstractPlugin.php b/dev/tests/integration/testsuite/Magento/Framework/Interception/AbstractPlugin.php index 5201891a8c226..1539ad87f28df 100644 --- a/dev/tests/integration/testsuite/Magento/Framework/Interception/AbstractPlugin.php +++ b/dev/tests/integration/testsuite/Magento/Framework/Interception/AbstractPlugin.php @@ -1,18 +1,27 @@ setUpInterceptionConfig( diff --git a/dev/tests/integration/testsuite/Magento/Framework/Interception/TwoPluginTest.php b/dev/tests/integration/testsuite/Magento/Framework/Interception/TwoPluginTest.php index 8a0c2e8c1e9ba..a4cbcd18f1103 100644 --- a/dev/tests/integration/testsuite/Magento/Framework/Interception/TwoPluginTest.php +++ b/dev/tests/integration/testsuite/Magento/Framework/Interception/TwoPluginTest.php @@ -1,7 +1,7 @@ Date: Fri, 23 Jan 2015 14:35:58 -0600 Subject: [PATCH 6/7] MAGETWO-32870: [GITHUB] extra tests for current interception behavior #965 - Fix license header in FirstPlugin --- .../Interception/Fixture/Intercepted/FirstPlugin.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/dev/tests/integration/testsuite/Magento/Framework/Interception/Fixture/Intercepted/FirstPlugin.php b/dev/tests/integration/testsuite/Magento/Framework/Interception/Fixture/Intercepted/FirstPlugin.php index a98e48ef926c9..596f8c38d72ce 100644 --- a/dev/tests/integration/testsuite/Magento/Framework/Interception/Fixture/Intercepted/FirstPlugin.php +++ b/dev/tests/integration/testsuite/Magento/Framework/Interception/Fixture/Intercepted/FirstPlugin.php @@ -1,7 +1,7 @@ Date: Mon, 26 Jan 2015 09:01:00 -0600 Subject: [PATCH 7/7] MAGETWO-32870: [GITHUB] extra tests for current interception behavior #965 - Suppress warnings for test fixtures --- .../Interception/Fixture/Intercepted.php | 15 +++++++ .../Fixture/Intercepted/FirstPlugin.php | 42 +++++++++++++++++++ .../Fixture/Intercepted/Plugin.php | 24 +++++++++++ 3 files changed, 81 insertions(+) diff --git a/dev/tests/integration/testsuite/Magento/Framework/Interception/Fixture/Intercepted.php b/dev/tests/integration/testsuite/Magento/Framework/Interception/Fixture/Intercepted.php index 6248d50fea221..6213b569b94e5 100644 --- a/dev/tests/integration/testsuite/Magento/Framework/Interception/Fixture/Intercepted.php +++ b/dev/tests/integration/testsuite/Magento/Framework/Interception/Fixture/Intercepted.php @@ -78,26 +78,41 @@ public function K($param1) return '' . $param1 . ''; } + /** + * @SuppressWarnings(PHPMD.ShortMethodName) + */ public function V($param1) { return '' . $param1 . ''; } + /** + * @SuppressWarnings(PHPMD.ShortMethodName) + */ public function W($param1) { return '' . $param1 . ''; } + /** + * @SuppressWarnings(PHPMD.ShortMethodName) + */ public function X($param1) { return '' . $param1 . ''; } + /** + * @SuppressWarnings(PHPMD.ShortMethodName) + */ public function Y($param1) { return '' . $param1 . ''; } + /** + * @SuppressWarnings(PHPMD.ShortMethodName) + */ public function Z($param1) { return '' . $param1 . ''; diff --git a/dev/tests/integration/testsuite/Magento/Framework/Interception/Fixture/Intercepted/FirstPlugin.php b/dev/tests/integration/testsuite/Magento/Framework/Interception/Fixture/Intercepted/FirstPlugin.php index 596f8c38d72ce..3babf53be8f8e 100644 --- a/dev/tests/integration/testsuite/Magento/Framework/Interception/Fixture/Intercepted/FirstPlugin.php +++ b/dev/tests/integration/testsuite/Magento/Framework/Interception/Fixture/Intercepted/FirstPlugin.php @@ -14,73 +14,115 @@ class FirstPlugin */ protected $_counter = 0; + /** + * @SuppressWarnings(PHPMD.UnusedFormalParameter) + */ public function aroundC(Intercepted $subject, \Closure $next, $param1) { return '' . $next($param1) . ''; } + /** + * @SuppressWarnings(PHPMD.UnusedFormalParameter) + */ public function aroundD(Intercepted $subject, \Closure $next, $param1) { $this->_counter++; return '' . $this->_counter . ': ' . $next($param1) . ''; } + /** + * @SuppressWarnings(PHPMD.UnusedFormalParameter) + */ public function aroundK(Intercepted $subject, \Closure $next, $param1) { $result = $subject->C($param1); return '' . $subject->F($result) . ''; } + /** + * @SuppressWarnings(PHPMD.UnusedFormalParameter) + */ public function beforeG(Intercepted $subject, $param1) { return ['' . $param1 . '']; } + /** + * @SuppressWarnings(PHPMD.UnusedFormalParameter) + */ public function aroundG(Intercepted $subject, \Closure $next, $param1) { return $next('' . $param1 . ''); } + /** + * @SuppressWarnings(PHPMD.UnusedFormalParameter) + */ public function afterG(Intercepted $subject, $result) { return '' . $result . ''; } + /** + * @SuppressWarnings(PHPMD.UnusedFormalParameter) + */ public function beforeV(Intercepted $subject, $param1) { return ['']; } + /** + * @SuppressWarnings(PHPMD.UnusedFormalParameter) + */ public function aroundV(Intercepted $subject, \Closure $next, $param1) { return '' . $param1 . ''; } + /** + * @SuppressWarnings(PHPMD.UnusedFormalParameter) + */ public function beforeW(Intercepted $subject, $param1) { return ['']; } + /** + * @SuppressWarnings(PHPMD.UnusedFormalParameter) + */ public function aroundW(Intercepted $subject, \Closure $next, $param1) { return '' . $param1 . ''; } + /** + * @SuppressWarnings(PHPMD.UnusedFormalParameter) + */ public function afterW(Intercepted $subject, $result) { return ''; } + /** + * @SuppressWarnings(PHPMD.UnusedFormalParameter) + */ public function beforeX(Intercepted $subject, $param1) { return ['']; } + /** + * @SuppressWarnings(PHPMD.UnusedFormalParameter) + */ public function aroundY(Intercepted $subject, \Closure $next, $param1) { return '' . $param1 . ''; } + /** + * @SuppressWarnings(PHPMD.UnusedFormalParameter) + */ public function afterZ(Intercepted $subject, $result) { return ''; diff --git a/dev/tests/integration/testsuite/Magento/Framework/Interception/Fixture/Intercepted/Plugin.php b/dev/tests/integration/testsuite/Magento/Framework/Interception/Fixture/Intercepted/Plugin.php index e8155a4d58924..fab9c11c709fe 100644 --- a/dev/tests/integration/testsuite/Magento/Framework/Interception/Fixture/Intercepted/Plugin.php +++ b/dev/tests/integration/testsuite/Magento/Framework/Interception/Fixture/Intercepted/Plugin.php @@ -65,41 +65,65 @@ public function afterG(Intercepted $subject, $result) return '' . $result . ''; } + /** + * @SuppressWarnings(PHPMD.UnusedFormalParameter) + */ public function beforeV(Intercepted $subject, $param1) { return ['']; } + /** + * @SuppressWarnings(PHPMD.UnusedFormalParameter) + */ public function aroundV(Intercepted $subject, \Closure $next, $param1) { return '' . $param1 . ''; } + /** + * @SuppressWarnings(PHPMD.UnusedFormalParameter) + */ public function beforeW(Intercepted $subject, $param1) { return ['']; } + /** + * @SuppressWarnings(PHPMD.UnusedFormalParameter) + */ public function aroundW(Intercepted $subject, \Closure $next, $param1) { return '' . $param1 . ''; } + /** + * @SuppressWarnings(PHPMD.UnusedFormalParameter) + */ public function afterW(Intercepted $subject, $result) { return ''; } + /** + * @SuppressWarnings(PHPMD.UnusedFormalParameter) + */ public function beforeX(Intercepted $subject, $param1) { return ['']; } + /** + * @SuppressWarnings(PHPMD.UnusedFormalParameter) + */ public function aroundY(Intercepted $subject, \Closure $next, $param1) { return '' . $param1 . ''; } + /** + * @SuppressWarnings(PHPMD.UnusedFormalParameter) + */ public function afterZ(Intercepted $subject, $result) { return '';