Skip to content

Commit 0ead4b8

Browse files
fix inheritance
1 parent 2d08d0d commit 0ead4b8

File tree

3 files changed

+89
-72
lines changed

3 files changed

+89
-72
lines changed
Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
<?php
2+
/**
3+
*
4+
* @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
5+
*/
6+
namespace Magento\Framework\Interception;
7+
8+
use Magento\Framework\ObjectManager\Config\Config as ObjectManagerConfig;
9+
10+
/**
11+
* Class GeneralTest
12+
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
13+
*/
14+
abstract class AbstractPlugin extends \PHPUnit_Framework_TestCase
15+
{
16+
public function setUpInterceptionConfig($pluginConfig)
17+
{
18+
$config = new \Magento\Framework\Interception\ObjectManager\Config\Developer();
19+
$factory = new \Magento\Framework\ObjectManager\Factory\Dynamic\Developer($config, null);
20+
21+
$this->_configReader = $this->getMock('Magento\Framework\Config\ReaderInterface');
22+
$this->_configReader->expects(
23+
$this->any()
24+
)->method(
25+
'read'
26+
)->will(
27+
$this->returnValue($pluginConfig)
28+
);
29+
30+
$areaList = $this->getMock('Magento\Framework\App\AreaList', [], [], '', false);
31+
$areaList->expects($this->any())->method('getCodes')->will($this->returnValue([]));
32+
$configScope = new \Magento\Framework\Config\Scope($areaList, 'global');
33+
$cache = $this->getMock('Magento\Framework\Config\CacheInterface');
34+
$cache->expects($this->any())->method('load')->will($this->returnValue(false));
35+
$definitions = new \Magento\Framework\ObjectManager\Definition\Runtime();
36+
$relations = new \Magento\Framework\ObjectManager\Relations\Runtime();
37+
$interceptionConfig = new Config\Config(
38+
$this->_configReader,
39+
$configScope,
40+
$cache,
41+
$relations,
42+
$config,
43+
$definitions
44+
);
45+
$interceptionDefinitions = new Definition\Runtime();
46+
$this->_objectManager = new \Magento\Framework\ObjectManager\ObjectManager(
47+
$factory,
48+
$config,
49+
[
50+
'Magento\Framework\Config\CacheInterface' => $cache,
51+
'Magento\Framework\Config\ScopeInterface' => $configScope,
52+
'Magento\Framework\Config\ReaderInterface' => $this->_configReader,
53+
'Magento\Framework\ObjectManager\RelationsInterface' => $relations,
54+
'Magento\Framework\ObjectManager\ConfigInterface' => $config,
55+
'Magento\Framework\Interception\ObjectManager\ConfigInterface' => $config,
56+
'Magento\Framework\ObjectManager\DefinitionInterface' => $definitions,
57+
'Magento\Framework\Interception\DefinitionInterface' => $interceptionDefinitions
58+
]
59+
);
60+
$factory->setObjectManager($this->_objectManager);
61+
$config->setInterceptionConfig($interceptionConfig);
62+
$config->extend(
63+
[
64+
'preferences' => [
65+
'Magento\Framework\Interception\PluginListInterface' =>
66+
'Magento\Framework\Interception\PluginList\PluginList',
67+
'Magento\Framework\Interception\ChainInterface' =>
68+
'Magento\Framework\Interception\Chain\Chain',
69+
],
70+
]
71+
);
72+
}
73+
}

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

Lines changed: 15 additions & 71 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
* Class GeneralTest
1212
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
1313
*/
14-
class GeneralTest extends \PHPUnit_Framework_TestCase
14+
class GeneralTest extends AbstractPlugin
1515
{
1616
/**
1717
* @var \PHPUnit_Framework_MockObject_MockObject
@@ -27,80 +27,24 @@ public function setUp()
2727
{
2828
$this->setUpInterceptionConfig(
2929
[
30-
'Magento\Framework\Interception\Fixture\InterceptedInterface' => [
31-
'plugins' => [
32-
'first' => [
33-
'instance' => 'Magento\Framework\Interception\Fixture\Intercepted\InterfacePlugin',
34-
'sortOrder' => 10,
30+
'Magento\Framework\Interception\Fixture\InterceptedInterface' =>
31+
[
32+
'plugins' => [
33+
'first' => [
34+
'instance' => 'Magento\Framework\Interception\Fixture\Intercepted\InterfacePlugin',
35+
'sortOrder' => 10,
36+
],
3537
],
3638
],
37-
],
38-
'Magento\Framework\Interception\Fixture\Intercepted' => [
39-
'plugins' => [
40-
'second' => [
41-
'instance' => 'Magento\Framework\Interception\Fixture\Intercepted\Plugin',
42-
'sortOrder' => 20,
39+
'Magento\Framework\Interception\Fixture\Intercepted' =>
40+
[
41+
'plugins' => [
42+
'second' => [
43+
'instance' => 'Magento\Framework\Interception\Fixture\Intercepted\Plugin',
44+
'sortOrder' => 20,
45+
],
4346
],
4447
],
45-
],
46-
]
47-
);
48-
}
49-
50-
public function setUpInterceptionConfig($pluginConfig)
51-
{
52-
$config = new \Magento\Framework\Interception\ObjectManager\Config\Developer();
53-
$factory = new \Magento\Framework\ObjectManager\Factory\Dynamic\Developer($config, null);
54-
55-
$this->_configReader = $this->getMock('Magento\Framework\Config\ReaderInterface');
56-
$this->_configReader->expects(
57-
$this->any()
58-
)->method(
59-
'read'
60-
)->will(
61-
$this->returnValue($pluginConfig)
62-
);
63-
64-
$areaList = $this->getMock('Magento\Framework\App\AreaList', [], [], '', false);
65-
$areaList->expects($this->any())->method('getCodes')->will($this->returnValue([]));
66-
$configScope = new \Magento\Framework\Config\Scope($areaList, 'global');
67-
$cache = $this->getMock('Magento\Framework\Config\CacheInterface');
68-
$cache->expects($this->any())->method('load')->will($this->returnValue(false));
69-
$definitions = new \Magento\Framework\ObjectManager\Definition\Runtime();
70-
$relations = new \Magento\Framework\ObjectManager\Relations\Runtime();
71-
$interceptionConfig = new Config\Config(
72-
$this->_configReader,
73-
$configScope,
74-
$cache,
75-
$relations,
76-
$config,
77-
$definitions
78-
);
79-
$interceptionDefinitions = new Definition\Runtime();
80-
$this->_objectManager = new \Magento\Framework\ObjectManager\ObjectManager(
81-
$factory,
82-
$config,
83-
[
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,
89-
'Magento\Framework\Interception\ObjectManager\ConfigInterface' => $config,
90-
'Magento\Framework\ObjectManager\DefinitionInterface' => $definitions,
91-
'Magento\Framework\Interception\DefinitionInterface' => $interceptionDefinitions
92-
]
93-
);
94-
$factory->setObjectManager($this->_objectManager);
95-
$config->setInterceptionConfig($interceptionConfig);
96-
$config->extend(
97-
[
98-
'preferences' => [
99-
'Magento\Framework\Interception\PluginListInterface' =>
100-
'Magento\Framework\Interception\PluginList\PluginList',
101-
'Magento\Framework\Interception\ChainInterface' =>
102-
'Magento\Framework\Interception\Chain\Chain',
103-
],
10448
]
10549
);
10650
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
/**
99
* Class TwoPluginTest
1010
*/
11-
class TwoPluginTest extends GeneralTest
11+
class TwoPluginTest extends AbstractPlugin
1212
{
1313
public function setUp()
1414
{

0 commit comments

Comments
 (0)