diff options
author | Bernhard Posselt <dev@bernhard-posselt.com> | 2014-05-14 17:32:49 +0200 |
---|---|---|
committer | Bernhard Posselt <dev@bernhard-posselt.com> | 2014-05-14 17:32:49 +0200 |
commit | 160a0dfebaeb21cc75d7166dfbac6d0ef1a51460 (patch) | |
tree | 28e2555c97462d60356ef933d5c71c5326649747 /tests/unit/db | |
parent | acc2df1251a1c1b9ec5ede13bdf46d516dc64b0d (diff) |
convert array() to []
Diffstat (limited to 'tests/unit/db')
-rw-r--r-- | tests/unit/db/FeedMapperTest.php | 109 | ||||
-rw-r--r-- | tests/unit/db/FeedTest.php | 4 | ||||
-rw-r--r-- | tests/unit/db/FolderMapperTest.php | 65 | ||||
-rw-r--r-- | tests/unit/db/FolderTest.php | 4 | ||||
-rw-r--r-- | tests/unit/db/ItemMapperTest.php | 79 | ||||
-rw-r--r-- | tests/unit/db/ItemTest.php | 16 | ||||
-rw-r--r-- | tests/unit/db/postgres/ItemMapperTest.php | 29 |
7 files changed, 131 insertions, 175 deletions
diff --git a/tests/unit/db/FeedMapperTest.php b/tests/unit/db/FeedMapperTest.php index 607255fde..c3b276ba6 100644 --- a/tests/unit/db/FeedMapperTest.php +++ b/tests/unit/db/FeedMapperTest.php @@ -30,10 +30,7 @@ class FeedMapperTest extends \OCP\AppFramework\Db\MapperTestUtility { $feed1 = new Feed(); $feed2 = new Feed(); - $this->feeds = array( - $feed1, - $feed2 - ); + $this->feeds = [$feed1, $feed2]; $this->user = 'herman'; } @@ -41,9 +38,9 @@ class FeedMapperTest extends \OCP\AppFramework\Db\MapperTestUtility { public function testFind(){ $userId = 'john'; $id = 3; - $rows = array( - array('id' => $this->feeds[0]->getId()), - ); + $rows = [ + ['id' => $this->feeds[0]->getId()], + ]; $sql = 'SELECT `feeds`.*, COUNT(`items`.`id`) AS `unread_count` ' . 'FROM `*PREFIX*news_feeds` `feeds` ' . 'LEFT JOIN `*PREFIX*news_items` `items` ' . @@ -56,7 +53,7 @@ class FeedMapperTest extends \OCP\AppFramework\Db\MapperTestUtility { '`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 = array($id, $userId); + $params = [$id, $userId]; $this->setMapperResult($sql, $params, $rows); $result = $this->mapper->find($id, $userId); @@ -80,7 +77,7 @@ class FeedMapperTest extends \OCP\AppFramework\Db\MapperTestUtility { '`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 = array($id, $userId); + $params = [$id, $userId]; $this->setMapperResult($sql, $params); $this->setExpectedException('\OCP\AppFramework\Db\DoesNotExistException'); @@ -91,10 +88,10 @@ class FeedMapperTest extends \OCP\AppFramework\Db\MapperTestUtility { public function testFindMoreThanOneResultFound(){ $userId = 'john'; $id = 3; - $rows = array( - array('id' => $this->feeds[0]->getId()), - array('id' => $this->feeds[1]->getId()) - ); + $rows = [ + ['id' => $this->feeds[0]->getId()], + ['id' => $this->feeds[1]->getId()] + ]; $sql = 'SELECT `feeds`.*, COUNT(`items`.`id`) AS `unread_count` ' . 'FROM `*PREFIX*news_feeds` `feeds` ' . 'LEFT JOIN `*PREFIX*news_items` `items` ' . @@ -107,7 +104,7 @@ class FeedMapperTest extends \OCP\AppFramework\Db\MapperTestUtility { '`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 = array($id, $userId); + $params = [$id, $userId]; $this->setMapperResult($sql, $params, $rows); $this->setExpectedException('\OCP\AppFramework\Db\MultipleObjectsReturnedException'); @@ -116,10 +113,10 @@ class FeedMapperTest extends \OCP\AppFramework\Db\MapperTestUtility { public function testFindAll(){ - $rows = array( - array('id' => $this->feeds[0]->getId()), - array('id' => $this->feeds[1]->getId()) - ); + $rows = [ + ['id' => $this->feeds[0]->getId()], + ['id' => $this->feeds[1]->getId()] + ]; $sql = 'SELECT `feeds`.*, COUNT(`items`.`id`) AS `unread_count` ' . 'FROM `*PREFIX*news_feeds` `feeds` ' . 'LEFT OUTER JOIN `*PREFIX*news_folders` `folders` '. @@ -141,7 +138,7 @@ class FeedMapperTest extends \OCP\AppFramework\Db\MapperTestUtility { '`feeds`.`favicon_link`, `feeds`.`added`, `feeds`.`articles_per_update`,'. '`feeds`.`folder_id`, `feeds`.`prevent_update`, `feeds`.`deleted_at`'; - $this->setMapperResult($sql, array(), $rows); + $this->setMapperResult($sql, [], $rows); $result = $this->mapper->findAll(); $this->assertEquals($this->feeds, $result); @@ -150,10 +147,10 @@ class FeedMapperTest extends \OCP\AppFramework\Db\MapperTestUtility { public function testFindAllFromUser(){ $userId = 'john'; - $rows = array( - array('id' => $this->feeds[0]->getId()), - array('id' => $this->feeds[1]->getId()) - ); + $rows = [ + ['id' => $this->feeds[0]->getId()], + ['id' => $this->feeds[1]->getId()] + ]; $sql = 'SELECT `feeds`.*, COUNT(`items`.`id`) AS `unread_count` ' . 'FROM `*PREFIX*news_feeds` `feeds` ' . 'LEFT OUTER JOIN `*PREFIX*news_folders` `folders` '. @@ -175,8 +172,7 @@ class FeedMapperTest extends \OCP\AppFramework\Db\MapperTestUtility { '`feeds`.`url`, `feeds`.`title`, `feeds`.`link`,'. '`feeds`.`favicon_link`, `feeds`.`added`, `feeds`.`articles_per_update`,'. '`feeds`.`folder_id`, `feeds`.`prevent_update`, `feeds`.`deleted_at`'; - $this->setMapperResult($sql, - array($userId), $rows); + $this->setMapperResult($sql, [$userId], $rows); $result = $this->mapper->findAllFromUser($userId); $this->assertEquals($this->feeds, $result); @@ -185,9 +181,7 @@ class FeedMapperTest extends \OCP\AppFramework\Db\MapperTestUtility { public function testFindByUrlHash(){ $urlHash = md5('hihi'); - $row = array( - array('id' => $this->feeds[0]->getId()), - ); + $row = [['id' => $this->feeds[0]->getId()]]; $sql = 'SELECT `feeds`.*, COUNT(`items`.`id`) AS `unread_count` ' . 'FROM `*PREFIX*news_feeds` `feeds` ' . 'LEFT JOIN `*PREFIX*news_items` `items` ' . @@ -200,8 +194,7 @@ class FeedMapperTest extends \OCP\AppFramework\Db\MapperTestUtility { '`feeds`.`url`, `feeds`.`title`, `feeds`.`link`,'. '`feeds`.`favicon_link`, `feeds`.`added`, `feeds`.`articles_per_update`,'. '`feeds`.`folder_id`, `feeds`.`prevent_update`, `feeds`.`deleted_at`'; - $this->setMapperResult($sql, - array($urlHash, $this->user), $row); + $this->setMapperResult($sql, [$urlHash, $this->user], $row); $result = $this->mapper->findByUrlHash($urlHash, $this->user); $this->assertEquals($this->feeds[0], $result); @@ -222,8 +215,7 @@ class FeedMapperTest extends \OCP\AppFramework\Db\MapperTestUtility { '`feeds`.`url`, `feeds`.`title`, `feeds`.`link`,'. '`feeds`.`favicon_link`, `feeds`.`added`, `feeds`.`articles_per_update`,'. '`feeds`.`folder_id`, `feeds`.`prevent_update`, `feeds`.`deleted_at`'; - $this->setMapperResult($sql, - array($urlHash, $this->user)); + $this->setMapperResult($sql, [$urlHash, $this->user]); $this->setExpectedException('\OCP\AppFramework\Db\DoesNotExistException'); $this->mapper->findByUrlHash($urlHash, $this->user); @@ -232,10 +224,10 @@ class FeedMapperTest extends \OCP\AppFramework\Db\MapperTestUtility { public function testFindByUrlHashMoreThanOneResultFound(){ $urlHash = md5('hihi'); - $rows = array( - array('id' => $this->feeds[0]->getId()), - array('id' => $this->feeds[1]->getId()) - ); + $rows = [ + ['id' => $this->feeds[0]->getId()], + ['id' => $this->feeds[1]->getId()] + ]; $sql = 'SELECT `feeds`.*, COUNT(`items`.`id`) AS `unread_count` ' . 'FROM `*PREFIX*news_feeds` `feeds` ' . 'LEFT JOIN `*PREFIX*news_items` `items` ' . @@ -248,8 +240,7 @@ class FeedMapperTest extends \OCP\AppFramework\Db\MapperTestUtility { '`feeds`.`url`, `feeds`.`title`, `feeds`.`link`,'. '`feeds`.`favicon_link`, `feeds`.`added`, `feeds`.`articles_per_update`,'. '`feeds`.`folder_id`, `feeds`.`prevent_update`, `feeds`.`deleted_at`'; - $this->setMapperResult($sql, - array($urlHash, $this->user), $rows); + $this->setMapperResult($sql, [$urlHash, $this->user], $rows); $this->setExpectedException('\OCP\AppFramework\Db\MultipleObjectsReturnedException'); $this->mapper->findByUrlHash($urlHash, $this->user); @@ -261,15 +252,13 @@ class FeedMapperTest extends \OCP\AppFramework\Db\MapperTestUtility { $feed->setId(3); $sql = 'DELETE FROM `*PREFIX*news_feeds` WHERE `id` = ?'; - $arguments = array($feed->getId()); + $arguments = [$feed->getId()]; $sql2 = 'DELETE FROM `*PREFIX*news_items` WHERE `feed_id` = ?'; - $arguments2 = array($feed->getId()); + $arguments2 = [$feed->getId()]; - $pdoResult = $this->getMock('Result', - array('fetchRow')); - $pdoResult->expects($this->any()) - ->method('fetchRow'); + $pdoResult = $this->getMock('Result', ['fetch']); + $pdoResult->expects($this->any())->method('fetch'); $this->setMapperResult($sql, $arguments); $this->setMapperResult($sql2, $arguments2); @@ -280,15 +269,15 @@ class FeedMapperTest extends \OCP\AppFramework\Db\MapperTestUtility { public function testGetPurgeDeleted(){ - $rows = array( - array('id' => $this->feeds[0]->getId()), - array('id' => $this->feeds[1]->getId()) - ); + $rows = [ + ['id' => $this->feeds[0]->getId()], + ['id' => $this->feeds[1]->getId()] + ]; $deleteOlderThan = 110; $sql = 'SELECT * FROM `*PREFIX*news_feeds` ' . 'WHERE `deleted_at` > 0 ' . 'AND `deleted_at` < ? '; - $this->setMapperResult($sql, array($deleteOlderThan), $rows); + $this->setMapperResult($sql, [$deleteOlderThan], $rows); $result = $this->mapper->getToDelete($deleteOlderThan); $this->assertEquals($this->feeds, $result); @@ -296,16 +285,16 @@ class FeedMapperTest extends \OCP\AppFramework\Db\MapperTestUtility { public function testGetPurgeDeletedFromUser(){ - $rows = array( - array('id' => $this->feeds[0]->getId()), - array('id' => $this->feeds[1]->getId()) - ); + $rows = [ + ['id' => $this->feeds[0]->getId()], + ['id' => $this->feeds[1]->getId()] + ]; $deleteOlderThan = 110; $sql = 'SELECT * FROM `*PREFIX*news_feeds` ' . 'WHERE `deleted_at` > 0 ' . 'AND `deleted_at` < ? ' . 'AND `user_id` = ?'; - $this->setMapperResult($sql, array($deleteOlderThan, $this->user), $rows); + $this->setMapperResult($sql, [$deleteOlderThan, $this->user], $rows); $result = $this->mapper->getToDelete($deleteOlderThan, $this->user); $this->assertEquals($this->feeds, $result); @@ -313,15 +302,15 @@ class FeedMapperTest extends \OCP\AppFramework\Db\MapperTestUtility { public function testGetAllPurgeDeletedFromUser(){ - $rows = array( - array('id' => $this->feeds[0]->getId()), - array('id' => $this->feeds[1]->getId()) - ); + $rows = [ + ['id' => $this->feeds[0]->getId()], + ['id' => $this->feeds[1]->getId()] + ]; $sql = 'SELECT * FROM `*PREFIX*news_feeds` ' . 'WHERE `deleted_at` > 0 ' . 'AND `user_id` = ?'; - $this->setMapperResult($sql, array($this->user), $rows); + $this->setMapperResult($sql, [$this->user], $rows); $result = $this->mapper->getToDelete(null, $this->user); $this->assertEquals($this->feeds, $result); @@ -332,7 +321,7 @@ class FeedMapperTest extends \OCP\AppFramework\Db\MapperTestUtility { $userId = 'john'; $sql = 'DELETE FROM `*PREFIX*news_feeds` WHERE `user_id` = ?'; - $this->setMapperResult($sql, array($userId)); + $this->setMapperResult($sql, [$userId]); $this->mapper->deleteUser($userId); } diff --git a/tests/unit/db/FeedTest.php b/tests/unit/db/FeedTest.php index 8e627c753..6ebe27732 100644 --- a/tests/unit/db/FeedTest.php +++ b/tests/unit/db/FeedTest.php @@ -30,7 +30,7 @@ class FeedTest extends \PHPUnit_Framework_TestCase { $feed->setUnreadCount(321); $feed->setLink('https://google'); - $this->assertEquals(array( + $this->assertEquals([ 'id' => 3, 'url' => 'http://google', 'title' => 'title', @@ -39,7 +39,7 @@ class FeedTest extends \PHPUnit_Framework_TestCase { 'folderId' => 1, 'unreadCount' => 321, 'link' => 'https://google' - ), $feed->toAPI()); + ], $feed->toAPI()); } diff --git a/tests/unit/db/FolderMapperTest.php b/tests/unit/db/FolderMapperTest.php index 359d63894..192b303c9 100644 --- a/tests/unit/db/FolderMapperTest.php +++ b/tests/unit/db/FolderMapperTest.php @@ -31,25 +31,24 @@ class FolderMapperTest extends \OCP\AppFramework\Db\MapperTestUtility { $folder1 = new Folder(); $folder2 = new Folder(); - $this->folders = array( - $folder1, - $folder2 - ); + $this->folders = [$folder1, $folder2]; $this->user = 'hh'; + $this->twoRows = [ + ['id' => $this->folders[0]->getId()], + ['id' => $this->folders[1]->getId()] + ]; } public function testFind(){ $userId = 'john'; $id = 3; - $rows = array( - array('id' => $this->folders[0]->getId()), - ); + $rows = [['id' => $this->folders[0]->getId()]]; $sql = 'SELECT * FROM `*PREFIX*news_folders` ' . 'WHERE `id` = ? ' . 'AND `user_id` = ?'; - $this->setMapperResult($sql, array($id, $userId), $rows); + $this->setMapperResult($sql, [$id, $userId], $rows); $result = $this->folderMapper->find($id, $userId); $this->assertEquals($this->folders[0], $result); @@ -64,7 +63,7 @@ class FolderMapperTest extends \OCP\AppFramework\Db\MapperTestUtility { 'WHERE `id` = ? ' . 'AND `user_id` = ?'; - $this->setMapperResult($sql, array($id, $userId)); + $this->setMapperResult($sql, [$id, $userId]); $this->setExpectedException('\OCP\AppFramework\Db\DoesNotExistException'); $this->folderMapper->find($id, $userId); @@ -74,15 +73,12 @@ class FolderMapperTest extends \OCP\AppFramework\Db\MapperTestUtility { public function testFindMoreThanOneResultFound(){ $userId = 'john'; $id = 3; - $rows = array( - array('id' => $this->folders[0]->getId()), - array('id' => $this->folders[1]->getId()) - ); + $rows = $this->twoRows; $sql = 'SELECT * FROM `*PREFIX*news_folders` ' . 'WHERE `id` = ? ' . 'AND `user_id` = ?'; - $this->setMapperResult($sql, array($id, $userId), $rows); + $this->setMapperResult($sql, [$id, $userId], $rows); $this->setExpectedException('\OCP\AppFramework\Db\MultipleObjectsReturnedException'); $this->folderMapper->find($id, $userId); @@ -92,15 +88,12 @@ class FolderMapperTest extends \OCP\AppFramework\Db\MapperTestUtility { public function testFindAllFromUser(){ $userId = 'john'; - $rows = array( - array('id' => $this->folders[0]->getId()), - array('id' => $this->folders[1]->getId()) - ); + $rows = $this->twoRows; $sql = 'SELECT * FROM `*PREFIX*news_folders` ' . 'WHERE `user_id` = ? ' . 'AND `deleted_at` = 0'; - $this->setMapperResult($sql, array($userId), $rows); + $this->setMapperResult($sql, [$userId], $rows); $result = $this->folderMapper->findAllFromUser($userId); $this->assertEquals($this->folders, $result); @@ -110,15 +103,12 @@ class FolderMapperTest extends \OCP\AppFramework\Db\MapperTestUtility { public function testFindByName(){ $folderName = 'heheh'; $userId = 'john'; - $rows = array( - array('id' => $this->folders[0]->getId()), - array('id' => $this->folders[1]->getId()) - ); + $rows = $this->twoRows; $sql = 'SELECT * FROM `*PREFIX*news_folders` ' . 'WHERE `name` = ? ' . 'AND `user_id` = ?'; - $this->setMapperResult($sql, array($folderName, $userId), $rows); + $this->setMapperResult($sql, [$folderName, $userId], $rows); $result = $this->folderMapper->findByName($folderName, $userId); $this->assertEquals($this->folders, $result); @@ -130,13 +120,13 @@ class FolderMapperTest extends \OCP\AppFramework\Db\MapperTestUtility { $folder->setId(3); $sql = 'DELETE FROM `*PREFIX*news_folders` WHERE `id` = ?'; - $arguments = array($folder->getId()); + $arguments = [$folder->getId()]; $sql2 = 'DELETE FROM `*PREFIX*news_feeds` WHERE `folder_id` = ?'; $sql3 = 'DELETE FROM `*PREFIX*news_items` WHERE `feed_id` NOT IN '. '(SELECT `feeds`.`id` FROM `*PREFIX*news_feeds` `feeds`)'; - $arguments2 = array($folder->getId()); + $arguments2 = [$folder->getId()]; $this->setMapperResult($sql, $arguments); $this->setMapperResult($sql2, $arguments2); @@ -147,15 +137,12 @@ class FolderMapperTest extends \OCP\AppFramework\Db\MapperTestUtility { public function testGetPurgeDeleted(){ - $rows = array( - array('id' => $this->folders[0]->getId()), - array('id' => $this->folders[1]->getId()) - ); + $rows = $this->twoRows; $deleteOlderThan = 110; $sql = 'SELECT * FROM `*PREFIX*news_folders` ' . 'WHERE `deleted_at` > 0 ' . 'AND `deleted_at` < ? '; - $this->setMapperResult($sql, array($deleteOlderThan), $rows); + $this->setMapperResult($sql, [$deleteOlderThan], $rows); $result = $this->folderMapper->getToDelete($deleteOlderThan); $this->assertEquals($this->folders, $result); @@ -164,16 +151,13 @@ class FolderMapperTest extends \OCP\AppFramework\Db\MapperTestUtility { public function testGetPurgeDeletedUser(){ - $rows = array( - array('id' => $this->folders[0]->getId()), - array('id' => $this->folders[1]->getId()) - ); + $rows = $this->twoRows; $deleteOlderThan = 110; $sql = 'SELECT * FROM `*PREFIX*news_folders` ' . 'WHERE `deleted_at` > 0 ' . 'AND `deleted_at` < ? ' . 'AND `user_id` = ?'; - $this->setMapperResult($sql, array($deleteOlderThan, $this->user), $rows); + $this->setMapperResult($sql, [$deleteOlderThan, $this->user], $rows); $result = $this->folderMapper->getToDelete($deleteOlderThan, $this->user); $this->assertEquals($this->folders, $result); @@ -181,15 +165,12 @@ class FolderMapperTest extends \OCP\AppFramework\Db\MapperTestUtility { public function testGetAllPurgeDeletedUser(){ - $rows = array( - array('id' => $this->folders[0]->getId()), - array('id' => $this->folders[1]->getId()) - ); + $rows = $this->twoRows; $sql = 'SELECT * FROM `*PREFIX*news_folders` ' . 'WHERE `deleted_at` > 0 ' . 'AND `user_id` = ?'; - $this->setMapperResult($sql, array($this->user), $rows); + $this->setMapperResult($sql, [$this->user], $rows); $result = $this->folderMapper->getToDelete(null, $this->user); $this->assertEquals($this->folders, $result); @@ -200,7 +181,7 @@ class FolderMapperTest extends \OCP\AppFramework\Db\MapperTestUtility { $userId = 'john'; $sql = 'DELETE FROM `*PREFIX*news_folders` WHERE `user_id` = ?'; - $this->setMapperResult($sql, array($userId)); + $this->setMapperResult($sql, [$userId]); $this->folderMapper->deleteUser($userId); } diff --git a/tests/unit/db/FolderTest.php b/tests/unit/db/FolderTest.php index 9c59cdeec..e2726e556 100644 --- a/tests/unit/db/FolderTest.php +++ b/tests/unit/db/FolderTest.php @@ -24,10 +24,10 @@ class FolderTest extends \PHPUnit_Framework_TestCase { $folder->setId(3); $folder->setName('name'); - $this->assertEquals(array( + $this->assertEquals([ 'id' => 3, 'name' => 'name' - ), $folder->toAPI()); + ], $folder->toAPI()); } }
\ No newline at end of file diff --git a/tests/unit/db/ItemMapperTest.php b/tests/unit/db/ItemMapperTest.php index b0a64a16d..15379f485 100644 --- a/tests/unit/db/ItemMapperTest.php +++ b/tests/unit/db/ItemMapperTest.php @@ -37,23 +37,20 @@ class ItemMapperTest extends \OCP\AppFramework\Db\MapperTestUtility { $item1 = new Item(); $item2 = new Item(); - $this->items = array( - $item1, - $item2 - ); + $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; @@ -93,7 +90,7 @@ class ItemMapperTest extends \OCP\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); @@ -102,9 +99,7 @@ class ItemMapperTest extends \OCP\AppFramework\Db\MapperTestUtility { public function testGetStarredCount(){ $userId = 'john'; - $row = array( - array('size' => 9) - ); + $row = [['size' => 9]]; $sql = 'SELECT COUNT(*) AS size FROM `*PREFIX*news_feeds` `feeds` ' . 'JOIN `*PREFIX*news_items` `items` ' . 'ON `items`.`feed_id` = `feeds`.`id` ' . @@ -112,7 +107,7 @@ class ItemMapperTest extends \OCP\AppFramework\Db\MapperTestUtility { 'WHERE ((`items`.`status` & ' . StatusFlag::STARRED . ') = ' . StatusFlag::STARRED . ')'; - $this->setMapperResult($sql, array($userId), $row); + $this->setMapperResult($sql, [$userId], $row); $result = $this->mapper->starredCount($userId); $this->assertEquals($row[0]['size'], $result); @@ -128,7 +123,7 @@ class ItemMapperTest extends \OCP\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); } @@ -144,7 +139,7 @@ class ItemMapperTest extends \OCP\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); } @@ -160,8 +155,7 @@ class ItemMapperTest extends \OCP\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); } @@ -170,7 +164,7 @@ class ItemMapperTest extends \OCP\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, @@ -185,7 +179,7 @@ class ItemMapperTest extends \OCP\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); @@ -198,7 +192,7 @@ class ItemMapperTest extends \OCP\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, @@ -212,7 +206,7 @@ class ItemMapperTest extends \OCP\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); @@ -224,7 +218,7 @@ class ItemMapperTest extends \OCP\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, $this->user); @@ -236,7 +230,7 @@ class ItemMapperTest extends \OCP\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, $this->user); @@ -249,8 +243,7 @@ class ItemMapperTest extends \OCP\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, $this->user); @@ -262,7 +255,7 @@ class ItemMapperTest extends \OCP\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, $this->user); @@ -274,7 +267,7 @@ class ItemMapperTest extends \OCP\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, $this->user); @@ -285,7 +278,7 @@ class ItemMapperTest extends \OCP\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, $this->user); @@ -303,7 +296,7 @@ class ItemMapperTest extends \OCP\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); @@ -322,8 +315,8 @@ class ItemMapperTest extends \OCP\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); @@ -344,18 +337,18 @@ class ItemMapperTest extends \OCP\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); @@ -367,8 +360,8 @@ class ItemMapperTest extends \OCP\AppFramework\Db\MapperTestUtility { '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); @@ -382,8 +375,8 @@ class ItemMapperTest extends \OCP\AppFramework\Db\MapperTestUtility { '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'); @@ -400,7 +393,7 @@ class ItemMapperTest extends \OCP\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/ItemTest.php b/tests/unit/db/ItemTest.php index 2da81cda0..65fb0cd52 100644 --- a/tests/unit/db/ItemTest.php +++ b/tests/unit/db/ItemTest.php @@ -72,7 +72,7 @@ class ItemTest extends \PHPUnit_Framework_TestCase { $item->setStarred(); $item->setLastModified(321); - $this->assertEquals(array( + $this->assertEquals([ 'id' => 3, 'guid' => 'guid', 'guidHash' => 'hash', @@ -87,7 +87,7 @@ class ItemTest extends \PHPUnit_Framework_TestCase { 'unread' => true, 'starred' => true, 'lastModified' => 321 - ), $item->toAPI()); + ], $item->toAPI()); } @@ -111,11 +111,9 @@ class ItemTest extends \PHPUnit_Framework_TestCase { $feed = new Feed(); $feed->setLink('http://test'); - $feeds = array( - "feed1" => $feed - ); + $feeds = ["feed1" => $feed]; - $this->assertEquals(array( + $this->assertEquals([ 'guid' => 'guid', 'url' => 'https://google', 'title' => 'title', @@ -127,7 +125,7 @@ class ItemTest extends \PHPUnit_Framework_TestCase { 'unread' => false, 'starred' => true, 'feedLink' => 'http://test' - ), $item->toExport($feeds)); + ], $item->toExport($feeds)); } @@ -144,7 +142,7 @@ class ItemTest extends \PHPUnit_Framework_TestCase { $item->setUnread(); |