diff options
author | Sean Molenaar <SMillerDev@users.noreply.github.com> | 2018-03-27 15:35:06 +0200 |
---|---|---|
committer | Bernhard Posselt <BernhardPosselt@users.noreply.github.com> | 2018-03-27 15:35:06 +0200 |
commit | 5b94705cf3918dc7986c6043b1fbe776bf22958f (patch) | |
tree | 4e8059818a0a913d24938e35238913a721fa6373 /tests | |
parent | f3c9d13551cef5968baea99c2f25085baee0ed5f (diff) |
Core: Fix compatibility with nextcloud codestyle (#280)
Diffstat (limited to 'tests')
45 files changed, 1958 insertions, 1103 deletions
diff --git a/tests/Integration/Db/FeedMapperTest.php b/tests/Integration/Db/FeedMapperTest.php index bcf1cb895..3d1ea71f4 100644 --- a/tests/Integration/Db/FeedMapperTest.php +++ b/tests/Integration/Db/FeedMapperTest.php @@ -5,8 +5,8 @@ * This file is licensed under the Affero General Public License version 3 or * later. See the COPYING file. * - * @author Bernhard Posselt <dev@bernhard-posselt.com> - * @author Daniel Opitz <dev@copynpaste.de> + * @author Bernhard Posselt <dev@bernhard-posselt.com> + * @author Daniel Opitz <dev@copynpaste.de> * @copyright Bernhard Posselt 2015 * @copyright Daniel Opitz 2017 */ @@ -17,9 +17,11 @@ use OCA\News\Db\Feed; use OCA\News\Tests\Integration\IntegrationTest; use OCA\News\Tests\Integration\Fixtures\FeedFixture; -class FeedMapperTest extends IntegrationTest { +class FeedMapperTest extends IntegrationTest +{ - public function testFind () { + public function testFind() + { $feed = new FeedFixture(); $feed = $this->feedMapper->insert($feed); @@ -32,12 +34,14 @@ class FeedMapperTest extends IntegrationTest { /** * @expectedException OCP\AppFramework\Db\DoesNotExistException */ - public function testFindNotExisting () { + public function testFindNotExisting() + { $this->feedMapper->find(0, $this->user); } - public function testFindAll () { + public function testFindAll() + { $feeds = [ [ 'userId' => $this->user, @@ -59,7 +63,8 @@ class FeedMapperTest extends IntegrationTest { $this->tearDownUser('john'); } - public function testFindAllEmpty () { + public function testFindAllEmpty() + { $feeds = $this->feedMapper->findAll(); $this->assertInternalType('array', $feeds); @@ -67,7 +72,8 @@ class FeedMapperTest extends IntegrationTest { } - public function testFindAllFromUser () { + public function testFindAllFromUser() + { $feeds = [ [ 'userId' => $this->user, @@ -90,7 +96,8 @@ class FeedMapperTest extends IntegrationTest { } - public function testFindAllFromUserNotExisting () { + public function testFindAllFromUserNotExisting() + { $fetched = $this->feedMapper->findAllFromUser('notexistinguser'); $this->assertInternalType('array', $fetched); @@ -98,11 +105,14 @@ class FeedMapperTest extends IntegrationTest { } - public function testFindByUrlHash () { - $feed = new FeedFixture([ + public function testFindByUrlHash() + { + $feed = new FeedFixture( + [ 'urlHash' => 'someTestHash', 'title' => 'Some Test Title' - ]); + ] + ); $feed = $this->feedMapper->insert($feed); $fetched = $this->feedMapper->findByUrlHash($feed->getUrlHash(), $this->user); @@ -114,13 +124,22 @@ class FeedMapperTest extends IntegrationTest { /** * @expectedException OCP\AppFramework\Db\MultipleObjectsReturnedException */ - public function testFindByUrlHashMoreThanOneResult () { - $feed1 = $this->feedMapper->insert(new FeedFixture([ - 'urlHash' => 'someTestHash' - ])); - $feed2 = $this->feedMapper->insert(new FeedFixture([ - 'urlHash' => 'someTestHash' - ])); + public function testFindByUrlHashMoreThanOneResult() + { + $feed1 = $this->feedMapper->insert( + new FeedFixture( + [ + 'urlHash' => 'someTestHash' + ] + ) + ); + $feed2 = $this->feedMapper->insert( + new FeedFixture( + [ + 'urlHash' => 'someTestHash' + ] + ) + ); $this->feedMapper->findByUrlHash($feed1->getUrlHash(), $this->user); } @@ -129,12 +148,14 @@ class FeedMapperTest extends IntegrationTest { /** * @expectedException OCP\AppFramework\Db\DoesNotExistException */ - public function testFindByUrlHashNotExisting () { + public function testFindByUrlHashNotExisting() + { $this->feedMapper->findByUrlHash('some random hash', $this->user); } - public function testDelete () { + public function testDelete() + { $this->loadFixtures('default'); $feeds = $this->feedMapper->findAllFromUser($this->user); @@ -157,13 +178,16 @@ class FeedMapperTest extends IntegrationTest { $this->assertCount(0, $items); } - public function testGetToDelete () { - $this->loadFeedFixtures([ + public function testGetToDelete() + { + $this->loadFeedFixtures( + [ ['deletedAt' => 1], ['deletedAt' => 0], ['deletedAt' => 1, 'userId' => 'john'], ['deletedAt' => 1000] - ]); + ] + ); $fetched = $this->feedMapper->getToDelete(); @@ -174,13 +198,16 @@ class FeedMapperTest extends IntegrationTest { $this->tearDownUser('john'); } - public function testGetToDeleteOlderThan () { - $this->loadFeedFixtures([ + public function testGetToDeleteOlderThan() + { + $this->loadFeedFixtures( + [ ['deletedAt' => 1], ['deletedAt' => 0], ['deletedAt' => 1, 'userId' => 'john'], ['deletedAt' => 1000] - ]); + ] + ); $fetched = $this->feedMapper->getToDelete(1000); @@ -191,13 +218,16 @@ class FeedMapperTest extends IntegrationTest { $this->tearDownUser('john'); } - public function testGetToDeleteUser () { - $this->loadFeedFixtures([ + public function testGetToDeleteUser() + { + $this->loadFeedFixtures( + [ ['deletedAt' => 1], ['deletedAt' => 0], ['deletedAt' => 1, 'userId' => 'john'], ['deletedAt' => 1000] - ]); + ] + ); $fetched = $this->feedMapper->getToDelete(2000, $this->user); @@ -208,14 +238,16 @@ class FeedMapperTest extends IntegrationTest { $this->tearDownUser('john'); } - public function testGetToDeleteEmpty () { + public function testGetToDeleteEmpty() + { $fetched = $this->feedMapper->getToDelete(); $this->assertInternalType('array', $fetched); $this->assertCount(0, $fetched); } - public function testDeleteUser () { + public function testDeleteUser() + { $this->loadFixtures('default'); $this->assertCount(4, $this->feedMapper->findAllFromUser($this->user)); @@ -231,7 +263,8 @@ class FeedMapperTest extends IntegrationTest { $this->assertCount(0, $items); } - public function testDeleteUserNotExisting () { + public function testDeleteUserNotExisting() + { $this->feedMapper->deleteUser('notexistinguser'); } } diff --git a/tests/Integration/Db/FolderMapperTest.php b/tests/Integration/Db/FolderMapperTest.php index 4be407566..889ac3e7c 100644 --- a/tests/Integration/Db/FolderMapperTest.php +++ b/tests/Integration/Db/FolderMapperTest.php @@ -5,7 +5,7 @@ * This file is licensed under the Affero General Public License version 3 or * later. See the COPYING file. * - * @author Bernhard Posselt <dev@bernhard-posselt.com> + * @author Bernhard Posselt <dev@bernhard-posselt.com> * @copyright Bernhard Posselt 2015 */ @@ -13,10 +13,12 @@ namespace OCA\News\Tests\Integration\Db; use OCA\News\Tests\Integration\IntegrationTest; -class FolderMapperTest extends IntegrationTest { +class FolderMapperTest extends IntegrationTest +{ - public function testFind () { + public function testFind() + { } diff --git a/tests/Integration/Db/ItemMapperTest.php b/tests/Integration/Db/ItemMapperTest.php index 546c43d85..c87a4139f 100644 --- a/tests/Integration/Db/ItemMapperTest.php +++ b/tests/Integration/Db/ItemMapperTest.php @@ -5,7 +5,7 @@ * This file is licensed under the Affero General Public License version 3 or * later. See the COPYING file. * - * @author Bernhard Posselt <dev@bernhard-posselt.com> + * @author Bernhard Posselt <dev@bernhard-posselt.com> * @copyright Bernhard Posselt 2015 */ @@ -15,9 +15,11 @@ use OCA\News\Tests\Integration\IntegrationTest; use OCA\News\Tests\Integration\Fixtures\FeedFixture; use OCA\News\Tests\Integration\Fixtures\ItemFixture; -class ItemMapperTest extends IntegrationTest { +class ItemMapperTest extends IntegrationTest +{ - public function testFind() { + public function testFind() + { $feed = new FeedFixture(); $feed = $this->feedMapper->insert($feed); @@ -32,17 +34,20 @@ class ItemMapperTest extends IntegrationTest { /** * Same as whereId with easier title search - * @param $title + * + * @param $title * @return mixed */ - private function whereTitleId($title) { + private function whereTitleId($title) + { return $this->findItemByTitle($title)->getId(); } /** * @expectedException OCP\AppFramework\Db\DoesNotExistException */ - public function testFindNotFoundWhenDeletedFeed() { + public function testFindNotFoundWhenDeletedFeed() + { $this->loadFixtures('default'); $id = $this->whereTitleId('not found feed'); @@ -53,7 +58,8 @@ class ItemMapperTest extends IntegrationTest { /** * @expectedException OCP\AppFramework\Db\DoesNotExistException */ - public function testFindNotFoundWhenDeletedFolder() { + public function testFindNotFoundWhenDeletedFolder() + { $this->loadFixtures('default'); @@ -62,7 +68,8 @@ class ItemMapperTest extends IntegrationTest { } - private function deleteReadOlderThanThreshold() { + private function deleteReadOlderThanThreshold() + { $this->loadFixtures('default'); $this->itemMapper->deleteReadOlderThanThreshold(1); @@ -77,7 +84,8 @@ class ItemMapperTest extends IntegrationTest { /** * @expectedException OCP\AppFramework\Db\DoesNotExistException */ - public function testDeleteOlderThanThresholdOne() { + public function testDeleteOlderThanThresholdOne() + { $this->loadFixtures('default'); $id = $this->whereTitleId('del1'); @@ -89,7 +97,8 @@ class ItemMapperTest extends IntegrationTest { /** * @expectedException OCP\AppFramework\Db\DoesNotExistException */ - public function testDeleteOlderThanThresholdTwo() { + public function testDeleteOlderThanThresholdTwo() + { $this->loadFixtures('default'); $id = $this->whereTitleId('del2'); @@ -99,7 +108,8 @@ class ItemMapperTest extends IntegrationTest { } - public function testStarredCount () { + public function testStarredCount() + { $this->loadFixtures('default'); $count = $this->itemMapper->starredCount($this->user); @@ -107,7 +117,8 @@ class ItemMapperTest extends IntegrationTest { } - public function testReadAll () { + public function testReadAll() + { $this->loadFixtures('default'); $this->itemMapper->readAll(PHP_INT_MAX, 10, $this->user); @@ -135,7 +146,8 @@ class ItemMapperTest extends IntegrationTest { } - public function testReadFolder () { + public function testReadFolder() + { $this->loadFixtures('default'); $folderId = $this->findFolderByName('first folder')->getId(); @@ -166,7 +178,8 @@ class ItemMapperTest extends IntegrationTest { } - public function testReadFeed () { + public function testReadFeed() + { $this->loadFixtures('default'); $feedId = $this->findFeedByTitle('third feed')->getId(); @@ -196,7 +209,8 @@ class ItemMapperTest extends IntegrationTest { } - public function testDeleteUser () { + public function testDeleteUser() + { $this->loadFixtures('default'); $this->itemMapper->deleteUser($this->user); @@ -205,7 +219,8 @@ class ItemMapperTest extends IntegrationTest { $this->assertEquals(0, $id); } - public function testGetNewestItemId () { + public function testGetNewestItemId() + { $this->loadFixtures('default'); $id = $this->itemMapper->getNewestItemId($this->user); @@ -214,7 +229,8 @@ class ItemMapperTest extends IntegrationTest { $this->assertEquals($itemId, $id); } - public function testFindAllUnreadOrStarred () { + public function testFindAllUnreadOrStarred() + { $this->loadFixtures('default'); $items = $this->itemMapper->findAllUnreadOrStarred($this->user); @@ -222,7 +238,8 @@ class ItemMapperTest extends IntegrationTest { } - public function testReadItem() { + public function testReadItem() + { $this->loadFixtures('readitem'); // assert that all items are unread $feed = $this->feedMapper->where(['userId' => 'john'])[0]; @@ -260,7 +277,8 @@ class ItemMapperTest extends IntegrationTest { } } - public function testUnreadItem() { + public function testUnreadItem() + { $this->loadFixtures('readitem'); // unread an item $feed = $this->feedMapper->where(['userId' => 'test'])[0]; @@ -286,7 +304,8 @@ class ItemMapperTest extends IntegrationTest { } } - protected function tearDown() { + protected function tearDown() + { parent::tearDown(); $this->clearUserNewsDatabase('john'); } diff --git a/tests/Integration/Fixtures/FeedFixture.php b/tests/Integration/Fixtures/FeedFixture.php index 3d7617a57..66461adbc 100644 --- a/tests/Integration/Fixtures/FeedFixture.php +++ b/tests/Integration/Fixtures/FeedFixture.php @@ -5,7 +5,7 @@ * This file is licensed under the Affero General Public License version 3 or * later. See the COPYING file. * - * @author Bernhard Posselt <dev@bernhard-posselt.com> + * @author Bernhard Posselt <dev@bernhard-posselt.com> * @copyright Bernhard Posselt 2015 */ @@ -15,13 +15,16 @@ namespace OCA\News\Tests\Integration\Fixtures; use OCA\News\Db\Feed; -class FeedFixture extends Feed { +class FeedFixture extends Feed +{ use Fixture; - public function __construct(array $defaults=[]) { + public function __construct(array $defaults=[]) + { parent::__construct(); - $defaults = array_merge([ + $defaults = array_merge( + [ 'userId' => 'test', 'urlHash' => 'urlHash', 'url' => 'http://the.url.com', @@ -42,7 +45,8 @@ class FeedFixture extends Feed { 'updateMode' => 0, 'updateErrorCount' => 0, 'lastUpdateError' => '', - ], $defaults); + ], $defaults + ); unset($defaults['items']); $this->fillDefaults($defaults); } diff --git a/tests/Integration/Fixtures/Fixture.php b/tests/Integration/Fixtures/Fixture.php index f17beb25c..1874c8102 100644 --- a/tests/Integration/Fixtures/Fixture.php +++ b/tests/Integration/Fixtures/Fixture.php @@ -5,7 +5,7 @@ * This file is licensed under the Affero General Public License version 3 or * later. See the COPYING file. * - * @author Bernhard Posselt <dev@bernhard-posselt.com> + * @author Bernhard Posselt <dev@bernhard-posselt.com> * @copyright Bernhard Posselt 2015 */ @@ -13,9 +13,11 @@ namespace OCA\News\Tests\Integration\Fixtures; -trait Fixture { +trait Fixture +{ - protected function fillDefaults(array $defaults=[]) { + protected function fillDefaults(array $defaults=[]) + { foreach ($defaults as $key => $value) { $method = 'set' . ucfirst($key); $this->$method($value); diff --git a/tests/Integration/Fixtures/FolderFixture.php b/tests/Integration/Fixtures/FolderFixture.php index 150557b8b..2564e8b71 100644 --- a/tests/Integration/Fixtures/FolderFixture.php +++ b/tests/Integration/Fixtures/FolderFixture.php @@ -5,7 +5,7 @@ * This file is licensed under the Affero General Public License version 3 or * later. See the COPYING file. * - * @author Bernhard Posselt <dev@bernhard-posselt.com> + * @author Bernhard Posselt <dev@bernhard-posselt.com> * @copyright Bernhard Posselt 2015 */ @@ -15,19 +15,23 @@ namespace OCA\News\Tests\Integration\Fixtures; use OCA\News\Db\Folder; -class FolderFixture extends Folder { +class FolderFixture extends Folder +{ use Fixture; - public function __construct(array $defaults=[]) { + public function __construct(array $defaults=[]) + { parent::__construct(); - $defaults = array_merge([ + $defaults = array_merge( + [ 'parentId' => 0, 'name' => 'folder', 'userId' => 'test', 'opened' => true, 'deletedAt' => 0, 'lastModified' => 9 - ], $defaults); + ], $defaults + ); unset($defaults['feeds']); $this->fillDefaults($defaults); } diff --git a/tests/Integration/Fixtures/ItemFixture.php b/tests/Integration/Fixtures/ItemFixture.php index 0832b0ef4..450b56f82 100644 --- a/tests/Integration/Fixtures/ItemFixture.php +++ b/tests/Integration/Fixtures/ItemFixture.php @@ -5,7 +5,7 @@ * This file is licensed under the Affero General Public License version 3 or * later. See the COPYING file. * - * @author Bernhard Posselt <dev@bernhard-posselt.com> + * @author Bernhard Posselt <dev@bernhard-posselt.com> * @copyright Bernhard Posselt 2015 */ @@ -15,12 +15,15 @@ namespace OCA\News\Tests\Integration\Fixtures; use OCA\News\Db\Item; -class ItemFixture extends Item { +class ItemFixture extends Item +{ use Fixture; - public function __construct(array $defaults=[]) { + public function __construct(array $defaults=[]) + { parent::__construct(); - $defaults = array_merge([ + $defaults = array_merge( + [ 'url' => 'http://google.de', 'title' => 'title', 'author' => 'my author', @@ -33,7 +36,8 @@ class ItemFixture extends Item { 'starred' => false, |