25 $this->loggerMock = $this->getMockBuilder(\Psr\
Log\LoggerInterface::class)
26 ->disableOriginalConstructor()
28 $this->driverMock = $this->getMockBuilder(\
Magento\Framework\
Shell\Driver::class)
29 ->disableOriginalConstructor()
31 $this->model =
new Shell(
41 $command =
'escaped command';
42 $logEntry = $command . PHP_EOL .
$output;
47 'exit_code' => $exitCode,
48 'escaped_command' => $command
51 $this->driverMock->expects($this->once())->method(
'execute')->willReturn($successfulResponse);
52 $this->loggerMock->expects($this->once())->method(
'info')->with($logEntry);
53 $this->assertEquals(
$output, $this->model->execute($command, []));
60 $command =
'escaped command';
61 $logEntry = $command . PHP_EOL .
$output;
66 'exit_code' => $exitCode,
67 'escaped_command' => $command
70 $this->driverMock->expects($this->once())->method(
'execute')->willReturn(
$response);
71 $this->loggerMock->expects($this->once())->method(
'error')->with($logEntry);
72 $this->expectException(LocalizedException::class);
73 $this->expectExceptionMessage(
"Command returned non-zero exit code:\n`$command`");
74 $this->model->execute($command, []);