From c5d0c8ce12824f68c7e3973a36f40133ec6fa7a6 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Tue, 27 Oct 2020 09:11:19 +0100 Subject: [PATCH] Simplify the function looking for output Signed-off-by: Joas Schilling --- .../features/bootstrap/CommandLine.php | 31 +++---------------- 1 file changed, 4 insertions(+), 27 deletions(-) diff --git a/build/integration/features/bootstrap/CommandLine.php b/build/integration/features/bootstrap/CommandLine.php index 4694102501..b34005fdad 100644 --- a/build/integration/features/bootstrap/CommandLine.php +++ b/build/integration/features/bootstrap/CommandLine.php @@ -23,6 +23,8 @@ * */ +use PHPUnit\Framework\Assert; + require __DIR__ . '/../../vendor/autoload.php'; trait CommandLine { @@ -95,25 +97,6 @@ trait CommandLine { return $exceptions; } - /** - * Finds all lines containing the given text - * - * @param string $input stdout or stderr output - * @param string $text text to search for - * @return array array of lines that matched - */ - public function findLines($input, $text) { - $results = []; - // the exception text usually appears after an "[Exception"] row - foreach (explode("\n", $input) as $line) { - if (strpos($line, $text) !== false) { - $results[] = $line; - } - } - - return $results; - } - /** * @Then /^the command was successful$/ */ @@ -158,19 +141,13 @@ trait CommandLine { * @Then /^the command output contains the text "([^"]*)"$/ */ public function theCommandOutputContainsTheText($text) { - $lines = $this->findLines($this->lastStdOut, $text); - if (empty($lines)) { - throw new \Exception('The command did not output the expected text on stdout "' . $text . '"'); - } + Assert::assertContains($text, $this->lastStdOut, 'The command did not output the expected text on stdout'); } /** * @Then /^the command error output contains the text "([^"]*)"$/ */ public function theCommandErrorOutputContainsTheText($text) { - $lines = $this->findLines($this->lastStdErr, $text); - if (empty($lines)) { - throw new \Exception('The command did not output the expected text on stderr "' . $text . '"'); - } + Assert::assertContains($text, $this->lastStdErr, 'The command did not output the expected text on stderr'); } }