Skip to content

Commit

Permalink
Fix integration tests findLines strpos check
Browse files Browse the repository at this point in the history
  • Loading branch information
phil-davis committed Sep 7, 2017
1 parent ed7a6c7 commit 701bf24
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 13 deletions.
12 changes: 6 additions & 6 deletions tests/integration/features/bootstrap/CommandLine.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@ trait CommandLine {
/**
* Invokes an OCC command
*
* @param string OCC command, the part behind "occ". For example: "files:transfer-ownership"
* @param array $args of the occ command
* @param bool $escaping
* @return int exit code
*/
public function runOcc($args = [], $escaping = true) {
Expand Down Expand Up @@ -70,7 +71,7 @@ public function invokingTheCommand($cmd) {
public function findExceptions() {
$exceptions = [];
$captureNext = false;
// the exception text usually appears after an "[Exception"] row
// the exception text usually appears after an "[Exception]" row
foreach (explode("\n", $this->lastStdErr) as $line) {
if (preg_match('/\[Exception\]/', $line)) {
$captureNext = true;
Expand All @@ -94,9 +95,8 @@ public function findExceptions() {
*/
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) >= 0) {
if (strpos($line, $text) !== false) {
$results[] = $line;
}
}
Expand Down Expand Up @@ -150,7 +150,7 @@ public function theCommandFailedWithException($exceptionText) {
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 "' . $exceptionText . '"');
throw new \Exception('The command did not output the expected text on stdout "' . $text . '"');
}
}

Expand All @@ -160,7 +160,7 @@ public function theCommandOutputContainsTheText($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 "' . $exceptionText . '"');
throw new \Exception('The command did not output the expected text on stderr "' . $text . '"');
}
}
}
14 changes: 7 additions & 7 deletions tests/integration/features/transfer-ownership.feature
Original file line number Diff line number Diff line change
Expand Up @@ -130,13 +130,13 @@ Feature: transfer-ownership
Scenario: transfering ownership fails with invalid source user
Given user "user0" exists
When transfering ownership from "invalid_user" to "user0"
Then the command error output contains the text "Unknown source user"
Then the command output contains the text "Unknown source user"
And the command failed with exit code 1

Scenario: transfering ownership fails with invalid target user
Scenario: transfering ownership fails with invalid destination user
Given user "user0" exists
When transfering ownership from "user0" to "invalid_user"
Then the command error output contains the text "Unknown target user"
Then the command output contains the text "Unknown destination user"
And the command failed with exit code 1

@no_default_encryption
Expand Down Expand Up @@ -236,19 +236,19 @@ Feature: transfer-ownership
Given user "user0" exists
And User "user0" created a folder "/sub"
When transfering ownership of path "sub" from "invalid_user" to "user0"
Then the command error output contains the text "Unknown source user"
Then the command output contains the text "Unknown source user"
And the command failed with exit code 1

Scenario: transfering ownership fails with invalid target user
Scenario: transfering ownership fails with invalid destination user
Given user "user0" exists
And User "user0" created a folder "/sub"
When transfering ownership of path "sub" from "user0" to "invalid_user"
Then the command error output contains the text "Unknown target user"
Then the command output contains the text "Unknown destination user"
And the command failed with exit code 1

Scenario: transfering ownership fails with invalid path
Given user "user0" exists
And user "user1" exists
When transfering ownership of path "test" from "user0" to "user1"
Then the command error output contains the text "Unknown target user"
Then the command output contains the text "Unknown path provided"
And the command failed with exit code 1

0 comments on commit 701bf24

Please sign in to comment.