Skip to content

Commit

Permalink
Merge pull request #28922 from owncloud/integration-tests-findLines
Browse files Browse the repository at this point in the history
Fix integration tests findLines strpos check
  • Loading branch information
Vincent Petry authored Sep 7, 2017
2 parents ed7a6c7 + 81ce78a commit acfa465
Show file tree
Hide file tree
Showing 3 changed files with 59 additions and 59 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 . '"');
}
}
}
8 changes: 4 additions & 4 deletions tests/integration/features/bootstrap/CommandLineContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -77,9 +77,9 @@ private function findLastTransferFolderForUser($sourceUser, $targetUser) {
}

/**
* @When /^transfering ownership from "([^"]+)" to "([^"]+)"/
* @When /^transferring ownership from "([^"]+)" to "([^"]+)"/
*/
public function transferingOwnership($user1, $user2) {
public function transferringOwnership($user1, $user2) {
if ($this->runOcc(['files:transfer-ownership', $user1, $user2]) === 0) {
$this->lastTransferPath = $this->findLastTransferFolderForUser($user1, $user2);
} else {
Expand All @@ -89,9 +89,9 @@ public function transferingOwnership($user1, $user2) {
}

/**
* @When /^transfering ownership of path "([^"]+)" from "([^"]+)" to "([^"]+)"/
* @When /^transferring ownership of path "([^"]+)" from "([^"]+)" to "([^"]+)"/
*/
public function transferingOwnershipPath($path, $user1, $user2) {
public function transferringOwnershipPath($path, $user1, $user2) {
$path = '--path=' . $path;
if($this->runOcc(['files:transfer-ownership', $path, $user1, $user2]) === 0) {
$this->lastTransferPath = $this->findLastTransferFolderForUser($user1, $user2);
Expand Down
98 changes: 49 additions & 49 deletions tests/integration/features/transfer-ownership.feature
Original file line number Diff line number Diff line change
@@ -1,83 +1,83 @@
Feature: transfer-ownership

@no_default_encryption
Scenario: transfering ownership of a file
Scenario: transferring ownership of a file
Given user "user0" exists
And user "user1" exists
And User "user0" uploads file "data/textfile.txt" to "/somefile.txt"
When transfering ownership from "user0" to "user1"
When transferring ownership from "user0" to "user1"
And the command was successful
And As an "user1"
And using received transfer folder of "user1" as dav path
Then Downloaded content when downloading file "/somefile.txt" with range "bytes=0-6" should be "This is"

@no_default_encryption
Scenario: transfering ownership of a file after updating the file
Scenario: transferring ownership of a file after updating the file
Given user "user0" exists
And user "user1" exists
And User "user0" uploads file "data/file_to_overwrite.txt" to "/PARENT/textfile0.txt"
And user "user0" uploads chunk file "1" of "3" with "AA" to "/PARENT/textfile0.txt"
And user "user0" uploads chunk file "2" of "3" with "BB" to "/PARENT/textfile0.txt"
And user "user0" uploads chunk file "3" of "3" with "CC" to "/PARENT/textfile0.txt"
When transfering ownership from "user0" to "user1"
When transferring ownership from "user0" to "user1"
Then the command was successful
And As an "user1"
And using received transfer folder of "user1" as dav path
Then Downloaded content when downloading file "/PARENT/textfile0.txt" with range "bytes=0-5" should be "AABBCC"

@no_default_encryption
Scenario: transfering ownership of a folder
Scenario: transferring ownership of a folder
Given user "user0" exists
And user "user1" exists
And User "user0" created a folder "/test"
And User "user0" uploads file "data/textfile.txt" to "/test/somefile.txt"
When transfering ownership from "user0" to "user1"
When transferring ownership from "user0" to "user1"
And the command was successful
And As an "user1"
And using received transfer folder of "user1" as dav path
Then Downloaded content when downloading file "/test/somefile.txt" with range "bytes=0-6" should be "This is"

@no_default_encryption
Scenario: transfering ownership of file shares
Scenario: transferring ownership of file shares
Given user "user0" exists
And user "user1" exists
And user "user2" exists
And User "user0" uploads file "data/textfile.txt" to "/somefile.txt"
And file "/somefile.txt" of user "user0" is shared with user "user2" with permissions 19
When transfering ownership from "user0" to "user1"
When transferring ownership from "user0" to "user1"
And the command was successful
And As an "user2"
Then Downloaded content when downloading file "/somefile.txt" with range "bytes=0-6" should be "This is"

@no_default_encryption
Scenario: transfering ownership of folder shared with third user
Scenario: transferring ownership of folder shared with third user
Given user "user0" exists
And user "user1" exists
And user "user2" exists
And User "user0" created a folder "/test"
And User "user0" uploads file "data/textfile.txt" to "/test/somefile.txt"
And folder "/test" of user "user0" is shared with user "user2" with permissions 31
When transfering ownership from "user0" to "user1"
When transferring ownership from "user0" to "user1"
And the command was successful
And As an "user2"
Then Downloaded content when downloading file "/test/somefile.txt" with range "bytes=0-6" should be "This is"

@no_default_encryption
Scenario: transfering ownership of folder shared with transfer recipient
Scenario: transferring ownership of folder shared with transfer recipient
Given user "user0" exists
And user "user1" exists
And User "user0" created a folder "/test"
And User "user0" uploads file "data/textfile.txt" to "/test/somefile.txt"
And folder "/test" of user "user0" is shared with user "user1" with permissions 31
When transfering ownership from "user0" to "user1"
When transferring ownership from "user0" to "user1"
And the command was successful
And As an "user1"
Then as "user1" the folder "/test" does not exist
And using received transfer folder of "user1" as dav path
And Downloaded content when downloading file "/test/somefile.txt" with range "bytes=0-6" should be "This is"

@no_default_encryption
Scenario: transfering ownership of folder doubly shared with third user
Scenario: transferring ownership of folder doubly shared with third user
Given group "group1" exists
And user "user0" exists
And user "user1" exists
Expand All @@ -87,112 +87,112 @@ Feature: transfer-ownership
And User "user0" uploads file "data/textfile.txt" to "/test/somefile.txt"
And folder "/test" of user "user0" is shared with group "group1" with permissions 31
And folder "/test" of user "user0" is shared with user "user2" with permissions 31
When transfering ownership from "user0" to "user1"
When transferring ownership from "user0" to "user1"
And the command was successful
And As an "user2"
Then Downloaded content when downloading file "/test/somefile.txt" with range "bytes=0-6" should be "This is"

@no_default_encryption
Scenario: transfering ownership does not transfer received shares
Scenario: transferring ownership does not transfer received shares
Given user "user0" exists
And user "user1" exists
And user "user2" exists
And User "user2" created a folder "/test"
And folder "/test" of user "user2" is shared with user "user0" with permissions 31
When transfering ownership from "user0" to "user1"
When transferring ownership from "user0" to "user1"
And the command was successful
And As an "user1"
And using received transfer folder of "user1" as dav path
Then as "user1" the folder "/test" does not exist

@local_storage @no_default_encryption
Scenario: transfering ownership does not transfer external storage
Scenario: transferring ownership does not transfer external storage
Given user "user0" exists
And user "user1" exists
When transfering ownership from "user0" to "user1"
When transferring ownership from "user0" to "user1"
And the command was successful
And As an "user1"
And using received transfer folder of "user1" as dav path
Then as "user1" the folder "/local_storage" does not exist

@no_default_encryption
Scenario: transfering ownership does not fail with shared trashed files
Scenario: transferring ownership does not fail with shared trashed files
Given user "user0" exists
And user "user1" exists
And user "user2" exists
And User "user0" created a folder "/sub"
And User "user0" created a folder "/sub/test"
And folder "/sub/test" of user "user0" is shared with user "user2" with permissions 31
And User "user0" deletes folder "/sub"
When transfering ownership from "user0" to "user1"
When transferring ownership from "user0" to "user1"
Then the command was successful

Scenario: transfering ownership fails with invalid source user
Scenario: transferring 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"
When transferring ownership from "invalid_user" to "user0"
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: transferring 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"
When transferring ownership from "user0" to "invalid_user"
Then the command output contains the text "Unknown destination user"
And the command failed with exit code 1

@no_default_encryption
Scenario: transfering ownership of a folder
Scenario: transferring ownership of a folder
Given user "user0" exists
And user "user1" exists
And User "user0" created a folder "/test"
And User "user0" uploads file "data/textfile.txt" to "/test/somefile.txt"
When transfering ownership of path "test" from "user0" to "user1"
When transferring ownership of path "test" from "user0" to "user1"
And the command was successful
And As an "user1"
And using received transfer folder of "user1" as dav path
Then Downloaded content when downloading file "/test/somefile.txt" with range "bytes=0-6" should be "This is"

@no_default_encryption
Scenario: transfering ownership of file shares
Scenario: transferring ownership of file shares
Given user "user0" exists
And user "user1" exists
And user "user2" exists
And User "user0" created a folder "/test"
And User "user0" uploads file "data/textfile.txt" to "/test/somefile.txt"
And file "/test/somefile.txt" of user "user0" is shared with user "user2" with permissions 19
When transfering ownership of path "test" from "user0" to "user1"
When transferring ownership of path "test" from "user0" to "user1"
And the command was successful
And As an "user2"
Then Downloaded content when downloading file "/somefile.txt" with range "bytes=0-6" should be "This is"

@no_default_encryption
Scenario: transfering ownership of folder shared with third user
Scenario: transferring ownership of folder shared with third user
Given user "user0" exists
And user "user1" exists
And user "user2" exists
And User "user0" created a folder "/test"
And User "user0" uploads file "data/textfile.txt" to "/test/somefile.txt"
And folder "/test" of user "user0" is shared with user "user2" with permissions 31
When transfering ownership of path "test" from "user0" to "user1"
When transferring ownership of path "test" from "user0" to "user1"
And the command was successful
And As an "user2"
Then Downloaded content when downloading file "/test/somefile.txt" with range "bytes=0-6" should be "This is"

@no_default_encryption
Scenario: transfering ownership of folder shared with transfer recipient
Scenario: transferring ownership of folder shared with transfer recipient
Given user "user0" exists
And user "user1" exists
And User "user0" created a folder "/test"
And User "user0" uploads file "data/textfile.txt" to "/test/somefile.txt"
And folder "/test" of user "user0" is shared with user "user1" with permissions 31
When transfering ownership of path "test" from "user0" to "user1"
When transferring ownership of path "test" from "user0" to "user1"
And the command was successful
And As an "user1"
Then as "user1" the folder "/test" does not exist
And using received transfer folder of "user1" as dav path
And Downloaded content when downloading file "/test/somefile.txt" with range "bytes=0-6" should be "This is"

@no_default_encryption
Scenario: transfering ownership of folder doubly shared with third user
Scenario: transferring ownership of folder doubly shared with third user
Given group "group1" exists
And user "user0" exists
And user "user1" exists
Expand All @@ -202,53 +202,53 @@ Feature: transfer-ownership
And User "user0" uploads file "data/textfile.txt" to "/test/somefile.txt"
And folder "/test" of user "user0" is shared with group "group1" with permissions 31
And folder "/test" of user "user0" is shared with user "user2" with permissions 31
When transfering ownership of path "test" from "user0" to "user1"
When transferring ownership of path "test" from "user0" to "user1"
And the command was successful
And As an "user2"
Then Downloaded content when downloading file "/test/somefile.txt" with range "bytes=0-6" should be "This is"

Scenario: transfering ownership does not transfer received shares
Scenario: transferring ownership does not transfer received shares
Given user "user0" exists
And user "user1" exists
And user "user2" exists
And User "user2" created a folder "/test"
And User "user0" created a folder "/sub"
And folder "/test" of user "user2" is shared with user "user0" with permissions 31
And User "user0" moved folder "/test" to "/sub/test"
When transfering ownership of path "sub" from "user0" to "user1"
When transferring ownership of path "sub" from "user0" to "user1"
And the command was successful
And As an "user1"
And using received transfer folder of "user1" as dav path
Then as "user1" the folder "/sub/test" does not exist

@local_storage
Scenario: transfering ownership does not transfer external storage
Scenario: transferring ownership does not transfer external storage
Given user "user0" exists
And user "user1" exists
And User "user0" created a folder "/sub"
When transfering ownership of path "sub" from "user0" to "user1"
When transferring ownership of path "sub" from "user0" to "user1"
And the command was successful
And As an "user1"
And using received transfer folder of "user1" as dav path
Then as "user1" the folder "/local_storage" does not exist

Scenario: transfering ownership fails with invalid source user
Scenario: transferring ownership fails with invalid source user
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"
When transferring ownership of path "sub" from "invalid_user" to "user0"
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: transferring 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"
When transferring ownership of path "sub" from "user0" to "invalid_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
Scenario: transferring 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"
When transferring ownership of path "test" from "user0" to "user1"
Then the command output contains the text "Unknown path provided"
And the command failed with exit code 1

0 comments on commit acfa465

Please sign in to comment.