diff --git a/tests/acceptance/bootstrap/TagContext.php b/tests/acceptance/bootstrap/TagContext.php index 9f559ef8334..4b63888a8ce 100644 --- a/tests/acceptance/bootstrap/TagContext.php +++ b/tests/acceptance/bootstrap/TagContext.php @@ -56,25 +56,21 @@ class TagContext implements Context { /** * @param string $user - * @param string $fileOrFolder (file|folder) + * @param string $fileOrFolder (file|folder) * @param string $resource * @param string $space - * @param TableNode $table + * @param array $tagNameArray * * @return ResponseInterface - * @throws Exception + * @throws \GuzzleHttp\Exception\GuzzleException */ public function createTags( string $user, string $fileOrFolder, string $resource, string $space, - TableNode $table + array $tagNameArray ): ResponseInterface { - $tagNameArray = []; - foreach ($table->getRows() as $value) { - $tagNameArray[] = $value[0]; - } if ($fileOrFolder === 'folder' || $fileOrFolder === 'folders') { $resourceId = $this->spacesContext->getResourceId($user, $space, $resource); } else { @@ -109,7 +105,11 @@ class TagContext implements Context { string $space, TableNode $table ): void { - $response = $this->createTags($user, $fileOrFolder, $resource, $space, $table); + $tagNameArray = []; + foreach ($table->getRows() as $value) { + $tagNameArray[] = $value[0]; + } + $response = $this->createTags($user, $fileOrFolder, $resource, $space, $tagNameArray); $this->featureContext->setResponse($response); } @@ -132,7 +132,11 @@ class TagContext implements Context { string $space, TableNode $table ): void { - $response = $this->createTags($user, $fileOrFolder, $resource, $space, $table); + $tagNameArray = []; + foreach ($table->getRows() as $value) { + $tagNameArray[] = $value[0]; + } + $response = $this->createTags($user, $fileOrFolder, $resource, $space, $tagNameArray); $this->featureContext->theHttpStatusCodeShouldBe(200, "", $response); } @@ -156,8 +160,8 @@ class TagContext implements Context { $this->featureContext->verifyTableNodeColumns($table, ["path", "tagName"]); $rows = $table->getHash(); foreach ($rows as $row) { - $tags = explode(',', $row['tagName']); - $response = $this->createTags($user, $filesOrFolders, $row['path'], $space, new TableNode([$tags])); + $tagNameArray = array_map('trim', explode(',', $row['tagName'])); + $response = $this->createTags($user, $filesOrFolders, $row['path'], $space, $tagNameArray); $this->featureContext->theHttpStatusCodeShouldBe(200, "", $response); } } @@ -302,4 +306,31 @@ class TagContext implements Context { $response = $this->removeTagsFromResourceOfTheSpace($user, $fileOrFolder, $resource, $space, $table); $this->featureContext->theHttpStatusCodeShouldBe(200, "", $response); } + + /** + * @When /^user "([^"]*)" creates "([^"]*)" tags for (folder|file) "([^"]*)" of space "([^"]*)"$/ + * + * @param string $user + * @param int $numberOfTags + * @param string $fileOrFolder (file|folder) + * @param string $resource + * @param string $space + * + * @return void + * @throws Exception + */ + public function userCreatesTagsForResourceOfSpace( + string $user, + int $numberOfTags, + string $fileOrFolder, + string $resource, + string $space + ): void { + $tagNames = []; + foreach (range(1, $numberOfTags) as $tagNumber) { + $tagNames[] = "testTag$tagNumber"; + } + $response = $this->createTags($user, $fileOrFolder, $resource, $space, $tagNames); + $this->featureContext->setResponse($response); + } } diff --git a/tests/acceptance/config/behat.yml b/tests/acceptance/config/behat.yml index 03a0f2a0dc7..b2ffab7278f 100644 --- a/tests/acceptance/config/behat.yml +++ b/tests/acceptance/config/behat.yml @@ -46,6 +46,7 @@ default: - OcisConfigContext: - WebDavLockingContext: - SharingNgContext: + - SearchContext: apiSpacesShares: paths: diff --git a/tests/acceptance/expected-failures-without-remotephp.md b/tests/acceptance/expected-failures-without-remotephp.md index 5d1b641189f..c6452cd0f9a 100644 --- a/tests/acceptance/expected-failures-without-remotephp.md +++ b/tests/acceptance/expected-failures-without-remotephp.md @@ -121,6 +121,7 @@ - [apiSearchContent/contentSearch.feature:238](https://github.com/owncloud/ocis/blob/master/tests/acceptance/features/apiSearchContent/contentSearch.feature#L238) - [apiSearchContent/contentSearch.feature:239](https://github.com/owncloud/ocis/blob/master/tests/acceptance/features/apiSearchContent/contentSearch.feature#L239) - [apiSearchContent/contentSearch.feature:268](https://github.com/owncloud/ocis/blob/master/tests/acceptance/features/apiSearchContent/contentSearch.feature#L268) +- [apiSpaces/tag.feature:369](https://github.com/owncloud/ocis/blob/master/tests/acceptance/features/apiSpaces/tag.feature#L369) - [cliCommands/searchReIndex.feature:15](https://github.com/owncloud/ocis/blob/master/tests/acceptance/features/cliCommands/searchReIndex.feature#L15) - [coreApiWebdavOperations/search.feature:44](https://github.com/owncloud/ocis/blob/master/tests/acceptance/features/coreApiWebdavOperations/search.feature#L44) - [coreApiWebdavOperations/search.feature:62](https://github.com/owncloud/ocis/blob/master/tests/acceptance/features/coreApiWebdavOperations/search.feature#L62) diff --git a/tests/acceptance/features/apiSpaces/tag.feature b/tests/acceptance/features/apiSpaces/tag.feature index 4d5a7a1173e..8acec94c378 100644 --- a/tests/acceptance/features/apiSpaces/tag.feature +++ b/tests/acceptance/features/apiSpaces/tag.feature @@ -363,4 +363,18 @@ Feature: Tag When user "Alice" creates the following tags for folder "folderMain" of space "Alice Hansen": | my tag | | Loremipsumdolorsitametconsecteturadipiscingelitseddoeiusmodtemporincididuntutlaboreetdoloremagnaaliqua,qa | - Then the HTTP status code should be "200" \ No newline at end of file + Then the HTTP status code should be "200" + + + Scenario: user tries to create tags above 100, only first 100 tags will be created + Given the config "OCIS_MAX_TAG_LENGTH" has been set to "100" + And user "Alice" has created a folder "folderMain" in space "Alice Hansen" + When user "Alice" creates "200" tags for folder "folderMain" of space "Alice Hansen" + Then the HTTP status code should be "200" + When user "Alice" searches for "Tags:testTag100" using the WebDAV API + Then the HTTP status code should be "207" + And the search result of user "Alice" should contain only these files: + | folderMain | + When user "Alice" searches for "Tags:testTag101" using the WebDAV API + Then the HTTP status code should be "207" + And the search result should contain "0" entries