@@ -51,10 +51,11 @@ public function testProcessFailedExceptionPopulatesInformationFromProcessOutput(
5151 $exitText = 'General error';
5252 $output = 'Command output';
5353 $errorOutput = 'FATAL: Unexpected error';
54+ $workingDirectory = getcwd();
5455
5556 $process = $this->getMock(
5657 'Symfony\Component\Process\Process',
57- array('isSuccessful', 'getOutput', 'getErrorOutput', 'getExitCode', 'getExitCodeText', 'isOutputDisabled'),
58+ array('isSuccessful', 'getOutput', 'getErrorOutput', 'getExitCode', 'getExitCodeText', 'isOutputDisabled', 'getWorkingDirectory' ),
5859 array($cmd)
5960 );
6061 $process->expects($this->once())
@@ -81,27 +82,32 @@ public function testProcessFailedExceptionPopulatesInformationFromProcessOutput(
8182 ->method('isOutputDisabled')
8283 ->will($this->returnValue(false));
8384
85+ $process->expects($this->once())
86+ ->method('getWorkingDirectory')
87+ ->will($this->returnValue($workingDirectory));
88+
8489 $exception = new ProcessFailedException($process);
8590
8691 $this->assertEquals(
87- "The command \"$cmd\" failed.\nExit Code: $exitCode($exitText)\n\nOutput:\n================\n{$output}\n\nError Output:\n================\n{$errorOutput}",
92+ "The command \"$cmd\" failed.\n\ nExit Code: $exitCode($exitText)\n\nWorking directory: {$workingDirectory} \n\nOutput:\n================\n{$output}\n\nError Output:\n================\n{$errorOutput}",
8893 $exception->getMessage()
8994 );
9095 }
9196
9297 /**
9398 * Tests that ProcessFailedException does not extract information from
94- * process output if it was previously disabled
99+ * process output if it was previously disabled.
95100 */
96101 public function testDisabledOutputInFailedExceptionDoesNotPopulateOutput()
97102 {
98103 $cmd = 'php';
99104 $exitCode = 1;
100105 $exitText = 'General error';
106+ $workingDirectory = getcwd();
101107
102108 $process = $this->getMock(
103109 'Symfony\Component\Process\Process',
104- array('isSuccessful', 'isOutputDisabled', 'getExitCode', 'getExitCodeText', 'getOutput', 'getErrorOutput'),
110+ array('isSuccessful', 'isOutputDisabled', 'getExitCode', 'getExitCodeText', 'getOutput', 'getErrorOutput', 'getWorkingDirectory' ),
105111 array($cmd)
106112 );
107113 $process->expects($this->once())
@@ -126,10 +132,14 @@ public function testDisabledOutputInFailedExceptionDoesNotPopulateOutput()
126132 ->method('isOutputDisabled')
127133 ->will($this->returnValue(true));
128134
135+ $process->expects($this->once())
136+ ->method('getWorkingDirectory')
137+ ->will($this->returnValue($workingDirectory));
138+
129139 $exception = new ProcessFailedException($process);
130140
131141 $this->assertEquals(
132- "The command \"$cmd\" failed.\nExit Code: $exitCode($exitText)",
142+ "The command \"$cmd\" failed.\n\ nExit Code: $exitCode($exitText)\n\nWorking directory: {$workingDirectory} ",
133143 $exception->getMessage()
134144 );
135145 }
0 commit comments