Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
ProfilerEnableCommandTest.php
Go to the documentation of this file.
1 <?php
8 
11 use PHPUnit\Framework\TestCase;
12 use Symfony\Component\Console\Tester\CommandTester;
13 
19 class ProfilerEnableCommandTest extends TestCase
20 {
24  private $filesystemMock;
25 
34  public function testCommand(string $inputType, bool $fileExists, string $expectedOutput)
35  {
36  $this->filesystemMock
37  ->expects($this->once())
38  ->method('write')
39  ->with(
42  );
43  $this->filesystemMock
44  ->expects($this->once())
45  ->method('fileExists')
47  ->willReturn($fileExists);
49  $command = new ProfilerEnableCommand($this->filesystemMock);
50  $commandTester = new CommandTester($command);
51  $commandTester->execute(['type' => $inputType]);
52 
53  self::assertEquals(
54  $expectedOutput,
55  trim(str_replace(PHP_EOL, ' ', $commandTester->getDisplay()))
56  );
57  }
58 
64  public function commandDataProvider()
65  {
66  return [
67  [
68  '',
69  true,
70  'Profiler enabled with html output.'
71  ],
72  [
73  '',
74  false,
75  'Something went wrong while enabling the profiler.'
76  ],
77  [
78  'html',
79  true,
80  'Profiler enabled with html output.'
81  ],
82  [
83  'html',
84  false,
85  'Something went wrong while enabling the profiler.'
86  ],
87  [
88  'csvfile',
89  true,
90  'Profiler enabled with csvfile output. Output will be saved in /var/log/profiler.csv'
91  ],
92  [
93  'csvfile',
94  false,
95  'Something went wrong while enabling the profiler.'
96  ],
97  [
98  'xml',
99  true,
100  'Type xml is not one of the built-in output types (html, csvfile). ' .
101  'Profiler enabled with xml output.'
102  ],
103  [
104  'xml',
105  false,
106  'Type xml is not one of the built-in output types (html, csvfile). ' .
107  'Something went wrong while enabling the profiler.'
108  ],
109  ];
110  }
111 
115  protected function setUp()
116  {
117  $this->filesystemMock = $this->getMockBuilder(File::class)
118  ->disableOriginalConstructor()
119  ->getMock();
120  }
121 }
const BP
Definition: autoload.php:14