From a91be27787ee8f4092d584eb9e5198b5e92918e2 Mon Sep 17 00:00:00 2001 From: Sean Molenaar Date: Tue, 17 Sep 2024 18:48:29 +0200 Subject: [PATCH] fix: run phpcdf on tests --- .../Unit/Controller/ExportControllerTest.php | 1 - .../Unit/Controller/FeedApiControllerTest.php | 3 +- tests/Unit/Controller/FeedControllerTest.php | 5 +-- .../Controller/FolderApiControllerTest.php | 17 ++++---- .../Unit/Controller/FolderControllerTest.php | 3 +- .../Unit/Controller/ItemApiControllerTest.php | 1 - tests/Unit/Controller/ItemControllerTest.php | 3 -- tests/Unit/Controller/JSONHttpErrorTest.php | 4 +- tests/Unit/Controller/PageControllerTest.php | 3 -- .../Controller/UtilityApiControllerTest.php | 2 - tests/Unit/Db/FeedMapperTest.php | 1 - tests/Unit/Db/FeedTest.php | 8 ++-- tests/Unit/Db/FolderTest.php | 6 ++- tests/Unit/Db/ItemMapperAfterTest.php | 1 - tests/Unit/Db/ItemMapperPaginatedTest.php | 1 - tests/Unit/Db/ItemMapperTest.php | 1 - tests/Unit/Db/ItemTest.php | 6 ++- tests/Unit/Db/NewsMapperTest.php | 5 ++- tests/Unit/Fetcher/FeedIoClientTest.php | 3 +- tests/Unit/Fetcher/FetcherTest.php | 3 -- tests/Unit/Search/ItemSearchProviderTest.php | 3 +- tests/Unit/Service/FeedServiceTest.php | 41 ++++++++++++------- tests/Unit/Service/FolderServiceTest.php | 2 - tests/Unit/Service/ImportServiceTest.php | 2 - tests/Unit/Service/ItemServiceTest.php | 1 - tests/Unit/Service/OPMLServiceTest.php | 2 - tests/Unit/Service/ServiceTest.php | 1 - tests/Unit/Service/ShareServiceTest.php | 1 - tests/Unit/Service/StatusServiceTest.php | 4 +- tests/Unit/Service/UpdaterTest.php | 3 +- tests/Unit/Utility/OPMLExporterTest.php | 5 +-- tests/Unit/Utility/TimeTest.php | 2 +- 32 files changed, 62 insertions(+), 82 deletions(-) diff --git a/tests/Unit/Controller/ExportControllerTest.php b/tests/Unit/Controller/ExportControllerTest.php index cb21822bed..46bf39757f 100644 --- a/tests/Unit/Controller/ExportControllerTest.php +++ b/tests/Unit/Controller/ExportControllerTest.php @@ -167,5 +167,4 @@ public function testGetAllArticles() $return->render() ); } - } diff --git a/tests/Unit/Controller/FeedApiControllerTest.php b/tests/Unit/Controller/FeedApiControllerTest.php index 24fb7760d1..38f872431b 100644 --- a/tests/Unit/Controller/FeedApiControllerTest.php +++ b/tests/Unit/Controller/FeedApiControllerTest.php @@ -286,7 +286,7 @@ public function testRead() { $this->feedService->expects($this->once()) ->method('read') - ->with($this->userID,3,30); + ->with($this->userID, 3, 30); $this->class->read(3, 30); } @@ -413,5 +413,4 @@ public function testUpdateError() $this->class->update($userId, $feedId); } - } diff --git a/tests/Unit/Controller/FeedControllerTest.php b/tests/Unit/Controller/FeedControllerTest.php index fde8210880..ab654d10f3 100644 --- a/tests/Unit/Controller/FeedControllerTest.php +++ b/tests/Unit/Controller/FeedControllerTest.php @@ -427,7 +427,8 @@ public function testCreateReturnsErrorForInvalidCreate() $this->assertEquals($msg, $params['message']); $this->assertEquals( - $response->getStatus(), Http::STATUS_UNPROCESSABLE_ENTITY + $response->getStatus(), + Http::STATUS_UNPROCESSABLE_ENTITY ); } @@ -782,6 +783,4 @@ public function testPatchDoesNotExistOnUpdate() $this->assertEquals('test', $params['message']); $this->assertEquals($response->getStatus(), Http::STATUS_NOT_FOUND); } - - } diff --git a/tests/Unit/Controller/FolderApiControllerTest.php b/tests/Unit/Controller/FolderApiControllerTest.php index 1964f7b473..0073b00af8 100644 --- a/tests/Unit/Controller/FolderApiControllerTest.php +++ b/tests/Unit/Controller/FolderApiControllerTest.php @@ -31,7 +31,6 @@ use PHPUnit\Framework\TestCase; - class FolderApiControllerTest extends TestCase { @@ -89,7 +88,8 @@ public function testIndex() $this->assertEquals( [ 'folders' => [$folders[0]->toAPI()] - ], $response + ], + $response ); } @@ -113,7 +113,8 @@ public function testCreate() $this->assertEquals( [ 'folders' => [$folder->toAPI()] - ], $response + ], + $response ); } @@ -153,7 +154,8 @@ public function testCreateInvalidFolderName() $data = $response->getData(); $this->assertEquals($msg, $data['message']); $this->assertEquals( - Http::STATUS_UNPROCESSABLE_ENTITY, $response->getStatus() + Http::STATUS_UNPROCESSABLE_ENTITY, + $response->getStatus() ); } @@ -260,7 +262,8 @@ public function testUpdateInvalidFolderName() $data = $response->getData(); $this->assertEquals($this->msg, $data['message']); $this->assertEquals( - Http::STATUS_UNPROCESSABLE_ENTITY, $response->getStatus() + Http::STATUS_UNPROCESSABLE_ENTITY, + $response->getStatus() ); } @@ -278,15 +281,11 @@ public function testUpdateRoot() { $response = $this->class->update(null, ''); $this->assertSame(400, $response->getStatus()); - } public function testDeleteRoot() { $response = $this->class->delete(null); $this->assertSame(400, $response->getStatus()); - } - - } diff --git a/tests/Unit/Controller/FolderControllerTest.php b/tests/Unit/Controller/FolderControllerTest.php index 4f46e12117..81b4d60435 100644 --- a/tests/Unit/Controller/FolderControllerTest.php +++ b/tests/Unit/Controller/FolderControllerTest.php @@ -306,5 +306,4 @@ public function testRestoreConflict() $this->assertEquals(Http::STATUS_CONFLICT, $response->getStatus()); $this->assertEquals($this->msg, $params['message']); } - -} \ No newline at end of file +} diff --git a/tests/Unit/Controller/ItemApiControllerTest.php b/tests/Unit/Controller/ItemApiControllerTest.php index 5359e89723..c2d5158462 100644 --- a/tests/Unit/Controller/ItemApiControllerTest.php +++ b/tests/Unit/Controller/ItemApiControllerTest.php @@ -27,7 +27,6 @@ use PHPUnit\Framework\TestCase; - class ItemApiControllerTest extends TestCase { /** diff --git a/tests/Unit/Controller/ItemControllerTest.php b/tests/Unit/Controller/ItemControllerTest.php index ab263dbf72..43aceb7e21 100644 --- a/tests/Unit/Controller/ItemControllerTest.php +++ b/tests/Unit/Controller/ItemControllerTest.php @@ -30,7 +30,6 @@ use OCP\IUserSession; use PHPUnit\Framework\TestCase; - class ItemControllerTest extends TestCase { @@ -624,6 +623,4 @@ public function testGetNewItemsNoNewestItemsId() $response = $this->controller->newItems(ListType::FEED, 2, 3); $this->assertEquals([], $response); } - - } diff --git a/tests/Unit/Controller/JSONHttpErrorTest.php b/tests/Unit/Controller/JSONHttpErrorTest.php index 8bfb11f3ee..98a16de24f 100644 --- a/tests/Unit/Controller/JSONHttpErrorTest.php +++ b/tests/Unit/Controller/JSONHttpErrorTest.php @@ -29,12 +29,10 @@ public function testError() $this->assertEquals(['message' => 'hi'], $result->getData()); $this->assertEquals(3, $result->getStatus()); } - - } class DummyTraitingClass { use JSONHttpErrorTrait; -} \ No newline at end of file +} diff --git a/tests/Unit/Controller/PageControllerTest.php b/tests/Unit/Controller/PageControllerTest.php index 4e29504796..a65e43cb4a 100644 --- a/tests/Unit/Controller/PageControllerTest.php +++ b/tests/Unit/Controller/PageControllerTest.php @@ -275,7 +275,6 @@ public function testExplore() $out = $this->controller->explore('en'); $this->assertEquals($in, $out); - } public function testExploreError() @@ -295,7 +294,5 @@ public function testExploreError() $out = $this->controller->explore('nl'); $this->assertEquals(404, $out->getStatus()); - } - } diff --git a/tests/Unit/Controller/UtilityApiControllerTest.php b/tests/Unit/Controller/UtilityApiControllerTest.php index 16d583b71e..99b9a93e06 100644 --- a/tests/Unit/Controller/UtilityApiControllerTest.php +++ b/tests/Unit/Controller/UtilityApiControllerTest.php @@ -145,6 +145,4 @@ public function testStatus() $this->assertEquals($in, $result); } - - } diff --git a/tests/Unit/Db/FeedMapperTest.php b/tests/Unit/Db/FeedMapperTest.php index 7830d266cc..2b53fcbd40 100644 --- a/tests/Unit/Db/FeedMapperTest.php +++ b/tests/Unit/Db/FeedMapperTest.php @@ -49,7 +49,6 @@ protected function setUp(): void $feed2->resetUpdatedFields(); $this->feeds = [$feed1, $feed2]; - } /** diff --git a/tests/Unit/Db/FeedTest.php b/tests/Unit/Db/FeedTest.php index fb983809ea..7b84c88b8b 100644 --- a/tests/Unit/Db/FeedTest.php +++ b/tests/Unit/Db/FeedTest.php @@ -63,7 +63,8 @@ public function testToAPI() 'updateErrorCount' => 2, 'lastUpdateError' => 'hi', 'items' => [], - ], $feed->toAPI() + ], + $feed->toAPI() ); } @@ -121,7 +122,8 @@ public function testSerialize() 'lastUpdateError' => 'hi', 'basicAuthUser' => 'user', 'basicAuthPassword' => 'password' - ], $feed->jsonSerialize() + ], + $feed->jsonSerialize() ); } @@ -200,6 +202,4 @@ public function testSetPinned() $feed->setPinned(true); $this->assertEquals(true, $feed->getPinned()); } - - } diff --git a/tests/Unit/Db/FolderTest.php b/tests/Unit/Db/FolderTest.php index 8f98fb3739..8d0fc404af 100644 --- a/tests/Unit/Db/FolderTest.php +++ b/tests/Unit/Db/FolderTest.php @@ -33,7 +33,8 @@ public function testToAPI() 'name' => 'name', 'opened' => false, 'feeds' => [], - ], $folder->toAPI() + ], + $folder->toAPI() ); } @@ -75,7 +76,8 @@ public function testSerialize() 'userId' => 'abc', 'opened' => true, 'deletedAt' => 9, - ], $folder->jsonSerialize() + ], + $folder->jsonSerialize() ); } public function testSetDeletedAt() diff --git a/tests/Unit/Db/ItemMapperAfterTest.php b/tests/Unit/Db/ItemMapperAfterTest.php index 016db17395..4b17518c1d 100644 --- a/tests/Unit/Db/ItemMapperAfterTest.php +++ b/tests/Unit/Db/ItemMapperAfterTest.php @@ -585,5 +585,4 @@ public function testFindAllAfterInvalid() $result = $this->class->findAllAfter('jack', 232, 1610903351); $this->assertEquals([Item::fromRow(['id' => 4])], $result); } - } diff --git a/tests/Unit/Db/ItemMapperPaginatedTest.php b/tests/Unit/Db/ItemMapperPaginatedTest.php index 9d44e0756e..5e331fbfdc 100644 --- a/tests/Unit/Db/ItemMapperPaginatedTest.php +++ b/tests/Unit/Db/ItemMapperPaginatedTest.php @@ -1276,5 +1276,4 @@ public function testFindAllFolderSearchId() $result = $this->class->findAllFolder('jack', 2, 10, 10, false, false, ['key', 'word']); $this->assertEquals([Item::fromRow(['id' => 4])], $result); } - } diff --git a/tests/Unit/Db/ItemMapperTest.php b/tests/Unit/Db/ItemMapperTest.php index 397f3be2c6..fc599a4588 100644 --- a/tests/Unit/Db/ItemMapperTest.php +++ b/tests/Unit/Db/ItemMapperTest.php @@ -1113,5 +1113,4 @@ public function testDeleteOverThresholdSuccessUnreadSkipsIfUnderThreshold() $res = $this->class->deleteOverThreshold(3, false); $this->assertSame(10, $res); } - } diff --git a/tests/Unit/Db/ItemTest.php b/tests/Unit/Db/ItemTest.php index 11620b33c0..7a382e6edb 100644 --- a/tests/Unit/Db/ItemTest.php +++ b/tests/Unit/Db/ItemTest.php @@ -228,7 +228,8 @@ public function testJSONSerialize() 'categories' => ['food'], 'sharedBy' => 'jack', 'sharedByDisplayName' => 'Jack' - ], $item->jsonSerialize() + ], + $item->jsonSerialize() ); } @@ -274,7 +275,8 @@ public function testToExport() 'starred' => true, 'feedLink' => 'http://test', 'rtl' => true - ], $item->toExport($feeds) + ], + $item->toExport($feeds) ); } diff --git a/tests/Unit/Db/NewsMapperTest.php b/tests/Unit/Db/NewsMapperTest.php index aa1be59890..66e27b99f7 100644 --- a/tests/Unit/Db/NewsMapperTest.php +++ b/tests/Unit/Db/NewsMapperTest.php @@ -25,7 +25,8 @@ * * @package OCA\News\Tests\Unit\Db */ -abstract class TmpNewsMapper extends NewsMapperV2 { +abstract class TmpNewsMapper extends NewsMapperV2 +{ const TABLE_NAME = 'NAME'; } @@ -272,4 +273,4 @@ public function testPurgeBoth() $result = $this->class->purgeDeleted('jack', 1); } -} \ No newline at end of file +} diff --git a/tests/Unit/Fetcher/FeedIoClientTest.php b/tests/Unit/Fetcher/FeedIoClientTest.php index 4020bc51f0..00817b9e11 100644 --- a/tests/Unit/Fetcher/FeedIoClientTest.php +++ b/tests/Unit/Fetcher/FeedIoClientTest.php @@ -3,7 +3,6 @@ namespace OCA\News\Tests\Unit\Fetcher; - use DateTime; use FeedIo\Adapter\Guzzle\Response; use FeedIo\Adapter\NotFoundException; @@ -89,4 +88,4 @@ public function testGetResponseThrows(): void $this->class->getResponse('url', new DateTime('@0')); } -} \ No newline at end of file +} diff --git a/tests/Unit/Fetcher/FetcherTest.php b/tests/Unit/Fetcher/FetcherTest.php index 157ce69057..095ebe0e1a 100644 --- a/tests/Unit/Fetcher/FetcherTest.php +++ b/tests/Unit/Fetcher/FetcherTest.php @@ -24,7 +24,6 @@ namespace OCA\News\Tests\Unit\Fetcher; - use OCA\News\Fetcher\Fetcher; use OCA\News\Fetcher\IFeedFetcher; use PHPUnit\Framework\TestCase; @@ -142,6 +141,4 @@ public function testMultipleFetchersOnlyOneShouldHandle() $this->assertEquals($return, $result); } - - } diff --git a/tests/Unit/Search/ItemSearchProviderTest.php b/tests/Unit/Search/ItemSearchProviderTest.php index c50e32a593..1086ae0d9e 100644 --- a/tests/Unit/Search/ItemSearchProviderTest.php +++ b/tests/Unit/Search/ItemSearchProviderTest.php @@ -116,7 +116,8 @@ public function testSearch() 10, 0, false, - ['some text']) + ['some text'] + ) ->willReturn($items); diff --git a/tests/Unit/Service/FeedServiceTest.php b/tests/Unit/Service/FeedServiceTest.php index bcc367f0cf..f981aeefd5 100644 --- a/tests/Unit/Service/FeedServiceTest.php +++ b/tests/Unit/Service/FeedServiceTest.php @@ -35,7 +35,6 @@ use PHPUnit\Framework\TestCase; use Psr\Log\LoggerInterface; - class FeedServiceTest extends TestCase { @@ -215,8 +214,13 @@ function () use ($createdFeed) { ); $feed = $this->class->create( - $this->uid, $url, $folderId, false, null, - 'user', 'pass' + $this->uid, + $url, + $folderId, + false, + null, + 'user', + 'pass' ); $this->assertEquals($feed->getFolderId(), $folderId); @@ -274,8 +278,13 @@ function () use ($createdFeed) { ); $feed = $this->class->create( - $this->uid, $url, $folderId, false, 'title', - 'user', 'pass' + $this->uid, + $url, + $folderId, + false, + 'title', + 'user', + 'pass' ); $this->assertEquals($feed->getFolderId(), $folderId); @@ -337,8 +346,13 @@ function () use ($createdFeed) { ); $feed = $this->class->create( - $this->uid, $url, $folderId, false, null, - 'user', 'pass' + $this->uid, + $url, + $folderId, + false, + null, + 'user', + 'pass' ); $this->assertEquals($feed->getFolderId(), $folderId); @@ -445,7 +459,7 @@ public function testFetchReturnsOnBlock() $feed->expects($this->once()) ->method('getPreventUpdate') - ->will($this->returnValue(TRUE)); + ->will($this->returnValue(true)); $this->assertSame($feed, $this->class->fetch($feed)); } @@ -462,7 +476,7 @@ public function testFetchAllReturnsOnAllBlock() $feed->expects($this->exactly(2)) ->method('getPreventUpdate') - ->will($this->returnValue(TRUE)); + ->will($this->returnValue(true)); $this->class->fetchAll(); } @@ -475,7 +489,7 @@ public function testFetchReturnsOnReadError() $feed->expects($this->once()) ->method('getPreventUpdate') - ->will($this->returnValue(FALSE)); + ->will($this->returnValue(false)); $feed->expects($this->once()) ->method('getLocation') @@ -512,7 +526,7 @@ public function testFetchReturnsNoUpdate() $feed->expects($this->once()) ->method('getPreventUpdate') - ->will($this->returnValue(FALSE)); + ->will($this->returnValue(false)); $feed->expects($this->once()) ->method('getLocation') @@ -536,7 +550,7 @@ public function testFetchSucceedsEmptyItems() $feed->expects($this->once()) ->method('getPreventUpdate') - ->will($this->returnValue(FALSE)); + ->will($this->returnValue(false)); $feed->expects($this->once()) ->method('getLocation') @@ -703,7 +717,7 @@ public function testPatchEnableFullText() $feed2 = Feed::fromRow(['id' => 3]); $this->mapper->expects($this->exactly(1)) ->method('findFromUser') - ->with($this->uid,$feed->getId()) + ->with($this->uid, $feed->getId()) ->willReturnOnConsecutiveCalls($this->returnValue($feed)); $feed2->setFullTextEnabled(false); @@ -826,5 +840,4 @@ public function testRead() $this->class->read($this->uid, 1); } - } diff --git a/tests/Unit/Service/FolderServiceTest.php b/tests/Unit/Service/FolderServiceTest.php index 3e47c6136d..7c96312fac 100644 --- a/tests/Unit/Service/FolderServiceTest.php +++ b/tests/Unit/Service/FolderServiceTest.php @@ -28,7 +28,6 @@ use PHPUnit\Framework\TestCase; use Psr\Log\LoggerInterface; - class FolderServiceTest extends TestCase { @@ -287,5 +286,4 @@ public function testRead() $this->class->read('jack', 1); } - } diff --git a/tests/Unit/Service/ImportServiceTest.php b/tests/Unit/Service/ImportServiceTest.php index 2a6a7b106f..c4e7a4338a 100644 --- a/tests/Unit/Service/ImportServiceTest.php +++ b/tests/Unit/Service/ImportServiceTest.php @@ -36,7 +36,6 @@ use PHPUnit\Framework\TestCase; use Psr\Log\LoggerInterface; - class ImportServiceTest extends TestCase { /** @@ -228,5 +227,4 @@ function () use ($insertFeed) { $this->assertEquals($feed, $result); } - } diff --git a/tests/Unit/Service/ItemServiceTest.php b/tests/Unit/Service/ItemServiceTest.php index 17a67674c9..eee0af85d6 100644 --- a/tests/Unit/Service/ItemServiceTest.php +++ b/tests/Unit/Service/ItemServiceTest.php @@ -630,5 +630,4 @@ public function testPurgeOverThresholdSet() $this->class->purgeOverThreshold(5); } - } diff --git a/tests/Unit/Service/OPMLServiceTest.php b/tests/Unit/Service/OPMLServiceTest.php index 6f117c0662..4e95264d5f 100644 --- a/tests/Unit/Service/OPMLServiceTest.php +++ b/tests/Unit/Service/OPMLServiceTest.php @@ -40,7 +40,6 @@ use PHPUnit\Framework\TestCase; use Psr\Log\LoggerInterface; - class OPMLServiceTest extends TestCase { /** @@ -139,5 +138,4 @@ public function testExportSuccess() $this->assertEquals('doc', $this->class->export('jack')); } - } diff --git a/tests/Unit/Service/ServiceTest.php b/tests/Unit/Service/ServiceTest.php index cc4e2604b0..b9eda74506 100644 --- a/tests/Unit/Service/ServiceTest.php +++ b/tests/Unit/Service/ServiceTest.php @@ -133,5 +133,4 @@ public function testDeleteUser() $this->class->deleteUser(''); } - } diff --git a/tests/Unit/Service/ShareServiceTest.php b/tests/Unit/Service/ShareServiceTest.php index d7c26a9181..145595bbcf 100644 --- a/tests/Unit/Service/ShareServiceTest.php +++ b/tests/Unit/Service/ShareServiceTest.php @@ -36,7 +36,6 @@ use PHPUnit\Framework\TestCase; use Psr\Log\LoggerInterface; - class ShareServiceTest extends TestCase { /** diff --git a/tests/Unit/Service/StatusServiceTest.php b/tests/Unit/Service/StatusServiceTest.php index fdfe41af5c..287d5ce6d0 100644 --- a/tests/Unit/Service/StatusServiceTest.php +++ b/tests/Unit/Service/StatusServiceTest.php @@ -20,7 +20,6 @@ use PHPUnit\Framework\MockObject\MockObject; use PHPUnit\Framework\TestCase; - class StatusServiceTest extends TestCase { /** @@ -228,5 +227,4 @@ public function testIsProperlyConfiguredModeCron() $response = $this->service->isCronProperlyConfigured(); $this->assertTrue($response); } - -} \ No newline at end of file +} diff --git a/tests/Unit/Service/UpdaterTest.php b/tests/Unit/Service/UpdaterTest.php index 3d5ca22529..9b73adc93b 100644 --- a/tests/Unit/Service/UpdaterTest.php +++ b/tests/Unit/Service/UpdaterTest.php @@ -94,5 +94,4 @@ public function testUpdate() ->method('fetchAll'); $this->updater->update(); } - -} \ No newline at end of file +} diff --git a/tests/Unit/Utility/OPMLExporterTest.php b/tests/Unit/Utility/OPMLExporterTest.php index bc0fd7bee9..9357c86f03 100644 --- a/tests/Unit/Utility/OPMLExporterTest.php +++ b/tests/Unit/Utility/OPMLExporterTest.php @@ -18,7 +18,6 @@ use OCA\News\Utility\OPMLExporter; use PHPUnit\Framework\TestCase; - class OPMLExporterTest extends TestCase { /** @var OPMLExporter */ @@ -156,6 +155,4 @@ public function testBuildReturnsFeedsAndFolders() $this->getAttribute($elems->item(1)->childNodes->item(0), 'htmlUrl') ); } - - -} \ No newline at end of file +} diff --git a/tests/Unit/Utility/TimeTest.php b/tests/Unit/Utility/TimeTest.php index 54b5d46755..f571e97842 100644 --- a/tests/Unit/Utility/TimeTest.php +++ b/tests/Unit/Utility/TimeTest.php @@ -47,4 +47,4 @@ public function testMicroTime(): void $result = (float) $time->getMicroTime(); $this->assertTrue($result >= $cur); } -} \ No newline at end of file +}