Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
Public Member Functions
GeneralTest Class Reference
Inheritance diagram for GeneralTest:
AbstractPlugin

Public Member Functions

 setUp ()
 
 testMethodCanBePluginized ()
 
 testPluginCanCallOnlyNextMethodOnNext ()
 
 testBeforeAndAfterPluginsAreExecuted ()
 
 testPluginCallsOtherMethodsOnSubject ()
 
 testInterfacePluginsAreInherited ()
 
 testInternalMethodCallsAreIntercepted ()
 
 testChainedMethodsAreIntercepted ()
 
 testFinalMethodWorks ()
 
 testObjectKeepsStateBetweenInvocations ()
 
- Public Member Functions inherited from AbstractPlugin
 setUp ()
 
 tearDown ()
 
 setUpInterceptionConfig ($pluginConfig)
 

Additional Inherited Members

- Protected Attributes inherited from AbstractPlugin
 $_configReader
 
 $_objectManager
 

Detailed Description

Class GeneralTest @SuppressWarnings(PHPMD.CouplingBetweenObjects)

Definition at line 12 of file GeneralTest.php.

Member Function Documentation

◆ setUp()

setUp ( )

Definition at line 14 of file GeneralTest.php.

15  {
17  [\Magento\Framework\Interception\Fixture\InterceptedInterface::class =>
18  [
19  'plugins' => [
20  'first' => [
21  'instance' =>
22  \Magento\Framework\Interception\Fixture\Intercepted\InterfacePlugin::class,
23  'sortOrder' => 10,
24  ],
25  ],
26  ], \Magento\Framework\Interception\Fixture\Intercepted::class =>
27  [
28  'plugins' => [
29  'second' => [
30  'instance' => \Magento\Framework\Interception\Fixture\Intercepted\Plugin::class,
31  'sortOrder' => 20,
32  ],
33  ],
34  ],
35  ]
36  );
37 
38  parent::setUp();
39  }

◆ testBeforeAndAfterPluginsAreExecuted()

testBeforeAndAfterPluginsAreExecuted ( )

Definition at line 56 of file GeneralTest.php.

57  {
58  $subject = $this->_objectManager->create(\Magento\Framework\Interception\Fixture\Intercepted::class);
59  $this->assertEquals(
60  '<IP:F><P:D>1: <D>prefix_<F><IP:C><P:C><C>test</C></P:C>' . '</IP:C></F></D></P:D></IP:F>',
61  $subject->A('prefix_')->F('test')
62  );
63  }

◆ testChainedMethodsAreIntercepted()

testChainedMethodsAreIntercepted ( )

Definition at line 87 of file GeneralTest.php.

88  {
89  $subject = $this->_objectManager->create(\Magento\Framework\Interception\Fixture\Intercepted::class);
90  $this->assertEquals('<P:D>1: <D>prefix_test</D></P:D>', $subject->A('prefix_')->D('test'));
91  }

◆ testFinalMethodWorks()

testFinalMethodWorks ( )

Definition at line 93 of file GeneralTest.php.

94  {
95  $subject = $this->_objectManager->create(\Magento\Framework\Interception\Fixture\Intercepted::class);
96  $this->assertEquals('<P:D>1: <D>prefix_test</D></P:D>', $subject->A('prefix_')->D('test'));
97  $this->assertEquals('<E>prefix_final</E>', $subject->E('final'));
98  $this->assertEquals('<P:D>2: <D>prefix_test</D></P:D>', $subject->D('test'));
99  }

◆ testInterfacePluginsAreInherited()

testInterfacePluginsAreInherited ( )

Definition at line 75 of file GeneralTest.php.

76  {
77  $subject = $this->_objectManager->create(\Magento\Framework\Interception\Fixture\Intercepted::class);
78  $this->assertEquals('<IP:C><P:C><C>test</C></P:C></IP:C>', $subject->C('test'));
79  }

◆ testInternalMethodCallsAreIntercepted()

testInternalMethodCallsAreIntercepted ( )

Definition at line 81 of file GeneralTest.php.

82  {
83  $subject = $this->_objectManager->create(\Magento\Framework\Interception\Fixture\Intercepted::class);
84  $this->assertEquals('<B>12<IP:C><P:C><C>1</C></P:C></IP:C></B>', $subject->B('1', '2'));
85  }

◆ testMethodCanBePluginized()

testMethodCanBePluginized ( )

Definition at line 41 of file GeneralTest.php.

42  {
43  $subject = $this->_objectManager->create(\Magento\Framework\Interception\Fixture\Intercepted::class);
44  $this->assertEquals('<P:D>1: <D>test</D></P:D>', $subject->D('test'));
45  }

◆ testObjectKeepsStateBetweenInvocations()

testObjectKeepsStateBetweenInvocations ( )

Definition at line 101 of file GeneralTest.php.

102  {
103  $subject = $this->_objectManager->create(\Magento\Framework\Interception\Fixture\Intercepted::class);
104  $this->assertEquals('<P:D>1: <D>test</D></P:D>', $subject->D('test'));
105  $this->assertEquals('<P:D>2: <D>test</D></P:D>', $subject->D('test'));
106  }

◆ testPluginCallsOtherMethodsOnSubject()

testPluginCallsOtherMethodsOnSubject ( )

Definition at line 65 of file GeneralTest.php.

66  {
67  $subject = $this->_objectManager->create(\Magento\Framework\Interception\Fixture\Intercepted::class);
68  $this->assertEquals(
69  '<P:K><IP:F><P:D>1: <D>prefix_<F><IP:C><P:C><C><IP:C><P:C><C>test' .
70  '</C></P:C></IP:C></C></P:C></IP:C></F></D></P:D></IP:F></P:K>',
71  $subject->A('prefix_')->K('test')
72  );
73  }

◆ testPluginCanCallOnlyNextMethodOnNext()

testPluginCanCallOnlyNextMethodOnNext ( )

Definition at line 47 of file GeneralTest.php.

48  {
49  $subject = $this->_objectManager->create(\Magento\Framework\Interception\Fixture\Intercepted::class);
50  $this->assertEquals(
51  '<IP:aG><P:aG><G><P:G><P:bG><IP:G><IP:bG>test</IP:bG></IP:G></P:bG></P:G></G></P:aG></IP:aG>',
52  $subject->G('test')
53  );
54  }

The documentation for this class was generated from the following file: