Skip to content

Commit e8754ff

Browse files
committed
Made a distinction between errors and warnings when checking the DB command.
1 parent 24d41ed commit e8754ff

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

src/Context/FeatureContext.php

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1134,12 +1134,19 @@ public function test_connection(): void {
11341134
'send_to_shell' => false,
11351135
]
11361136
);
1137-
if ( ! empty( $sql_result['stderr'] ) ) {
1137+
1138+
if ( $sql_result['exit_code'] !== 0 ) {
11381139
# WP_CLI output functions are suppressed in behat context.
11391140
echo 'There was an error connecting to the database:' . \PHP_EOL;
1140-
echo ' ' . trim( $sql_result['stderr'] ) . \PHP_EOL;
1141+
if ( ! empty( $sql_result['stderr'] ) ) {
1142+
echo ' ' . trim( $sql_result['stderr'] ) . \PHP_EOL;
1143+
}
11411144
echo 'run `composer prepare-tests` to connect to the database.' . \PHP_EOL;
1142-
die( 1 );
1145+
die( $sql_result['exit_code'] );
1146+
} elseif ( ! empty( $sql_result['stderr'] ) ) {
1147+
// There is "error" output but not an exit code.
1148+
// Probably a warning, still display it.
1149+
echo trim( $sql_result['stderr'] ) . \PHP_EOL;
11431150
}
11441151
}
11451152

0 commit comments

Comments
 (0)