Commit eef37109 authored by Sergio Bertolin's avatar Sergio Bertolin

Starting refactoring

parent 2259f7f7
......@@ -12,8 +12,6 @@ default:
- admin
- admin
regular_user_password: 123456
- CommentsContext:
baseUrl: http://localhost:8080
- TagsContext:
baseUrl: http://localhost:8080
- CardDavContext:
......
......@@ -10,6 +10,7 @@ trait BasicStructure {
use Auth;
use Trashbin;
use Checksums;
use Comments;
/** @var string */
private $currentUser = '';
......
......@@ -21,49 +21,52 @@
require __DIR__ . '/../../../../lib/composer/autoload.php';
class CommentsContext implements \Behat\Behat\Context\Context {
/** @var string */
private $baseUrl;
/** @var array */
private $response;
//class CommentsContext implements \Behat\Behat\Context\Context {
trait Comments {
use Sharing;
// /** @var string */
// private $baseUrl;
// /** @var array */
// private $response;
/** @var int */
private $commentId;
/** @var int */
private $fileId;
/**
* @param string $baseUrl
*/
public function __construct($baseUrl) {
$this->baseUrl = $baseUrl;
// /**
// * @param string $baseUrl
// */
// public function __construct($baseUrl) {
// $this->baseUrl = $baseUrl;
// in case of ci deployment we take the server url from the environment
$testServerUrl = getenv('TEST_SERVER_URL');
if ($testServerUrl !== false) {
$this->baseUrl = substr($testServerUrl, 0, -5);
}
}
// // in case of ci deployment we take the server url from the environment
// $testServerUrl = getenv('TEST_SERVER_URL');
// if ($testServerUrl !== false) {
// $this->baseUrl = substr($testServerUrl, 0, -5);
// }
// }
/** @AfterScenario */
public function teardownScenario() {
$client = new \GuzzleHttp\Client();
try {
$client->delete(
$this->baseUrl.'/remote.php/webdav/myFileToComment.txt',
[
'auth' => [
'user0',
'123456',
],
'headers' => [
'Content-Type' => 'application/json',
],
]
);
} catch (\GuzzleHttp\Exception\ClientException $e) {
$e->getResponse();
}
}
// /** @AfterScenario */
// public function teardownScenario() {
// $client = new \GuzzleHttp\Client();
// try {
// $client->delete(
// $this->baseUrl.'/remote.php/webdav/myFileToComment.txt',
// [
// 'auth' => [
// 'user0',
// '123456',
// ],
// 'headers' => [
// 'Content-Type' => 'application/json',
// ],
// ]
// );
// } catch (\GuzzleHttp\Exception\ClientException $e) {
// $e->getResponse();
// }
// }
/**
* @param string $path
......@@ -175,22 +178,22 @@ class CommentsContext implements \Behat\Behat\Context\Context {
}
}
/**
* @Given As :user sending :verb to :url with
* @param string $user
* @param string $verb
* @param string $url
* @param \Behat\Gherkin\Node\TableNode $body
* @throws \Exception
*/
public function asUserSendingToWith($user, $verb, $url, \Behat\Gherkin\Node\TableNode $body) {
$client = new \GuzzleHttp\Client();
$options = [];
$options['auth'] = [$user, '123456'];
$fd = $body->getRowsHash();
$options['body'] = $fd;
$client->send($client->createRequest($verb, $this->baseUrl.'/ocs/v1.php/'.$url, $options));
}
// /**
// * @Given As :user sending :verb to :url with
// * @param string $user
// * @param string $verb
// * @param string $url
// * @param \Behat\Gherkin\Node\TableNode $body
// * @throws \Exception
// */
// public function asUserSendingToWith($user, $verb, $url, \Behat\Gherkin\Node\TableNode $body) {
// $client = new \GuzzleHttp\Client();
// $options = [];
// $options['auth'] = [$user, '123456'];
// $fd = $body->getRowsHash();
// $options['body'] = $fd;
// $client->send($client->createRequest($verb, $this->baseUrl.'/ocs/v1.php/'.$url, $options));
// }
/**
* @Then As :user delete the created comment it should return :statusCode
......
Feature: comments
Scenario: Creating a comment on a file belonging to myself
Given user "user0" exists
Given As an "user0"
......@@ -16,12 +17,9 @@ Feature: comments
Scenario: Creating a comment on a shared file belonging to another user
Given user "user0" exists
Given user "user1" exists
Given User "user0" uploads file "data/textfile.txt" to "/myFileToComment.txt"
Given As "user0" sending "POST" to "/apps/files_sharing/api/v1/shares" with
| path | myFileToComment.txt |
| shareWith | user1 |
| shareType | 0 |
And user "user1" exists
And User "user0" uploads file "data/textfile.txt" to "/myFileToComment.txt"
And file "/myFileToComment.txt" of user "user0" is shared with user "user1"
When "user1" posts a comment with content "A comment from another user" on the file named "/myFileToComment.txt" it should return "201"
Then As "user1" load all the comments of the file named "/myFileToComment.txt" it should return "207"
And the response should contain a property "oc:parentId" with value "0"
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment