diff --git a/tests/integration/config/behat.yml b/tests/integration/config/behat.yml index 8b2b9a4194e69861a1c452037fe5476af31e6673..c7d3f1838649ecfc2f96baa1e41fc4065c506482 100644 --- a/tests/integration/config/behat.yml +++ b/tests/integration/config/behat.yml @@ -12,8 +12,6 @@ default: - admin - admin regular_user_password: 123456 - - CommentsContext: - baseUrl: http://localhost:8080 - TagsContext: baseUrl: http://localhost:8080 - CardDavContext: diff --git a/tests/integration/features/bootstrap/BasicStructure.php b/tests/integration/features/bootstrap/BasicStructure.php index 97b98365e97748573c81b8563c2fa89f20f1929a..5585a66404d21f765ab1858754d5878937a772d0 100644 --- a/tests/integration/features/bootstrap/BasicStructure.php +++ b/tests/integration/features/bootstrap/BasicStructure.php @@ -10,6 +10,7 @@ trait BasicStructure { use Auth; use Trashbin; use Checksums; + use Comments; /** @var string */ private $currentUser = ''; diff --git a/tests/integration/features/bootstrap/CommentsContext.php b/tests/integration/features/bootstrap/Comments.php similarity index 81% rename from tests/integration/features/bootstrap/CommentsContext.php rename to tests/integration/features/bootstrap/Comments.php index 79890adf9ae6eb21c8555d187aee2ece3a5b551c..11e2a2e7b0dcc5a40a949eeee545c53a4694d0bd 100644 --- a/tests/integration/features/bootstrap/CommentsContext.php +++ b/tests/integration/features/bootstrap/Comments.php @@ -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 diff --git a/tests/integration/features/comments.feature b/tests/integration/features/comments.feature index 135bb0165275cbd45749abf589f448ff4e8ff042..437f649cdb046bcf55d3a88c56883dd1df5359f5 100644 --- a/tests/integration/features/comments.feature +++ b/tests/integration/features/comments.feature @@ -1,4 +1,5 @@ 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"