aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorVincent Petry <pvince81@owncloud.com>2015-01-19 17:05:44 +0100
committerVincent Petry <pvince81@owncloud.com>2015-01-19 17:05:44 +0100
commitef8d38ca27d24ff1c2b2b499f74c24dae9d9e906 (patch)
tree05e7e8ee9638ce16c64d69303df005b5b3ba78e6 /tests
parent4894a2c458f49b2c6b49b18cc0055ae087bff1b2 (diff)
downloadnextcloud-server-ef8d38ca27d24ff1c2b2b499f74c24dae9d9e906.tar.gz
nextcloud-server-ef8d38ca27d24ff1c2b2b499f74c24dae9d9e906.zip
Fix chunked query for tags + unit test
Diffstat (limited to 'tests')
-rw-r--r--tests/lib/tags.php32
1 files changed, 29 insertions, 3 deletions
diff --git a/tests/lib/tags.php b/tests/lib/tags.php
index 71296d2e346..547cd302d5d 100644
--- a/tests/lib/tags.php
+++ b/tests/lib/tags.php
@@ -30,7 +30,7 @@ class Test_Tags extends \Test\TestCase {
protected $backupGlobals = FALSE;
/** @var \OC\Tagging\TagMapper */
protected $tagMapper;
- /** @var \OC\TagManager */
+ /** @var \OCP\ITagManager */
protected $tagMgr;
protected function setUp() {
@@ -55,8 +55,9 @@ class Test_Tags extends \Test\TestCase {
}
protected function tearDown() {
- //$query = OC_DB::prepare('DELETE FROM `*PREFIX*vcategories` WHERE `item_type` = ?');
- //$query->execute(array('test'));
+ $conn = \OC_DB::getConnection();
+ $conn->executeQuery('DELETE FROM `*PREFIX*vcategory_to_object`');
+ $conn->executeQuery('DELETE FROM `*PREFIX*vcategory`');
parent::tearDown();
}
@@ -176,6 +177,31 @@ class Test_Tags extends \Test\TestCase {
);
}
+ public function testGetTagsForObjectsMassiveResults() {
+ $defaultTags = array('tag1');
+ $tagger = $this->tagMgr->load($this->objectType, $defaultTags);
+ $tagData = $tagger->getTags();
+ $tagId = $tagData[0]['id'];
+ $tagType = $tagData[0]['type'];
+
+ $conn = \OC_DB::getConnection();
+ $statement = $conn->prepare(
+ 'INSERT INTO `*PREFIX*vcategory_to_object` ' .
+ '(`objid`, `categoryid`, `type`) VALUES ' .
+ '(?, ?, ?)'
+ );
+
+ // insert lots of entries
+ $idsArray = array();
+ for($i = 1; $i <= 1500; $i++) {
+ $statement->execute(array($i, $tagId, $tagType));
+ $idsArray[] = $i;
+ }
+
+ $tags = $tagger->getTagsForObjects($idsArray);
+ $this->assertEquals(1500, count($tags));
+ }
+
public function testDeleteTags() {
$defaultTags = array('Friends', 'Family', 'Work', 'Other');
$tagger = $this->tagMgr->load($this->objectType, $defaultTags);