Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
AbstractBuilderTest.php
Go to the documentation of this file.
1 <?php
7 
8 class AbstractBuilderTest extends \PHPUnit\Framework\TestCase
9 {
14 
18  protected $reportWriterMock;
19 
23  protected $builder;
24 
25  protected function setUp()
26  {
27  $this->dependenciesParserMock = $this->createMock(\Magento\Setup\Module\Dependency\ParserInterface::class);
28  $this->reportWriterMock = $this->createMock(\Magento\Setup\Module\Dependency\Report\WriterInterface::class);
29 
30  $this->builder = $this->getMockForAbstractClass(
31  \Magento\Setup\Module\Dependency\Report\Builder\AbstractBuilder::class,
32  ['dependenciesParser' => $this->dependenciesParserMock, 'reportWriter' => $this->reportWriterMock]
33  );
34  }
35 
43  {
44  $this->builder->build($options);
45  }
46 
51  {
52  return [[['write' => [1, 2]]], [['parse' => [], 'write' => [1, 2]]]];
53  }
54 
62  {
63  $this->builder->build($options);
64  }
65 
70  {
71  return [[['parse' => [1, 2]]], [['parse' => [1, 2], 'write' => []]]];
72  }
73 
74  public function testBuild()
75  {
76  $options = [
77  'parse' => ['files_for_parse' => [1, 2, 3]],
78  'write' => ['report_filename' => 'some_filename'],
79  ];
80 
81  $parseResult = ['foo', 'bar', 'baz'];
82  $configMock = $this->createMock(\Magento\Setup\Module\Dependency\Report\Data\ConfigInterface::class);
83 
84  $this->dependenciesParserMock->expects(
85  $this->once()
86  )->method(
87  'parse'
88  )->with(
89  $options['parse']
90  )->will(
91  $this->returnValue($parseResult)
92  );
93  $this->builder->expects(
94  $this->once()
95  )->method(
96  'buildData'
97  )->with(
98  $parseResult
99  )->will(
100  $this->returnValue($configMock)
101  );
102  $this->reportWriterMock->expects($this->once())->method('write')->with($options['write'], $configMock);
103 
104  $this->builder->build($options);
105  }
106 }