Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
CompactDeployTest.php
Go to the documentation of this file.
1 <?php
7 
12 
13 use PHPUnit_Framework_MockObject_MockObject as Mock;
14 
20 class CompactDeployTest extends \PHPUnit\Framework\TestCase
21 {
25  private $strategy;
26 
32  private $packagePool;
33 
39  private $queue;
40 
44  private $options = [];
45 
49  private $packages = [];
50 
54  protected function setUp()
55  {
56  $this->options = [
57  'opt1' => '',
58  'opt2' => ''
59  ];
60 
61  $virtualPackage = $this->createMock(Package::class);
62  $virtualPackage->expects($this->exactly(1))
63  ->method('isVirtual')
64  ->willReturn(true);
65  $virtualPackage->expects($this->atLeastOnce())
66  ->method('getParentPackages')
67  ->willReturn([]);
68  $virtualPackage->expects($this->never())
69  ->method('setParam')
70  ->willReturn('virtual');
71 
72  $realPackage = $this->createMock(Package::class);
73  $realPackage->expects($this->exactly(1))
74  ->method('isVirtual')
75  ->willReturn(false);
76  $realPackage->expects($this->atLeastOnce())
77  ->method('getParentPackages')
78  ->willReturn([]);
79  $realPackage->expects($this->exactly(1))
80  ->method('setParam')
81  ->willReturn('virtual');
82 
83  $this->packages = [
84  'virtual' => $virtualPackage,
85  'real' => $realPackage
86  ];
87  $this->packagePool = $this->createPartialMock(PackagePool::class, ['getPackagesForDeployment']);
88  $this->packagePool->expects($this->once())
89  ->method('getPackagesForDeployment')
90  ->with($this->options)
91  ->willReturn($this->packages);
92 
93  $this->queue = $this->createPartialMock(Queue::class, ['add', 'process']);
94  $this->queue->expects($this->exactly(2))->method('add');
95  $this->queue->expects($this->exactly(1))->method('process');
96 
97  $this->strategy = new CompactDeploy(
98  $this->packagePool,
99  $this->queue
100  );
101  }
102 
106  public function testDeploy()
107  {
108  $this->assertEquals(
109  $this->packages,
110  $this->strategy->deploy($this->options)
111  );
112  }
113 }