-
Notifications
You must be signed in to change notification settings - Fork 9.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #61 from magento-extensibility/MAGETWO-32870
[Github] extra tests for current interception behavior #965
- Loading branch information
Showing
6 changed files
with
386 additions
and
70 deletions.
There are no files selected for viewing
82 changes: 82 additions & 0 deletions
82
dev/tests/integration/testsuite/Magento/Framework/Interception/AbstractPlugin.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
<?php | ||
/** | ||
* Copyright © 2015 Magento. All rights reserved. | ||
* See COPYING.txt for license details. | ||
*/ | ||
namespace Magento\Framework\Interception; | ||
|
||
/** | ||
* Class GeneralTest | ||
* @SuppressWarnings(PHPMD.CouplingBetweenObjects) | ||
*/ | ||
abstract class AbstractPlugin extends \PHPUnit_Framework_TestCase | ||
{ | ||
|
||
/** | ||
* @var \PHPUnit_Framework_MockObject_MockObject | ||
*/ | ||
protected $_configReader; | ||
|
||
/** | ||
* @var \Magento\Framework\ObjectManagerInterface | ||
*/ | ||
protected $_objectManager; | ||
|
||
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', | ||
], | ||
] | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
130 changes: 130 additions & 0 deletions
130
.../integration/testsuite/Magento/Framework/Interception/Fixture/Intercepted/FirstPlugin.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,130 @@ | ||
<?php | ||
/** | ||
* Copyright © 2015 Magento. All rights reserved. | ||
* See COPYING.txt for license details. | ||
*/ | ||
namespace Magento\Framework\Interception\Fixture\Intercepted; | ||
|
||
use Magento\Framework\Interception\Fixture\Intercepted; | ||
|
||
class FirstPlugin | ||
{ | ||
/** | ||
* @var int | ||
*/ | ||
protected $_counter = 0; | ||
|
||
/** | ||
* @SuppressWarnings(PHPMD.UnusedFormalParameter) | ||
*/ | ||
public function aroundC(Intercepted $subject, \Closure $next, $param1) | ||
{ | ||
return '<F:C>' . $next($param1) . '</F:C>'; | ||
} | ||
|
||
/** | ||
* @SuppressWarnings(PHPMD.UnusedFormalParameter) | ||
*/ | ||
public function aroundD(Intercepted $subject, \Closure $next, $param1) | ||
{ | ||
$this->_counter++; | ||
return '<F:D>' . $this->_counter . ': ' . $next($param1) . '</F:D>'; | ||
} | ||
|
||
/** | ||
* @SuppressWarnings(PHPMD.UnusedFormalParameter) | ||
*/ | ||
public function aroundK(Intercepted $subject, \Closure $next, $param1) | ||
{ | ||
$result = $subject->C($param1); | ||
return '<F:K>' . $subject->F($result) . '</F:K>'; | ||
} | ||
|
||
/** | ||
* @SuppressWarnings(PHPMD.UnusedFormalParameter) | ||
*/ | ||
public function beforeG(Intercepted $subject, $param1) | ||
{ | ||
return ['<F:bG>' . $param1 . '</F:bG>']; | ||
} | ||
|
||
/** | ||
* @SuppressWarnings(PHPMD.UnusedFormalParameter) | ||
*/ | ||
public function aroundG(Intercepted $subject, \Closure $next, $param1) | ||
{ | ||
return $next('<F:G>' . $param1 . '</F:G>'); | ||
} | ||
|
||
/** | ||
* @SuppressWarnings(PHPMD.UnusedFormalParameter) | ||
*/ | ||
public function afterG(Intercepted $subject, $result) | ||
{ | ||
return '<F:aG>' . $result . '</F:aG>'; | ||
} | ||
|
||
/** | ||
* @SuppressWarnings(PHPMD.UnusedFormalParameter) | ||
*/ | ||
public function beforeV(Intercepted $subject, $param1) | ||
{ | ||
return ['<F:bV/>']; | ||
} | ||
|
||
/** | ||
* @SuppressWarnings(PHPMD.UnusedFormalParameter) | ||
*/ | ||
public function aroundV(Intercepted $subject, \Closure $next, $param1) | ||
{ | ||
return '<F:V>' . $param1 . '<F:V/>'; | ||
} | ||
|
||
/** | ||
* @SuppressWarnings(PHPMD.UnusedFormalParameter) | ||
*/ | ||
public function beforeW(Intercepted $subject, $param1) | ||
{ | ||
return ['<F:bW/>']; | ||
} | ||
|
||
/** | ||
* @SuppressWarnings(PHPMD.UnusedFormalParameter) | ||
*/ | ||
public function aroundW(Intercepted $subject, \Closure $next, $param1) | ||
{ | ||
return '<F:W>' . $param1 . '<F:W/>'; | ||
} | ||
|
||
/** | ||
* @SuppressWarnings(PHPMD.UnusedFormalParameter) | ||
*/ | ||
public function afterW(Intercepted $subject, $result) | ||
{ | ||
return '<F:aW/>'; | ||
} | ||
|
||
/** | ||
* @SuppressWarnings(PHPMD.UnusedFormalParameter) | ||
*/ | ||
public function beforeX(Intercepted $subject, $param1) | ||
{ | ||
return ['<F:bX/>']; | ||
} | ||
|
||
/** | ||
* @SuppressWarnings(PHPMD.UnusedFormalParameter) | ||
*/ | ||
public function aroundY(Intercepted $subject, \Closure $next, $param1) | ||
{ | ||
return '<F:Y>' . $param1 . '<F:Y/>'; | ||
} | ||
|
||
/** | ||
* @SuppressWarnings(PHPMD.UnusedFormalParameter) | ||
*/ | ||
public function afterZ(Intercepted $subject, $result) | ||
{ | ||
return '<F:aZ/>'; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.