TwoPluginTest.php 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. <?php
  2. /**
  3. * Copyright © Magento, Inc. All rights reserved.
  4. * See COPYING.txt for license details.
  5. */
  6. namespace Magento\Framework\Interception;
  7. /**
  8. * Class TwoPluginTest
  9. */
  10. class TwoPluginTest extends AbstractPlugin
  11. {
  12. public function setUp()
  13. {
  14. $this->setUpInterceptionConfig(
  15. [\Magento\Framework\Interception\Fixture\Intercepted::class => [
  16. 'plugins' => [
  17. 'first' => [
  18. 'instance' => \Magento\Framework\Interception\Fixture\Intercepted\FirstPlugin::class,
  19. 'sortOrder' => 10,
  20. ], 'second' => [
  21. 'instance' => \Magento\Framework\Interception\Fixture\Intercepted\Plugin::class,
  22. 'sortOrder' => 20,
  23. ]
  24. ],
  25. ]
  26. ]
  27. );
  28. parent::setUp();
  29. }
  30. public function testPluginBeforeWins()
  31. {
  32. $subject = $this->_objectManager->create(\Magento\Framework\Interception\Fixture\Intercepted::class);
  33. $this->assertEquals('<X><P:bX/></X>', $subject->X('test'));
  34. }
  35. public function testPluginAroundWins()
  36. {
  37. $subject = $this->_objectManager->create(\Magento\Framework\Interception\Fixture\Intercepted::class);
  38. $this->assertEquals('<F:Y>test<F:Y/>', $subject->Y('test'));
  39. }
  40. public function testPluginAfterWins()
  41. {
  42. $subject = $this->_objectManager->create(\Magento\Framework\Interception\Fixture\Intercepted::class);
  43. $this->assertEquals('<P:aZ/>', $subject->Z('test'));
  44. }
  45. public function testPluginBeforeAroundWins()
  46. {
  47. $subject = $this->_objectManager->create(\Magento\Framework\Interception\Fixture\Intercepted::class);
  48. $this->assertEquals('<F:V><F:bV/><F:V/>', $subject->V('test'));
  49. }
  50. public function testPluginBeforeAroundAfterWins()
  51. {
  52. $subject = $this->_objectManager->create(\Magento\Framework\Interception\Fixture\Intercepted::class);
  53. $this->assertEquals('<F:aW/>', $subject->W('test'));
  54. }
  55. }