PHPUnit_Framework_Assert::assertEquals(200, $this->response->getStatusCode());
}
+ /**
+ * @Given user :user has a quota of :quota
+ */
+ public function userHasAQuotaOf($user, $quota)
+ {
+ $body = new \Behat\Gherkin\Node\TableNode([
+ 0 => ['key', 'quota'],
+ 1 => ['value', $quota],
+ ]);
+
+ // method used from BasicStructure trait
+ $this->sendingToWith("PUT", "/cloud/users/" . $user, $body);
+ }
+
/**
* @BeforeScenario
* @AfterScenario
$this->davPath = $davPath;
}
- public function makeDavRequest($user, $method, $path, $headers){
+ public function makeDavRequest($user, $method, $path, $headers, $body = null){
$fullUrl = substr($this->baseUrl, 0, -4) . $this->davPath . "$path";
$client = new GClient();
$options = [];
$request->addHeader($key, $value);
}
}
+
+ if (!is_null($body)) {
+ $request->setBody($body);
+ }
+
return $client->send($request);
}
}
}
}
-
+
+ /**
+ * @When User :user uploads file :source to :destination
+ */
+ public function userUploadsAFileTo($user, $source, $destination)
+ {
+ $file = \GuzzleHttp\Stream\Stream::factory(fopen($source, 'r'));
+ try {
+ $this->response = $this->makeDavRequest($user, "PUT", $destination, [], $file);
+ } catch (\GuzzleHttp\Exception\ServerException $e) {
+ // 4xx and 5xx responses cause an exception
+ $this->response = $e->getResponse();
+ }
+ }
}
Then Downloaded content should be "example file for developers"
+ Scenario: Upload forbidden if quota is 0
+ Given using dav path "remote.php/webdav"
+ And As an "admin"
+ And user "user0" exists
+ And user "user0" has a quota of "0"
+ When User "user0" uploads file "data/textfile.txt" to "/asdf.txt"
+ Then the HTTP status code should be "507"