@@ -54,30 +54,83 @@ public function testProcessFailedExceptionPopulatesInformationFromProcessOutput(
54
54
55
55
$ process = $ this ->getMock (
56
56
'Symfony\Component\Process\Process ' ,
57
- array ('isSuccessful ' , 'getOutput ' , 'getErrorOutput ' , 'getExitCode ' , 'getExitCodeText ' ),
57
+ array ('isSuccessful ' , 'getOutput ' , 'getErrorOutput ' , 'getExitCode ' , 'getExitCodeText ' , ' isOutputDisabled ' ),
58
58
array ($ cmd )
59
59
);
60
60
$ process ->expects ($ this ->once ())
61
61
->method ('isSuccessful ' )
62
62
->will ($ this ->returnValue (false ));
63
+
63
64
$ process ->expects ($ this ->once ())
64
65
->method ('getOutput ' )
65
66
->will ($ this ->returnValue ($ output ));
67
+
66
68
$ process ->expects ($ this ->once ())
67
69
->method ('getErrorOutput ' )
68
70
->will ($ this ->returnValue ($ errorOutput ));
71
+
69
72
$ process ->expects ($ this ->once ())
70
73
->method ('getExitCode ' )
71
74
->will ($ this ->returnValue ($ exitCode ));
75
+
72
76
$ process ->expects ($ this ->once ())
73
77
->method ('getExitCodeText ' )
74
78
->will ($ this ->returnValue ($ exitText ));
75
79
80
+ $ process ->expects ($ this ->once ())
81
+ ->method ('isOutputDisabled ' )
82
+ ->will ($ this ->returnValue (false ));
83
+
76
84
$ exception = new ProcessFailedException ($ process );
77
85
78
86
$ this ->assertEquals (
79
87
"The command \"$ cmd \" failed. \nExit Code: $ exitCode( $ exitText) \n\nOutput: \n================ \n{$ output }\n\nError Output: \n================ \n{$ errorOutput }" ,
80
88
$ exception ->getMessage ()
81
89
);
82
90
}
91
+
92
+ /**
93
+ * Tests that ProcessFailedException does not extract information from
94
+ * process output if it was previously disabled
95
+ */
96
+ public function testDisabledOutputInFailedExceptionDoesNotPopulateOutput ()
97
+ {
98
+ $ cmd = 'php ' ;
99
+ $ exitCode = 1 ;
100
+ $ exitText = 'General error ' ;
101
+
102
+ $ process = $ this ->getMock (
103
+ 'Symfony\Component\Process\Process ' ,
104
+ array ('isSuccessful ' , 'isOutputDisabled ' , 'getExitCode ' , 'getExitCodeText ' , 'getOutput ' , 'getErrorOutput ' ),
105
+ array ($ cmd )
106
+ );
107
+ $ process ->expects ($ this ->once ())
108
+ ->method ('isSuccessful ' )
109
+ ->will ($ this ->returnValue (false ));
110
+
111
+ $ process ->expects ($ this ->never ())
112
+ ->method ('getOutput ' );
113
+
114
+ $ process ->expects ($ this ->never ())
115
+ ->method ('getErrorOutput ' );
116
+
117
+ $ process ->expects ($ this ->once ())
118
+ ->method ('getExitCode ' )
119
+ ->will ($ this ->returnValue ($ exitCode ));
120
+
121
+ $ process ->expects ($ this ->once ())
122
+ ->method ('getExitCodeText ' )
123
+ ->will ($ this ->returnValue ($ exitText ));
124
+
125
+ $ process ->expects ($ this ->once ())
126
+ ->method ('isOutputDisabled ' )
127
+ ->will ($ this ->returnValue (true ));
128
+
129
+ $ exception = new ProcessFailedException ($ process );
130
+
131
+ $ this ->assertEquals (
132
+ "The command \"$ cmd \" failed. \nExit Code: $ exitCode( $ exitText) " ,
133
+ $ exception ->getMessage ()
134
+ );
135
+ }
83
136
}
0 commit comments