Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@
"behat/mink-selenium2-driver": "dev-master",
"sensiolabs/behat-page-object-extension": "^2.0",
"behat/behat": "^3.0",
"jarnaiz/behat-junit-formatter": "^1.3"
"jarnaiz/behat-junit-formatter": "^1.3",
"rdx/behat-variables": "^1.2"
},
"require": {
"php": ">=5.4.1",
Expand Down
41 changes: 40 additions & 1 deletion composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions tests/integration/config/behat.yml
Original file line number Diff line number Diff line change
Expand Up @@ -60,3 +60,5 @@ default:
jarnaiz\JUnitFormatter\JUnitFormatterExtension:
filename: report.xml
outputDir: %paths.base%/../output/

rdx\behatvars\BehatVariablesExtension: ~
2 changes: 1 addition & 1 deletion tests/integration/features/bootstrap/FeatureContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
/**
* Features context.
*/
class FeatureContext implements Context, SnippetAcceptingContext {
class FeatureContext extends \rdx\behatvars\BehatVariablesContext {
use BasicStructure;

/**
Expand Down
67 changes: 67 additions & 0 deletions tests/integration/features/bootstrap/WebDav.php
Original file line number Diff line number Diff line change
Expand Up @@ -491,6 +491,58 @@ public function listFolder($user, $path, $folderDepth, $properties = null) {
return $response;
}

public function listVersionFolder($user, $path, $folderDepth, $properties = null) {
$client = $this->getSabreClient($user);
if (!$properties) {
$properties = [
'{DAV:}getetag'
];
}

try {
$response = $client->propfind($this->makeSabrePathNotForFiles($path), $properties, $folderDepth);
} catch (Sabre\HTTP\ClientHttpException $e) {
$response = $e->getResponse();
}
return $response;
}

/**
* @Then the version folder of file :path for user :user contains :count elements
* @param $path
* @param $count
* @param $user
*/
public function theVersionFolderOfFileContainsElements($path, $user, $count) {
$fileId = $this->getFileIdForPath($user, $path);
$elements = $this->listVersionFolder($user, '/meta/'.$fileId.'/v', 1);
PHPUnit_Framework_Assert::assertEquals($count, count($elements)-1);
}

/**
* @Then the version folder of fileId :fileId contains :count elements
* @param int $count
* @param int $fileId
*/
public function theVersionFolderOfFileIdContainsElements($fileId, $count) {
$elements = $this->listVersionFolder($this->currentUser, '/meta/'.$fileId.'/v', 1);
PHPUnit_Framework_Assert::assertEquals($count, count($elements)-1);
}

/**
* @Then the content length of file :path with version index :index for user :user in versions folder is :length
* @param $path
* @param $index
* @param $user
* @param $length
*/
public function theContentLengthOfFileForUserInVersionsFolderIs($path, $index, $user, $length) {
$fileId = $this->getFileIdForPath($user, $path);
$elements = $this->listVersionFolder($user, '/meta/'.$fileId.'/v', 1, ['{DAV:}getcontentlength']);
$elements = array_values($elements);
PHPUnit_Framework_Assert::assertEquals($length, $elements[$index]['{DAV:}getcontentlength']);
}

/* Returns the elements of a report command
* @param string $user
* @param string $path
Expand Down Expand Up @@ -778,6 +830,7 @@ public function userUploadsAFileWithContentTo($user, $content, $destination)
$file = \GuzzleHttp\Stream\Stream::factory($content);
try {
$this->response = $this->makeDavRequest($user, "PUT", $destination, [], $file);
return $this->response->getHeader('oc-fileid');
} catch (BadResponseException $e) {
// 4xx and 5xx responses cause an exception
$this->response = $e->getResponse();
Expand Down Expand Up @@ -1142,4 +1195,18 @@ public function userChecksFileIdForPath($user, $path) {
$currentFileID = $this->getFileIdForPath($user, $path);
PHPUnit_Framework_Assert::assertEquals($currentFileID, $this->storedFileID);
}

/**
* @When user :user restores version index :versionIndex of file :path
* @param string $user
* @param int $versionIndex
* @param string $path
*/
public function userRestoresVersionIndexOfFile($user, $versionIndex, $path) {
$fileId = $this->getFileIdForPath($user, $path);
$client = $this->getSabreClient($user);
$versions = array_keys($this->listVersionFolder($user, '/meta/'.$fileId.'/v', 1));
$client->request('COPY', $versions[$versionIndex], null, ['Destination' => $this->makeSabrePath($user, $path)]);
}

}