Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
InterceptionCacheTest.php
Go to the documentation of this file.
1 <?php
7 
9 
10 class InterceptionCacheTest extends \PHPUnit\Framework\TestCase
11 {
15  private $configMock;
16 
20  private $interceptionsListMock;
21 
22  public function setUp()
23  {
24  $this->configMock = $this->getMockBuilder(\Magento\Framework\Interception\Config\Config::class)
25  ->setMethods([])
26  ->disableOriginalConstructor()
27  ->getMock();
28  $this->interceptionsListMock = $this->getMockBuilder(
29  \Magento\Setup\Module\Di\Code\Reader\Decorator\Interceptions::class
30  )
31  ->setMethods([])
32  ->disableOriginalConstructor()
33  ->getMock();
34  }
35 
36  public function testDoOperationEmptyData()
37  {
38  $data = [];
39 
40  $operation = new InterceptionCache($this->configMock, $this->interceptionsListMock, $data);
41  $this->configMock->expects($this->never())
42  ->method('initialize');
43 
44  $this->assertNull($operation->doOperation());
45  }
46 
48  {
49  $definitions = [
50  'Library\Class',
51  'Application\Class',
52  'VarGeneration\Class',
53  'AppGeneration\Class'
54  ];
55 
56  $data = [
57  'lib',
58  'app',
59  'generation',
60  'appgeneration'
61  ];
62 
63  $this->interceptionsListMock->expects($this->any())
64  ->method('getList')
65  ->willReturnMap(
66  [
67  ['lib', ['Library\Class']],
68  ['app', ['Application\Class']],
69  ['generation', ['VarGeneration\Class']],
70  ['appgeneration', ['AppGeneration\Class']]
71  ]
72  );
73 
74  $operation = new InterceptionCache($this->configMock, $this->interceptionsListMock, $data);
75  $this->configMock->expects($this->once())
76  ->method('initialize')
77  ->with($definitions);
78 
79  $this->assertNull($operation->doOperation());
80  }
81 }