filesystemMock ->expects($this->once()) ->method('write') ->with( BP . '/' . ProfilerEnableCommand::PROFILER_FLAG_FILE, $inputType ?: ProfilerEnableCommand::TYPE_DEFAULT ); $this->filesystemMock ->expects($this->once()) ->method('fileExists') ->with(BP . '/' . ProfilerEnableCommand::PROFILER_FLAG_FILE) ->willReturn($fileExists); /** @var ProfilerEnableCommand $command */ $command = new ProfilerEnableCommand($this->filesystemMock); $commandTester = new CommandTester($command); $commandTester->execute(['type' => $inputType]); self::assertEquals( $expectedOutput, trim(str_replace(PHP_EOL, ' ', $commandTester->getDisplay())) ); } /** * Data provider for testCommand. * * @return array */ public function commandDataProvider() { return [ [ '', true, 'Profiler enabled with html output.' ], [ '', false, 'Something went wrong while enabling the profiler.' ], [ 'html', true, 'Profiler enabled with html output.' ], [ 'html', false, 'Something went wrong while enabling the profiler.' ], [ 'csvfile', true, 'Profiler enabled with csvfile output. Output will be saved in /var/log/profiler.csv' ], [ 'csvfile', false, 'Something went wrong while enabling the profiler.' ], [ 'xml', true, 'Type xml is not one of the built-in output types (html, csvfile). ' . 'Profiler enabled with xml output.' ], [ 'xml', false, 'Type xml is not one of the built-in output types (html, csvfile). ' . 'Something went wrong while enabling the profiler.' ], ]; } /** * @inheritdoc */ protected function setUp() { $this->filesystemMock = $this->getMockBuilder(File::class) ->disableOriginalConstructor() ->getMock(); } }