Skip to content

Commit 2d08d0d

Browse files
remove duplication
1 parent ba91818 commit 2d08d0d

File tree

2 files changed

+49
-107
lines changed

2 files changed

+49
-107
lines changed

dev/tests/integration/testsuite/Magento/Framework/Interception/GeneralTest.php

Lines changed: 34 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,30 @@ class GeneralTest extends \PHPUnit_Framework_TestCase
2424
protected $_objectManager;
2525

2626
public function setUp()
27+
{
28+
$this->setUpInterceptionConfig(
29+
[
30+
'Magento\Framework\Interception\Fixture\InterceptedInterface' => [
31+
'plugins' => [
32+
'first' => [
33+
'instance' => 'Magento\Framework\Interception\Fixture\Intercepted\InterfacePlugin',
34+
'sortOrder' => 10,
35+
],
36+
],
37+
],
38+
'Magento\Framework\Interception\Fixture\Intercepted' => [
39+
'plugins' => [
40+
'second' => [
41+
'instance' => 'Magento\Framework\Interception\Fixture\Intercepted\Plugin',
42+
'sortOrder' => 20,
43+
],
44+
],
45+
],
46+
]
47+
);
48+
}
49+
50+
public function setUpInterceptionConfig($pluginConfig)
2751
{
2852
$config = new \Magento\Framework\Interception\ObjectManager\Config\Developer();
2953
$factory = new \Magento\Framework\ObjectManager\Factory\Dynamic\Developer($config, null);
@@ -34,26 +58,7 @@ public function setUp()
3458
)->method(
3559
'read'
3660
)->will(
37-
$this->returnValue(
38-
[
39-
'Magento\Framework\Interception\Fixture\InterceptedInterface' => [
40-
'plugins' => [
41-
'first' => [
42-
'instance' => 'Magento\Framework\Interception\Fixture\Intercepted\InterfacePlugin',
43-
'sortOrder' => 10,
44-
],
45-
],
46-
],
47-
'Magento\Framework\Interception\Fixture\Intercepted' => [
48-
'plugins' => [
49-
'second' => [
50-
'instance' => 'Magento\Framework\Interception\Fixture\Intercepted\Plugin',
51-
'sortOrder' => 20,
52-
],
53-
],
54-
],
55-
]
56-
)
61+
$this->returnValue($pluginConfig)
5762
);
5863

5964
$areaList = $this->getMock('Magento\Framework\App\AreaList', [], [], '', false);
@@ -76,14 +81,14 @@ public function setUp()
7681
$factory,
7782
$config,
7883
[
79-
'Magento\Framework\Config\CacheInterface' => $cache,
80-
'Magento\Framework\Config\ScopeInterface' => $configScope,
81-
'Magento\Framework\Config\ReaderInterface' => $this->_configReader,
82-
'Magento\Framework\ObjectManager\RelationsInterface' => $relations,
83-
'Magento\Framework\ObjectManager\ConfigInterface' => $config,
84+
'Magento\Framework\Config\CacheInterface' => $cache,
85+
'Magento\Framework\Config\ScopeInterface' => $configScope,
86+
'Magento\Framework\Config\ReaderInterface' => $this->_configReader,
87+
'Magento\Framework\ObjectManager\RelationsInterface' => $relations,
88+
'Magento\Framework\ObjectManager\ConfigInterface' => $config,
8489
'Magento\Framework\Interception\ObjectManager\ConfigInterface' => $config,
85-
'Magento\Framework\ObjectManager\DefinitionInterface' => $definitions,
86-
'Magento\Framework\Interception\DefinitionInterface' => $interceptionDefinitions
90+
'Magento\Framework\ObjectManager\DefinitionInterface' => $definitions,
91+
'Magento\Framework\Interception\DefinitionInterface' => $interceptionDefinitions
8792
]
8893
);
8994
$factory->setObjectManager($this->_objectManager);
@@ -93,7 +98,8 @@ public function setUp()
9398
'preferences' => [
9499
'Magento\Framework\Interception\PluginListInterface' =>
95100
'Magento\Framework\Interception\PluginList\PluginList',
96-
'Magento\Framework\Interception\ChainInterface' => 'Magento\Framework\Interception\Chain\Chain',
101+
'Magento\Framework\Interception\ChainInterface' =>
102+
'Magento\Framework\Interception\Chain\Chain',
97103
],
98104
]
99105
);

dev/tests/integration/testsuite/Magento/Framework/Interception/TwoPluginTest.php

Lines changed: 15 additions & 79 deletions
Original file line numberDiff line numberDiff line change
@@ -5,91 +5,26 @@
55
*/
66
namespace Magento\Framework\Interception;
77

8-
use Magento\Framework\ObjectManager\Config\Config as ObjectManagerConfig;
9-
108
/**
11-
* Class GeneralTest
12-
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
9+
* Class TwoPluginTest
1310
*/
14-
class TwoPluginTest extends \PHPUnit_Framework_TestCase
11+
class TwoPluginTest extends GeneralTest
1512
{
16-
/**
17-
* @var \PHPUnit_Framework_MockObject_MockObject
18-
*/
19-
protected $_configReader;
20-
21-
/**
22-
* @var \Magento\Framework\ObjectManagerInterface
23-
*/
24-
protected $_objectManager;
25-
2613
public function setUp()
2714
{
28-
$config = new \Magento\Framework\Interception\ObjectManager\Config\Developer();
29-
$factory = new \Magento\Framework\ObjectManager\Factory\Dynamic\Developer($config, null);
30-
31-
$this->_configReader = $this->getMock('Magento\Framework\Config\ReaderInterface');
32-
$this->_configReader->expects(
33-
$this->any()
34-
)->method(
35-
'read'
36-
)->will(
37-
$this->returnValue(
38-
[
39-
'Magento\Framework\Interception\Fixture\Intercepted' => [
40-
'plugins' => [
41-
'first' => [
42-
'instance' => 'Magento\Framework\Interception\Fixture\Intercepted\FirstPlugin',
43-
'sortOrder' => 10,
44-
], 'second' => [
45-
'instance' => 'Magento\Framework\Interception\Fixture\Intercepted\Plugin',
46-
'sortOrder' => 20,
47-
]
48-
],
49-
]
50-
]
51-
)
52-
);
53-
54-
$areaList = $this->getMock('Magento\Framework\App\AreaList', [], [], '', false);
55-
$areaList->expects($this->any())->method('getCodes')->will($this->returnValue([]));
56-
$configScope = new \Magento\Framework\Config\Scope($areaList, 'global');
57-
$cache = $this->getMock('Magento\Framework\Config\CacheInterface');
58-
$cache->expects($this->any())->method('load')->will($this->returnValue(false));
59-
$definitions = new \Magento\Framework\ObjectManager\Definition\Runtime();
60-
$relations = new \Magento\Framework\ObjectManager\Relations\Runtime();
61-
$interceptionConfig = new Config\Config(
62-
$this->_configReader,
63-
$configScope,
64-
$cache,
65-
$relations,
66-
$config,
67-
$definitions
68-
);
69-
$interceptionDefinitions = new Definition\Runtime();
70-
$this->_objectManager = new \Magento\Framework\ObjectManager\ObjectManager(
71-
$factory,
72-
$config,
73-
[
74-
'Magento\Framework\Config\CacheInterface' => $cache,
75-
'Magento\Framework\Config\ScopeInterface' => $configScope,
76-
'Magento\Framework\Config\ReaderInterface' => $this->_configReader,
77-
'Magento\Framework\ObjectManager\RelationsInterface' => $relations,
78-
'Magento\Framework\ObjectManager\ConfigInterface' => $config,
79-
'Magento\Framework\Interception\ObjectManager\ConfigInterface' => $config,
80-
'Magento\Framework\ObjectManager\DefinitionInterface' => $definitions,
81-
'Magento\Framework\Interception\DefinitionInterface' => $interceptionDefinitions
82-
]
83-
);
84-
$factory->setObjectManager($this->_objectManager);
85-
$config->setInterceptionConfig($interceptionConfig);
86-
$config->extend(
15+
$this->setUpInterceptionConfig(
8716
[
88-
'preferences' => [
89-
'Magento\Framework\Interception\PluginListInterface' =>
90-
'Magento\Framework\Interception\PluginList\PluginList',
91-
'Magento\Framework\Interception\ChainInterface' => 'Magento\Framework\Interception\Chain\Chain',
92-
],
17+
'Magento\Framework\Interception\Fixture\Intercepted' => [
18+
'plugins' => [
19+
'first' => [
20+
'instance' => 'Magento\Framework\Interception\Fixture\Intercepted\FirstPlugin',
21+
'sortOrder' => 10,
22+
], 'second' => [
23+
'instance' => 'Magento\Framework\Interception\Fixture\Intercepted\Plugin',
24+
'sortOrder' => 20,
25+
]
26+
],
27+
]
9328
]
9429
);
9530
}
@@ -117,6 +52,7 @@ public function testPluginBeforeAroundWins()
11752
$subject = $this->_objectManager->create('Magento\Framework\Interception\Fixture\Intercepted');
11853
$this->assertEquals('<F:V><F:bV/><F:V/>', $subject->V('test'));
11954
}
55+
12056
public function testPluginBeforeAroundAfterWins()
12157
{
12258
$subject = $this->_objectManager->create('Magento\Framework\Interception\Fixture\Intercepted');

0 commit comments

Comments
 (0)