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/FolderMapperTest.php | |
parent | acc2df1251a1c1b9ec5ede13bdf46d516dc64b0d (diff) |
convert array() to []
Diffstat (limited to 'tests/unit/db/FolderMapperTest.php')
-rw-r--r-- | tests/unit/db/FolderMapperTest.php | 65 |
1 files changed, 23 insertions, 42 deletions
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); } |