setUpInterceptionConfig( [\Magento\Framework\Interception\Fixture\InterceptedInterface::class => [ 'plugins' => [ 'first' => [ 'instance' => \Magento\Framework\Interception\Fixture\Intercepted\InterfacePlugin::class, 'sortOrder' => 10, ], ], ], \Magento\Framework\Interception\Fixture\Intercepted::class => [ 'plugins' => [ 'second' => [ 'instance' => \Magento\Framework\Interception\Fixture\Intercepted\Plugin::class, 'sortOrder' => 20, ], ], ], ] ); parent::setUp(); } public function testMethodCanBePluginized() { $subject = $this->_objectManager->create(\Magento\Framework\Interception\Fixture\Intercepted::class); $this->assertEquals('1: test', $subject->D('test')); } public function testPluginCanCallOnlyNextMethodOnNext() { $subject = $this->_objectManager->create(\Magento\Framework\Interception\Fixture\Intercepted::class); $this->assertEquals( 'test', $subject->G('test') ); } public function testBeforeAndAfterPluginsAreExecuted() { $subject = $this->_objectManager->create(\Magento\Framework\Interception\Fixture\Intercepted::class); $this->assertEquals( '1: prefix_test' . '', $subject->A('prefix_')->F('test') ); } public function testPluginCallsOtherMethodsOnSubject() { $subject = $this->_objectManager->create(\Magento\Framework\Interception\Fixture\Intercepted::class); $this->assertEquals( '1: prefix_test' . '', $subject->A('prefix_')->K('test') ); } public function testInterfacePluginsAreInherited() { $subject = $this->_objectManager->create(\Magento\Framework\Interception\Fixture\Intercepted::class); $this->assertEquals('test', $subject->C('test')); } public function testInternalMethodCallsAreIntercepted() { $subject = $this->_objectManager->create(\Magento\Framework\Interception\Fixture\Intercepted::class); $this->assertEquals('121', $subject->B('1', '2')); } public function testChainedMethodsAreIntercepted() { $subject = $this->_objectManager->create(\Magento\Framework\Interception\Fixture\Intercepted::class); $this->assertEquals('1: prefix_test', $subject->A('prefix_')->D('test')); } public function testFinalMethodWorks() { $subject = $this->_objectManager->create(\Magento\Framework\Interception\Fixture\Intercepted::class); $this->assertEquals('1: prefix_test', $subject->A('prefix_')->D('test')); $this->assertEquals('prefix_final', $subject->E('final')); $this->assertEquals('2: prefix_test', $subject->D('test')); } public function testObjectKeepsStateBetweenInvocations() { $subject = $this->_objectManager->create(\Magento\Framework\Interception\Fixture\Intercepted::class); $this->assertEquals('1: test', $subject->D('test')); $this->assertEquals('2: test', $subject->D('test')); } }