|
5 | 5 | */
|
6 | 6 | namespace Magento\Framework\Interception;
|
7 | 7 |
|
8 |
| -use Magento\Framework\ObjectManager\Config\Config as ObjectManagerConfig; |
9 |
| - |
10 | 8 | /**
|
11 |
| - * Class GeneralTest |
12 |
| - * @SuppressWarnings(PHPMD.CouplingBetweenObjects) |
| 9 | + * Class TwoPluginTest |
13 | 10 | */
|
14 |
| -class TwoPluginTest extends \PHPUnit_Framework_TestCase |
| 11 | +class TwoPluginTest extends GeneralTest |
15 | 12 | {
|
16 |
| - /** |
17 |
| - * @var \PHPUnit_Framework_MockObject_MockObject |
18 |
| - */ |
19 |
| - protected $_configReader; |
20 |
| - |
21 |
| - /** |
22 |
| - * @var \Magento\Framework\ObjectManagerInterface |
23 |
| - */ |
24 |
| - protected $_objectManager; |
25 |
| - |
26 | 13 | public function setUp()
|
27 | 14 | {
|
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( |
87 | 16 | [
|
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 | + ] |
93 | 28 | ]
|
94 | 29 | );
|
95 | 30 | }
|
@@ -117,6 +52,7 @@ public function testPluginBeforeAroundWins()
|
117 | 52 | $subject = $this->_objectManager->create('Magento\Framework\Interception\Fixture\Intercepted');
|
118 | 53 | $this->assertEquals('<F:V><F:bV/><F:V/>', $subject->V('test'));
|
119 | 54 | }
|
| 55 | + |
120 | 56 | public function testPluginBeforeAroundAfterWins()
|
121 | 57 | {
|
122 | 58 | $subject = $this->_objectManager->create('Magento\Framework\Interception\Fixture\Intercepted');
|
|
0 commit comments