diff options
author | Joas Schilling <coding@schilljs.com> | 2020-10-27 09:11:19 +0100 |
---|---|---|
committer | Joas Schilling <coding@schilljs.com> | 2020-10-27 09:11:19 +0100 |
commit | c5d0c8ce12824f68c7e3973a36f40133ec6fa7a6 (patch) | |
tree | 8a11485c90cb93f1392e594ce6335a6716ec7627 /build | |
parent | dd3d5829e73c90a9f3ee068ab103ed1b04f97e35 (diff) | |
download | nextcloud-server-c5d0c8ce12824f68c7e3973a36f40133ec6fa7a6.tar.gz nextcloud-server-c5d0c8ce12824f68c7e3973a36f40133ec6fa7a6.zip |
Simplify the function looking for output
Signed-off-by: Joas Schilling <coding@schilljs.com>
Diffstat (limited to 'build')
-rw-r--r-- | build/integration/features/bootstrap/CommandLine.php | 31 |
1 files changed, 4 insertions, 27 deletions
diff --git a/build/integration/features/bootstrap/CommandLine.php b/build/integration/features/bootstrap/CommandLine.php index 46941025012..b34005fdadf 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 { @@ -96,25 +98,6 @@ trait CommandLine { } /** - * 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$/ */ public function theCommandWasSuccessful() { @@ -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'); } } |