@@ -95,8 +95,9 @@ public function then_stdout_stderr_should_contain( $stream, $strictly, $action,
9595 public function then_stdout_stderr_should_be_a_number ( $ stream ): void {
9696
9797 $ stream = strtolower ( $ stream );
98+ $ output = $ this ->normalize_line_endings ( $ this ->result ->$ stream );
9899
99- $ this ->assert_numeric ( trim ( $ this -> result -> $ stream , "\n" ) );
100+ $ this ->assert_numeric ( trim ( $ output , "\n" ) );
100101 }
101102
102103 /**
@@ -118,8 +119,9 @@ public function then_stdout_stderr_should_be_a_number( $stream ): void {
118119 public function then_stdout_stderr_should_not_be_a_number ( $ stream ): void {
119120
120121 $ stream = strtolower ( $ stream );
122+ $ output = $ this ->normalize_line_endings ( $ this ->result ->$ stream );
121123
122- $ this ->assert_not_numeric ( trim ( $ this -> result -> $ stream , "\n" ) );
124+ $ this ->assert_not_numeric ( trim ( $ output , "\n" ) );
123125 }
124126
125127 /**
@@ -140,7 +142,7 @@ public function then_stdout_stderr_should_not_be_a_number( $stream ): void {
140142 * @Then /^STDOUT should be a table containing rows:$/
141143 */
142144 public function then_stdout_should_be_a_table_containing_rows ( TableNode $ expected ): void {
143- $ output = $ this ->result ->stdout ;
145+ $ output = $ this ->normalize_line_endings ( $ this -> result ->stdout ) ;
144146 $ actual_rows = explode ( "\n" , rtrim ( $ output , "\n" ) );
145147
146148 $ expected_rows = array ();
@@ -176,7 +178,7 @@ public function then_stdout_should_be_a_table_containing_rows( TableNode $expect
176178 * @Then /^STDOUT should end with a table containing rows:$/
177179 */
178180 public function then_stdout_should_end_with_a_table_containing_rows ( TableNode $ expected ): void {
179- $ output = $ this ->result ->stdout ;
181+ $ output = $ this ->normalize_line_endings ( $ this -> result ->stdout ) ;
180182 $ actual_rows = explode ( "\n" , rtrim ( $ output , "\n" ) );
181183
182184 $ expected_rows = array ();
@@ -212,8 +214,8 @@ public function then_stdout_should_end_with_a_table_containing_rows( TableNode $
212214 * @Then /^STDOUT should be JSON containing:$/
213215 */
214216 public function then_stdout_should_be_json_containing ( PyStringNode $ expected ): void {
215- $ output = $ this ->result ->stdout ;
216- $ expected = $ this ->replace_variables ( (string ) $ expected );
217+ $ output = $ this ->normalize_line_endings ( $ this -> result ->stdout ) ;
218+ $ expected = $ this ->normalize_line_endings ( $ this -> replace_variables ( (string ) $ expected ) );
217219
218220 if ( ! $ this ->check_that_json_string_contains_json_string ( $ output , $ expected ) ) {
219221 $ message = (string ) $ this ->result ;
@@ -253,11 +255,11 @@ public function then_stdout_should_be_json_containing( PyStringNode $expected ):
253255 * @Then /^STDOUT should be a JSON array containing:$/
254256 */
255257 public function then_stdout_should_be_a_json_array_containing ( PyStringNode $ expected ): void {
256- $ output = $ this ->result ->stdout ;
257- $ expected = $ this ->replace_variables ( (string ) $ expected );
258+ $ output = $ this ->normalize_line_endings ( $ this -> result ->stdout ) ;
259+ $ expected = $ this ->normalize_line_endings ( $ this -> replace_variables ( (string ) $ expected ) );
258260
259- $ actual_values = json_decode ( $ output );
260- $ expected_values = json_decode ( $ expected );
261+ $ actual_values = $ this -> normalize_line_endings_in_data ( json_decode ( $ output ) );
262+ $ expected_values = $ this -> normalize_line_endings_in_data ( json_decode ( $ expected ) );
261263
262264 $ missing = array_diff ( $ expected_values , $ actual_values );
263265 if ( ! empty ( $ missing ) ) {
@@ -293,7 +295,7 @@ public function then_stdout_should_be_a_json_array_containing( PyStringNode $exp
293295 * @Then /^STDOUT should be CSV containing:$/
294296 */
295297 public function then_stdout_should_be_csv_containing ( TableNode $ expected ): void {
296- $ output = $ this ->result ->stdout ;
298+ $ output = $ this ->normalize_line_endings ( $ this -> result ->stdout ) ;
297299
298300 $ expected_rows = $ expected ->getRows ();
299301 foreach ( $ expected_rows as &$ row ) {
@@ -336,8 +338,8 @@ public function then_stdout_should_be_csv_containing( TableNode $expected ): voi
336338 * @Then /^STDOUT should be YAML containing:$/
337339 */
338340 public function then_stdout_should_be_yaml_containing ( PyStringNode $ expected ): void {
339- $ output = $ this ->result ->stdout ;
340- $ expected = $ this ->replace_variables ( (string ) $ expected );
341+ $ output = $ this ->normalize_line_endings ( $ this -> result ->stdout ) ;
342+ $ expected = $ this ->normalize_line_endings ( $ this -> replace_variables ( (string ) $ expected ) );
341343
342344 if ( ! $ this ->check_that_yaml_string_contains_yaml_string ( $ output , $ expected ) ) {
343345 $ message = (string ) $ this ->result ;
@@ -392,8 +394,9 @@ public function then_stdout_stderr_should_be_empty( $stream ): void {
392394 public function then_stdout_stderr_should_not_be_empty ( $ stream ): void {
393395
394396 $ stream = strtolower ( $ stream );
397+ $ output = $ this ->normalize_line_endings ( $ this ->result ->$ stream );
395398
396- if ( '' === rtrim ( $ this -> result -> $ stream , "\n" ) ) {
399+ if ( '' === rtrim ( $ output , "\n" ) ) {
397400 throw new Exception ( $ this ->result );
398401 }
399402 }
@@ -419,7 +422,8 @@ public function then_stdout_stderr_should_not_be_empty( $stream ): void {
419422 public function then_stdout_stderr_should_be_a_specific_version_string ( $ stream , $ operator , $ goal_ver ): void {
420423 $ goal_ver = $ this ->replace_variables ( $ goal_ver );
421424 $ stream = strtolower ( $ stream );
422- if ( false === version_compare ( trim ( $ this ->result ->$ stream , "\n" ), $ goal_ver , $ operator ) ) {
425+ $ output = $ this ->normalize_line_endings ( $ this ->result ->$ stream );
426+ if ( false === version_compare ( trim ( $ output , "\n" ), $ goal_ver , $ operator ) ) {
423427 throw new Exception ( $ this ->result );
424428 }
425429 }
@@ -530,7 +534,7 @@ public function then_the_contents_of_a_specific_file_should_match( $path, $not,
530534 if ( '/ ' !== $ path [0 ] ) {
531535 $ path = $ this ->variables ['RUN_DIR ' ] . "/ $ path " ;
532536 }
533- $ contents = file_get_contents ( $ path );
537+ $ contents = $ this -> normalize_line_endings ( file_get_contents ( $ path ) );
534538 if ( $ not ) {
535539 $ this ->assert_not_regex ( $ expected , $ contents );
536540 } else {
@@ -559,10 +563,11 @@ public function then_stdout_stderr_should_match_a_string( $stream, $not, $expect
559563 $ expected = $ this ->replace_variables ( $ expected );
560564
561565 $ stream = strtolower ( $ stream );
566+ $ output = $ this ->normalize_line_endings ( $ this ->result ->$ stream );
562567 if ( $ not ) {
563- $ this ->assert_not_regex ( $ expected , $ this -> result -> $ stream );
568+ $ this ->assert_not_regex ( $ expected , $ output );
564569 } else {
565- $ this ->assert_regex ( $ expected , $ this -> result -> $ stream );
570+ $ this ->assert_regex ( $ expected , $ output );
566571 }
567572 }
568573
0 commit comments