diff options
author | Bernhard Posselt <dev@bernhard-posselt.com> | 2014-10-21 18:19:23 +0200 |
---|---|---|
committer | Bernhard Posselt <dev@bernhard-posselt.com> | 2014-10-21 18:19:23 +0200 |
commit | 66c73a96ac2dda076bcfe0dc0a1ca2a7e169149d (patch) | |
tree | dc0318fa459e4f313217ee38e4bc63524513d721 /tests/unit/db | |
parent | f5e64d35c05b14016eb4fffff7199386a97a9b43 (diff) |
first try to set indention limit at 80 characters in php
Diffstat (limited to 'tests/unit/db')
-rw-r--r-- | tests/unit/db/FeedMapperTest.php | 79 | ||||
-rw-r--r-- | tests/unit/db/FolderMapperTest.php | 12 | ||||
-rw-r--r-- | tests/unit/db/ItemMapperTest.php | 106 | ||||
-rw-r--r-- | tests/unit/db/MapperFactoryTest.php | 3 | ||||
-rw-r--r-- | tests/unit/db/postgres/ItemMapperTest.php | 2 |
5 files changed, 112 insertions, 90 deletions
diff --git a/tests/unit/db/FeedMapperTest.php b/tests/unit/db/FeedMapperTest.php index a1a570b87..9bbce1ab0 100644 --- a/tests/unit/db/FeedMapperTest.php +++ b/tests/unit/db/FeedMapperTest.php @@ -47,10 +47,12 @@ class FeedMapperTest extends \Test\AppFramework\Db\MapperTestUtility { StatusFlag::UNREAD . ' ' . 'WHERE `feeds`.`id` = ? ' . 'AND `feeds`.`user_id` = ? ' . - 'GROUP BY `feeds`.`id`, `feeds`.`user_id`, `feeds`.`url_hash`,'. - '`feeds`.`url`, `feeds`.`title`, `feeds`.`link`,'. - '`feeds`.`favicon_link`, `feeds`.`added`, `feeds`.`articles_per_update`,'. - '`feeds`.`folder_id`, `feeds`.`prevent_update`, `feeds`.`deleted_at`'; + 'GROUP BY `feeds`.`id`, `feeds`.`user_id`, ' . + '`feeds`.`url_hash`, '. + '`feeds`.`url`, `feeds`.`title`, `feeds`.`link`, '. + '`feeds`.`favicon_link`, `feeds`.`added`, ' . + '`feeds`.`articles_per_update`, `feeds`.`folder_id`, ' . + '`feeds`.`prevent_update`, `feeds`.`deleted_at`'; $params = [$id, $userId]; $this->setMapperResult($sql, $params, $rows); @@ -71,14 +73,18 @@ class FeedMapperTest extends \Test\AppFramework\Db\MapperTestUtility { StatusFlag::UNREAD . ' ' . 'WHERE `feeds`.`id` = ? ' . 'AND `feeds`.`user_id` = ? ' . - 'GROUP BY `feeds`.`id`, `feeds`.`user_id`, `feeds`.`url_hash`,'. - '`feeds`.`url`, `feeds`.`title`, `feeds`.`link`,'. - '`feeds`.`favicon_link`, `feeds`.`added`, `feeds`.`articles_per_update`,'. - '`feeds`.`folder_id`, `feeds`.`prevent_update`, `feeds`.`deleted_at`'; + 'GROUP BY `feeds`.`id`, `feeds`.`user_id`, ' . + '`feeds`.`url_hash`, '. + '`feeds`.`url`, `feeds`.`title`, `feeds`.`link`, '. + '`feeds`.`favicon_link`, `feeds`.`added`, ' . + '`feeds`.`articles_per_update`, `feeds`.`folder_id`, ' . + '`feeds`.`prevent_update`, `feeds`.`deleted_at`'; $params = [$id, $userId]; $this->setMapperResult($sql, $params); - $this->setExpectedException('\OCP\AppFramework\Db\DoesNotExistException'); + $this->setExpectedException( + '\OCP\AppFramework\Db\DoesNotExistException' + ); $this->mapper->find($id, $userId); } @@ -98,14 +104,18 @@ class FeedMapperTest extends \Test\AppFramework\Db\MapperTestUtility { StatusFlag::UNREAD . ' ' . 'WHERE `feeds`.`id` = ? ' . 'AND `feeds`.`user_id` = ? ' . - 'GROUP BY `feeds`.`id`, `feeds`.`user_id`, `feeds`.`url_hash`,'. - '`feeds`.`url`, `feeds`.`title`, `feeds`.`link`,'. - '`feeds`.`favicon_link`, `feeds`.`added`, `feeds`.`articles_per_update`,'. - '`feeds`.`folder_id`, `feeds`.`prevent_update`, `feeds`.`deleted_at`'; + 'GROUP BY `feeds`.`id`, `feeds`.`user_id`, ' . + '`feeds`.`url_hash`, '. + '`feeds`.`url`, `feeds`.`title`, `feeds`.`link`, '. + '`feeds`.`favicon_link`, `feeds`.`added`, ' . + '`feeds`.`articles_per_update`, `feeds`.`folder_id`, ' . + '`feeds`.`prevent_update`, `feeds`.`deleted_at`'; $params = [$id, $userId]; $this->setMapperResult($sql, $params, $rows); - $this->setExpectedException('\OCP\AppFramework\Db\MultipleObjectsReturnedException'); + $this->setExpectedException( + '\OCP\AppFramework\Db\MultipleObjectsReturnedException' + ); $this->mapper->find($id, $userId); } @@ -121,10 +131,6 @@ class FeedMapperTest extends \Test\AppFramework\Db\MapperTestUtility { 'ON `feeds`.`folder_id` = `folders`.`id` ' . 'LEFT JOIN `*PREFIX*news_items` `items` ' . 'ON `feeds`.`id` = `items`.`feed_id` ' . - // WARNING: this is a desperate attempt at making this query work - // because prepared statements dont work. This is a possible - // SQL INJECTION RISK WHEN MODIFIED WITHOUT THOUGHT. - // think twice when changing this 'AND (`items`.`status` & ' . StatusFlag::UNREAD . ') = ' . StatusFlag::UNREAD . ' ' . 'WHERE (`feeds`.`folder_id` = 0 ' . @@ -133,8 +139,9 @@ class FeedMapperTest extends \Test\AppFramework\Db\MapperTestUtility { 'AND `feeds`.`deleted_at` = 0 ' . 'GROUP BY `feeds`.`id`, `feeds`.`user_id`, `feeds`.`url_hash`,'. '`feeds`.`url`, `feeds`.`title`, `feeds`.`link`,'. - '`feeds`.`favicon_link`, `feeds`.`added`, `feeds`.`articles_per_update`,'. - '`feeds`.`folder_id`, `feeds`.`prevent_update`, `feeds`.`deleted_at`'; + '`feeds`.`favicon_link`, `feeds`.`added`, ' . + '`feeds`.`articles_per_update`, `feeds`.`folder_id`, ' . + '`feeds`.`prevent_update`, `feeds`.`deleted_at`'; $this->setMapperResult($sql, [], $rows); @@ -155,10 +162,6 @@ class FeedMapperTest extends \Test\AppFramework\Db\MapperTestUtility { 'ON `feeds`.`folder_id` = `folders`.`id` ' . 'LEFT JOIN `*PREFIX*news_items` `items` ' . 'ON `feeds`.`id` = `items`.`feed_id` ' . - // WARNING: this is a desperate attempt at making this query work - // because prepared statements dont work. This is a possible - // SQL INJECTION RISK WHEN MODIFIED WITHOUT THOUGHT. - // think twice when changing this 'AND (`items`.`status` & ' . StatusFlag::UNREAD . ') = ' . StatusFlag::UNREAD . ' ' . 'WHERE `feeds`.`user_id` = ? ' . @@ -168,8 +171,9 @@ class FeedMapperTest extends \Test\AppFramework\Db\MapperTestUtility { 'AND `feeds`.`deleted_at` = 0 ' . 'GROUP BY `feeds`.`id`, `feeds`.`user_id`, `feeds`.`url_hash`,'. '`feeds`.`url`, `feeds`.`title`, `feeds`.`link`,'. - '`feeds`.`favicon_link`, `feeds`.`added`, `feeds`.`articles_per_update`,'. - '`feeds`.`folder_id`, `feeds`.`prevent_update`, `feeds`.`deleted_at`'; + '`feeds`.`favicon_link`, `feeds`.`added`, ' . + '`feeds`.`articles_per_update`, `feeds`.`folder_id`, ' . + '`feeds`.`prevent_update`, `feeds`.`deleted_at`'; $this->setMapperResult($sql, [$userId], $rows); $result = $this->mapper->findAllFromUser($userId); @@ -190,8 +194,9 @@ class FeedMapperTest extends \Test\AppFramework\Db\MapperTestUtility { 'AND `feeds`.`user_id` = ? ' . 'GROUP BY `feeds`.`id`, `feeds`.`user_id`, `feeds`.`url_hash`,'. '`feeds`.`url`, `feeds`.`title`, `feeds`.`link`,'. - '`feeds`.`favicon_link`, `feeds`.`added`, `feeds`.`articles_per_update`,'. - '`feeds`.`folder_id`, `feeds`.`prevent_update`, `feeds`.`deleted_at`'; + '`feeds`.`favicon_link`, `feeds`.`added`, ' . + '`feeds`.`articles_per_update`, `feeds`.`folder_id`, ' . + '`feeds`.`prevent_update`, `feeds`.`deleted_at`'; $this->setMapperResult($sql, [$urlHash, $this->user], $row); $result = $this->mapper->findByUrlHash($urlHash, $this->user); @@ -211,11 +216,14 @@ class FeedMapperTest extends \Test\AppFramework\Db\MapperTestUtility { 'AND `feeds`.`user_id` = ? ' . 'GROUP BY `feeds`.`id`, `feeds`.`user_id`, `feeds`.`url_hash`,'. '`feeds`.`url`, `feeds`.`title`, `feeds`.`link`,'. - '`feeds`.`favicon_link`, `feeds`.`added`, `feeds`.`articles_per_update`,'. - '`feeds`.`folder_id`, `feeds`.`prevent_update`, `feeds`.`deleted_at`'; + '`feeds`.`favicon_link`, `feeds`.`added`, ' . + '`feeds`.`articles_per_update`, `feeds`.`folder_id`, ' . + '`feeds`.`prevent_update`, `feeds`.`deleted_at`'; $this->setMapperResult($sql, [$urlHash, $this->user]); - $this->setExpectedException('\OCP\AppFramework\Db\DoesNotExistException'); + $this->setExpectedException( + '\OCP\AppFramework\Db\DoesNotExistException' + ); $this->mapper->findByUrlHash($urlHash, $this->user); } @@ -236,11 +244,14 @@ class FeedMapperTest extends \Test\AppFramework\Db\MapperTestUtility { 'AND `feeds`.`user_id` = ? ' . 'GROUP BY `feeds`.`id`, `feeds`.`user_id`, `feeds`.`url_hash`,'. '`feeds`.`url`, `feeds`.`title`, `feeds`.`link`,'. - '`feeds`.`favicon_link`, `feeds`.`added`, `feeds`.`articles_per_update`,'. - '`feeds`.`folder_id`, `feeds`.`prevent_update`, `feeds`.`deleted_at`'; + '`feeds`.`favicon_link`, `feeds`.`added`, ' . + '`feeds`.`articles_per_update`, `feeds`.`folder_id`, ' . + '`feeds`.`prevent_update`, `feeds`.`deleted_at`'; $this->setMapperResult($sql, [$urlHash, $this->user], $rows); - $this->setExpectedException('\OCP\AppFramework\Db\MultipleObjectsReturnedException'); + $this->setExpectedException( + '\OCP\AppFramework\Db\MultipleObjectsReturnedException' + ); $this->mapper->findByUrlHash($urlHash, $this->user); } diff --git a/tests/unit/db/FolderMapperTest.php b/tests/unit/db/FolderMapperTest.php index 1078d205f..87f9e617c 100644 --- a/tests/unit/db/FolderMapperTest.php +++ b/tests/unit/db/FolderMapperTest.php @@ -63,7 +63,9 @@ class FolderMapperTest extends \Test\AppFramework\Db\MapperTestUtility { $this->setMapperResult($sql, [$id, $userId]); - $this->setExpectedException('\OCP\AppFramework\Db\DoesNotExistException'); + $this->setExpectedException( + '\OCP\AppFramework\Db\DoesNotExistException' + ); $this->folderMapper->find($id, $userId); } @@ -78,7 +80,9 @@ class FolderMapperTest extends \Test\AppFramework\Db\MapperTestUtility { $this->setMapperResult($sql, [$id, $userId], $rows); - $this->setExpectedException('\OCP\AppFramework\Db\MultipleObjectsReturnedException'); + $this->setExpectedException( + '\OCP\AppFramework\Db\MultipleObjectsReturnedException' + ); $this->folderMapper->find($id, $userId); } @@ -156,7 +160,9 @@ class FolderMapperTest extends \Test\AppFramework\Db\MapperTestUtility { 'AND `deleted_at` < ? ' . 'AND `user_id` = ?'; $this->setMapperResult($sql, [$deleteOlderThan, $this->user], $rows); - $result = $this->folderMapper->getToDelete($deleteOlderThan, $this->user); + $result = $this->folderMapper->getToDelete( + $deleteOlderThan, $this->user + ); $this->assertEquals($this->folders, $result); } diff --git a/tests/unit/db/ItemMapperTest.php b/tests/unit/db/ItemMapperTest.php index 46ab2165a..2f6b68c1c 100644 --- a/tests/unit/db/ItemMapperTest.php +++ b/tests/unit/db/ItemMapperTest.php @@ -35,23 +35,23 @@ class ItemMapperTest extends \Test\AppFramework\Db\MapperTestUtility { $item1 = new Item(); $item2 = new Item(); - $this->items = array( + $this->items = [ $item1, $item2 - ); + ]; $this->userId = 'john'; $this->id = 3; $this->folderId = 2; - $this->row = array( - array('id' => $this->items[0]->getId()), - ); + $this->row = [ + ['id' => $this->items[0]->getId()], + ]; - $this->rows = array( - array('id' => $this->items[0]->getId()), - array('id' => $this->items[1]->getId()) - ); + $this->rows = [ + ['id' => $this->items[0]->getId()], + ['id' => $this->items[1]->getId()] + ]; $this->user = 'john'; $this->limit = 10; @@ -98,7 +98,9 @@ class ItemMapperTest extends \Test\AppFramework\Db\MapperTestUtility { public function testFind(){ $sql = $this->makeSelectQuery('AND `items`.`id` = ? '); - $this->setMapperResult($sql, array($this->userId, $this->id), $this->row); + $this->setMapperResult( + $sql, [$this->userId, $this->id], $this->row + ); $result = $this->mapper->find($this->id, $this->userId); $this->assertEquals($this->items[0], $result); @@ -107,9 +109,7 @@ class ItemMapperTest extends \Test\AppFramework\Db\MapperTestUtility { public function testGetStarredCount(){ $userId = 'john'; - $row = array( - array('size' => 9) - ); + $row = [['size' => 9]]; $sql = 'SELECT COUNT(*) AS size FROM `*PREFIX*news_items` `items` '. 'JOIN `*PREFIX*news_feeds` `feeds` ' . 'ON `feeds`.`id` = `items`.`feed_id` '. @@ -122,7 +122,7 @@ class ItemMapperTest extends \Test\AppFramework\Db\MapperTestUtility { 'WHERE `feeds`.`folder_id` = 0 ' . 'OR `folders`.`deleted_at` = 0'; - $this->setMapperResult($sql, array($userId), $row); + $this->setMapperResult($sql, [$userId], $row); $result = $this->mapper->starredCount($userId); $this->assertEquals($row[0]['size'], $result); @@ -138,7 +138,7 @@ class ItemMapperTest extends \Test\AppFramework\Db\MapperTestUtility { 'WHERE `user_id` = ? ' . ') '. 'AND `id` <= ?'; - $params = array(~StatusFlag::UNREAD, $this->updatedSince, $this->user, 3); + $params = [~StatusFlag::UNREAD, $this->updatedSince, $this->user, 3]; $this->setMapperResult($sql, $params); $this->mapper->readAll(3, $this->updatedSince, $this->user); } @@ -154,7 +154,7 @@ class ItemMapperTest extends \Test\AppFramework\Db\MapperTestUtility { 'AND `user_id` = ? ' . ') '. 'AND `id` <= ?'; - $params = array(~StatusFlag::UNREAD, $this->updatedSince, 3, $this->user, 6); + $params = [~StatusFlag::UNREAD, $this->updatedSince, 3, $this->user, 6]; $this->setMapperResult($sql, $params); $this->mapper->readFolder(3, 6, $this->updatedSince, $this->user); } @@ -170,8 +170,9 @@ class ItemMapperTest extends \Test\AppFramework\Db\MapperTestUtility { 'SELECT * FROM `*PREFIX*news_feeds` ' . 'WHERE `user_id` = ? ' . 'AND `id` = ? ) '; - $params = array(~StatusFlag::UNREAD, $this->updatedSince, 3, 6, - $this->user, 3); + $params = [ + ~StatusFlag::UNREAD, $this->updatedSince, 3, 6, $this->user, 3 + ]; $this->setMapperResult($sql, $params); $this->mapper->readFeed(3, 6, $this->updatedSince, $this->user); } @@ -180,7 +181,7 @@ class ItemMapperTest extends \Test\AppFramework\Db\MapperTestUtility { public function testFindAllNew(){ $sql = 'AND `items`.`last_modified` >= ? '; $sql = $this->makeSelectQueryStatus($sql, $this->status); - $params = array($this->user, $this->updatedSince); + $params = [$this->user, $this->updatedSince]; $this->setMapperResult($sql, $params, $this->rows); $result = $this->mapper->findAllNew($this->updatedSince, @@ -195,10 +196,10 @@ class ItemMapperTest extends \Test\AppFramework\Db\MapperTestUtility { 'AND `items`.`last_modified` >= ? '; $sql = $this->makeSelectQueryStatus($sql, $this->status); - $params = array($this->user, $this->id, $this->updatedSince); + $params = [$this->user, $this->id, $this->updatedSince]; $this->setMapperResult($sql, $params, $this->rows); - $result = $this->mapper->findAllNewFolder($this->id, $this->updatedSince, - $this->status, $this->user); + $result = $this->mapper->findAllNewFolder($this->id, + $this->updatedSince, $this->status, $this->user); $this->assertEquals($this->items, $result); } @@ -208,7 +209,7 @@ class ItemMapperTest extends \Test\AppFramework\Db\MapperTestUtility { $sql = 'AND `items`.`feed_id` = ? ' . 'AND `items`.`last_modified` >= ? '; $sql = $this->makeSelectQueryStatus($sql, $this->status); - $params = array($this->user, $this->id, $this->updatedSince); + $params = [$this->user, $this->id, $this->updatedSince]; $this->setMapperResult($sql, $params, $this->rows); $result = $this->mapper->findAllNewFeed($this->id, $this->updatedSince, @@ -222,7 +223,7 @@ class ItemMapperTest extends \Test\AppFramework\Db\MapperTestUtility { $status = StatusFlag::UNREAD | StatusFlag::STARRED; $sql = 'AND ((`items`.`status` & ' . $status . ') > 0) '; $sql = $this->makeSelectQuery($sql); - $params = array($this->user); + $params = [$this->user]; $this->setMapperResult($sql, $params, $this->rows); $result = $this->mapper->findAllUnreadOrStarred($this->user); @@ -234,7 +235,7 @@ class ItemMapperTest extends \Test\AppFramework\Db\MapperTestUtility { $sql = 'AND `items`.`feed_id` = ? ' . 'AND `items`.`id` < ? '; $sql = $this->makeSelectQueryStatus($sql, $this->status); - $params = array($this->user, $this->id, $this->offset); + $params = [$this->user, $this->id, $this->offset]; $this->setMapperResult($sql, $params, $this->rows); $result = $this->mapper->findAllFeed($this->id, $this->limit, $this->offset, $this->status, false, $this->user); @@ -247,7 +248,7 @@ class ItemMapperTest extends \Test\AppFramework\Db\MapperTestUtility { $sql = 'AND `items`.`feed_id` = ? ' . 'AND `items`.`id` > ? '; $sql = $this->makeSelectQueryStatus($sql, $this->status, true); - $params = array($this->user, $this->id, $this->offset); + $params = [$this->user, $this->id, $this->offset]; $this->setMapperResult($sql, $params, $this->rows); $result = $this->mapper->findAllFeed($this->id, $this->limit, $this->offset, $this->status, true, $this->user); @@ -259,7 +260,7 @@ class ItemMapperTest extends \Test\AppFramework\Db\MapperTestUtility { public function testFindAllFeedOffsetZero(){ $sql = 'AND `items`.`feed_id` = ? '; $sql = $this->makeSelectQueryStatus($sql, $this->status); - $params = array($this->user, $this->id); + $params = [$this->user, $this->id]; $this->setMapperResult($sql, $params, $this->rows); $result = $this->mapper->findAllFeed($this->id, $this->limit, 0, $this->status, false, $this->user); @@ -272,8 +273,7 @@ class ItemMapperTest extends \Test\AppFramework\Db\MapperTestUtility { $sql = 'AND `feeds`.`folder_id` = ? ' . 'AND `items`.`id` < ? '; $sql = $this->makeSelectQueryStatus($sql, $this->status); - $params = array($this->user, $this->id, - $this->offset); + $params = [$this->user, $this->id, $this->offset]; $this->setMapperResult($sql, $params, $this->rows); $result = $this->mapper->findAllFolder($this->id, $this->limit, $this->offset, $this->status, false, $this->user); @@ -286,8 +286,7 @@ class ItemMapperTest extends \Test\AppFramework\Db\MapperTestUtility { $sql = 'AND `feeds`.`folder_id` = ? ' . 'AND `items`.`id` > ? '; $sql = $this->makeSelectQueryStatus($sql, $this->status, true); - $params = array($this->user, $this->id, - $this->offset); + $params = [$this->user, $this->id, $this->offset]; $this->setMapperResult($sql, $params, $this->rows); $result = $this->mapper->findAllFolder($this->id, $this->limit, $this->offset, $this->status, true, $this->user); @@ -299,7 +298,7 @@ class ItemMapperTest extends \Test\AppFramework\Db\MapperTestUtility { public function testFindAllFolderOffsetZero(){ $sql = 'AND `feeds`.`folder_id` = ? '; $sql = $this->makeSelectQueryStatus($sql, $this->status); - $params = array($this->user, $this->id); + $params = [$this->user, $this->id]; $this->setMapperResult($sql, $params, $this->rows); $result = $this->mapper->findAllFolder($this->id, $this->limit, 0, $this->status, false, $this->user); @@ -311,7 +310,7 @@ class ItemMapperTest extends \Test\AppFramework\Db\MapperTestUtility { public function testFindAll(){ $sql = 'AND `items`.`id` < ? '; $sql = $this->makeSelectQueryStatus($sql, $this->status); - $params = array($this->user, $this->offset); + $params = [$this->user, $this->offset]; $this->setMapperResult($sql, $params, $this->rows); $result = $this->mapper->findAll($this->limit, $this->offset, $this->status, false, $this->user); @@ -323,7 +322,7 @@ class ItemMapperTest extends \Test\AppFramework\Db\MapperTestUtility { public function testFindAllOldestFirst(){ $sql = 'AND `items`.`id` > ? '; $sql = $this->makeSelectQueryStatus($sql, $this->status, true); - $params = array($this->user, $this->offset); + $params = [$this->user, $this->offset]; $this->setMapperResult($sql, $params, $this->rows); $result = $this->mapper->findAll($this->limit, $this->offset, $this->status, true, $this->user); @@ -334,7 +333,7 @@ class ItemMapperTest extends \Test\AppFramework\Db\MapperTestUtility { public function testFindAllOffsetZero(){ $sql = $this->makeSelectQueryStatus('', $this->status); - $params = array($this->user); + $params = [$this->user]; $this->setMapperResult($sql, $params, $this->rows); $result = $this->mapper->findAll($this->limit, 0, $this->status, false, $this->user); @@ -352,14 +351,15 @@ class ItemMapperTest extends \Test\AppFramework\Db\MapperTestUtility { 'AND `items`.`guid_hash` = ? ' . 'AND `feeds`.`id` = ? '); - $this->setMapperResult($sql, array($this->userId, $hash, $feedId), $this->row); + $this->setMapperResult( + $sql, [$this->userId, $hash, $feedId], $this->row); $result = $this->mapper->findByGuidHash($hash, $feedId, $this->userId); $this->assertEquals($this->items[0], $result); } - public function testDeleteReadOlderThanThresholdDoesNotDeleteBelowThreshold(){ + public function testDeleteReadOlderThanThresholdDoesNotDelete(){ $status = StatusFlag::STARRED | StatusFlag::UNREAD; $sql = 'SELECT COUNT(*) - `feeds`.`articles_per_update` AS `size`, ' . '`items`.`feed_id` AS `feed_id` ' . @@ -371,8 +371,8 @@ class ItemMapperTest extends \Test\AppFramework\Db\MapperTestUtility { 'HAVING COUNT(*) > ?'; $threshold = 10; - $rows = array(array('feed_id' => 30, 'size' => 9)); - $params = array($status, $threshold); + $rows = [['feed_id' => 30, 'size' => 9]]; + $params = [$status, $threshold]; $this->setMapperResult($sql, $params, $rows); $this->mapper->deleteReadOlderThanThreshold($threshold); @@ -393,18 +393,18 @@ class ItemMapperTest extends \Test\AppFramework\Db\MapperTestUtility { 'WHERE NOT ((`items`.`status` & ?) > 0) ' . 'GROUP BY `items`.`feed_id`, `feeds`.`articles_per_update` ' . 'HAVING COUNT(*) > ?'; - $params1 = array($status, $threshold); + $params1 = [$status, $threshold]; - $row = array('feed_id' => 30, 'size' => 11); + $row = ['feed_id' => 30, 'size' => 11]; $sql2 = 'DELETE FROM `*PREFIX*news_items` ' . 'WHERE NOT ((`status` & ?) > 0) ' . 'AND `feed_id` = ? ' . 'ORDER BY `id` ASC'; - $params2 = array($status, 30); + $params2 = [$status, 30]; - $this->setMapperResult($sql1, $params1, array($row)); + $this->setMapperResult($sql1, $params1, [$row]); $this->setMapperResult($sql2, $params2); $this->mapper->deleteReadOlderThanThreshold($threshold); @@ -412,12 +412,13 @@ class ItemMapperTest extends \Test\AppFramework\Db\MapperTestUtility { public function testGetNewestItem() { - $sql = 'SELECT MAX(`items`.`id`) AS `max_id` FROM `*PREFIX*news_items` `items` '. + $sql = 'SELECT MAX(`items`.`id`) AS `max_id` ' . + 'FROM `*PREFIX*news_items` `items` '. 'JOIN `*PREFIX*news_feeds` `feeds` ' . 'ON `feeds`.`id` = `items`.`feed_id` '. 'AND `feeds`.`user_id` = ?'; - $params = array($this->user); - $rows = array(array('max_id' => 3)); + $params = [$this->user]; + $rows = [['max_id' => 3]]; $this->setMapperResult($sql, $params, $rows); @@ -427,15 +428,18 @@ class ItemMapperTest extends \Test\AppFramework\Db\MapperTestUtility { public function testGetNewestItemIdNotFound() { - $sql = 'SELECT MAX(`items`.`id`) AS `max_id` FROM `*PREFIX*news_items` `items` '. + $sql = 'SELECT MAX(`items`.`id`) AS `max_id` ' . + 'FROM `*PREFIX*news_items` `items` '. 'JOIN `*PREFIX*news_feeds` `feeds` ' . 'ON `feeds`.`id` = `items`.`feed_id` '. 'AND `feeds`.`user_id` = ?'; - $params = array($this->user); - $rows = array(); + $params = [$this->user]; + $rows = []; $this->setMapperResult($sql, $params, $rows); - $this->setExpectedException('\OCP\AppFramework\Db\DoesNotExistException'); + $this->setExpectedException( + '\OCP\AppFramework\Db\DoesNotExistException' + ); $this->mapper->getNewestItemId($this->user); } @@ -449,7 +453,7 @@ class ItemMapperTest extends \Test\AppFramework\Db\MapperTestUtility { 'WHERE `feeds`.`user_id` = ?' . ')'; - $this->setMapperResult($sql, array($userId)); + $this->setMapperResult($sql, [$userId]); $this->mapper->deleteUser($userId); } diff --git a/tests/unit/db/MapperFactoryTest.php b/tests/unit/db/MapperFactoryTest.php index 3ebc0ce17..b5aa76dc0 100644 --- a/tests/unit/db/MapperFactoryTest.php +++ b/tests/unit/db/MapperFactoryTest.php @@ -43,7 +43,8 @@ class MapperFactoryTest extends \PHPUnit_Framework_TestCase { public function testGetItemMapperPostgres() { $factory = new MapperFactory('pgsql', $this->db); - $this->assertTrue($factory->getItemMapper() instanceof \OCA\News\Db\Postgres\ItemMapper); + $this->assertTrue($factory->getItemMapper() + instanceof \OCA\News\Db\Postgres\ItemMapper); } diff --git a/tests/unit/db/postgres/ItemMapperTest.php b/tests/unit/db/postgres/ItemMapperTest.php index 04550695d..473641522 100644 --- a/tests/unit/db/postgres/ItemMapperTest.php +++ b/tests/unit/db/postgres/ItemMapperTest.php @@ -62,7 +62,7 @@ class ItemMapperTest extends \Test\AppFramework\Db\MapperTestUtility { } - public function testDeleteReadOlderThanThresholdDoesNotDeleteBelowThreshold(){ + public function testDeleteReadOlderThanThresholdDoesntDelete(){ $status = StatusFlag::STARRED | StatusFlag::UNREAD; $sql = 'SELECT COUNT(*) - `feeds`.`articles_per_update` AS `size`, ' . '`items`.`feed_id` AS `feed_id` ' . |