Commit eef37109 authored by Sergio Bertolin's avatar Sergio Bertolin

Starting refactoring

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