Skip to content

Commit

Permalink
refactor: Add void return type to PHPUnit test methods
Browse files Browse the repository at this point in the history
Signed-off-by: Christoph Wurst <christoph@winzerhof-wurst.at>
  • Loading branch information
ChristophWurst committed Sep 15, 2024
1 parent 4281ce6 commit 49dd79e
Show file tree
Hide file tree
Showing 670 changed files with 4,750 additions and 4,750 deletions.
2 changes: 1 addition & 1 deletion apps/comments/tests/Unit/Activity/ListenerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ protected function setUp(): void {
);
}

public function testCommentEvent() {
public function testCommentEvent(): void {
$this->appManager->expects($this->any())
->method('isInstalled')
->with('activity')
Expand Down
2 changes: 1 addition & 1 deletion apps/comments/tests/Unit/AppInfo/ApplicationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ protected function tearDown(): void {
parent::tearDown();
}

public function test() {
public function test(): void {
$app = new Application();
$c = $app->getContainer();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ protected function setUp(): void {
* @dataProvider sortDataProvider
* @param $data
*/
public function testSort($data) {
public function testSort($data): void {
$commentMocks = [];
foreach ($data['actors'] as $actorType => $actors) {
foreach ($actors as $actorId => $noOfComments) {
Expand Down
8 changes: 4 additions & 4 deletions apps/comments/tests/Unit/Controller/NotificationsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ protected function setUp(): void {
);
}

public function testViewGuestRedirect() {
public function testViewGuestRedirect(): void {
$this->commentsManager->expects($this->never())
->method('get');

Expand Down Expand Up @@ -96,7 +96,7 @@ public function testViewGuestRedirect() {
$this->assertSame('link-to-login', $response->getRedirectURL());
}

public function testViewSuccess() {
public function testViewSuccess(): void {
$comment = $this->createMock(IComment::class);
$comment->expects($this->any())
->method('getObjectType')
Expand Down Expand Up @@ -146,7 +146,7 @@ public function testViewSuccess() {
$this->assertInstanceOf(RedirectResponse::class, $response);
}

public function testViewInvalidComment() {
public function testViewInvalidComment(): void {
$this->commentsManager->expects($this->any())
->method('get')
->with('42')
Expand Down Expand Up @@ -174,7 +174,7 @@ public function testViewInvalidComment() {
$this->assertInstanceOf(NotFoundResponse::class, $response);
}

public function testViewNoFile() {
public function testViewNoFile(): void {
$comment = $this->createMock(IComment::class);
$comment->expects($this->any())
->method('getObjectType')
Expand Down
4 changes: 2 additions & 2 deletions apps/comments/tests/Unit/EventHandlerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ protected function setUp(): void {
$this->eventHandler = new CommentsEventListener($this->activityListener, $this->notificationListener);
}

public function testNotFiles() {
public function testNotFiles(): void {
/** @var IComment|\PHPUnit\Framework\MockObject\MockObject $comment */
$comment = $this->getMockBuilder(IComment::class)->getMock();
$comment->expects($this->once())
Expand Down Expand Up @@ -69,7 +69,7 @@ public function handledProvider() {
* @dataProvider handledProvider
* @param string $eventType
*/
public function testHandled($eventType) {
public function testHandled($eventType): void {
/** @var IComment|\PHPUnit\Framework\MockObject\MockObject $comment */
$comment = $this->getMockBuilder(IComment::class)->getMock();
$comment->expects($this->once())
Expand Down
6 changes: 3 additions & 3 deletions apps/comments/tests/Unit/Notification/ListenerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ public function eventProvider() {
* @param string $eventType
* @param string $notificationMethod
*/
public function testEvaluate($eventType, $notificationMethod) {
public function testEvaluate($eventType, $notificationMethod): void {
/** @var IComment|\PHPUnit\Framework\MockObject\MockObject $comment */
$comment = $this->getMockBuilder(IComment::class)->getMock();
$comment->expects($this->any())
Expand Down Expand Up @@ -123,7 +123,7 @@ public function testEvaluate($eventType, $notificationMethod) {
* @dataProvider eventProvider
* @param string $eventType
*/
public function testEvaluateNoMentions($eventType) {
public function testEvaluateNoMentions($eventType): void {
/** @var IComment|\PHPUnit\Framework\MockObject\MockObject $comment */
$comment = $this->getMockBuilder(IComment::class)->getMock();
$comment->expects($this->any())
Expand Down Expand Up @@ -160,7 +160,7 @@ public function testEvaluateNoMentions($eventType) {
$this->listener->evaluate($event);
}

public function testEvaluateUserDoesNotExist() {
public function testEvaluateUserDoesNotExist(): void {
/** @var IComment|\PHPUnit\Framework\MockObject\MockObject $comment */
$comment = $this->getMockBuilder(IComment::class)->getMock();
$comment->expects($this->any())
Expand Down
14 changes: 7 additions & 7 deletions apps/comments/tests/Unit/Notification/NotifierTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ protected function setUp(): void {
$this->comment = $this->createMock(IComment::class);
}

public function testPrepareSuccess() {
public function testPrepareSuccess(): void {
$fileName = 'Gre\'thor.odp';
$displayName = 'Huraga';
$message = '@Huraga mentioned you in a comment on "Gre\'thor.odp"';
Expand Down Expand Up @@ -190,7 +190,7 @@ public function testPrepareSuccess() {
$this->notifier->prepare($this->notification, $this->lc);
}

public function testPrepareSuccessDeletedUser() {
public function testPrepareSuccessDeletedUser(): void {
$fileName = 'Gre\'thor.odp';
$message = 'You were mentioned on "Gre\'thor.odp", in a comment by an account that has since been deleted';

Expand Down Expand Up @@ -305,7 +305,7 @@ public function testPrepareSuccessDeletedUser() {
}


public function testPrepareDifferentApp() {
public function testPrepareDifferentApp(): void {
$this->expectException(UnknownNotificationException::class);

$this->folder
Expand Down Expand Up @@ -342,7 +342,7 @@ public function testPrepareDifferentApp() {
}


public function testPrepareNotFound() {
public function testPrepareNotFound(): void {
$this->expectException(UnknownNotificationException::class);

$this->folder
Expand Down Expand Up @@ -380,7 +380,7 @@ public function testPrepareNotFound() {
}


public function testPrepareDifferentSubject() {
public function testPrepareDifferentSubject(): void {
$this->expectException(UnknownNotificationException::class);

$displayName = 'Huraga';
Expand Down Expand Up @@ -437,7 +437,7 @@ public function testPrepareDifferentSubject() {
}


public function testPrepareNotFiles() {
public function testPrepareNotFiles(): void {
$this->expectException(UnknownNotificationException::class);

$displayName = 'Huraga';
Expand Down Expand Up @@ -495,7 +495,7 @@ public function testPrepareNotFiles() {
}


public function testPrepareUnresolvableFileID() {
public function testPrepareUnresolvableFileID(): void {
$this->expectException(AlreadyProcessedException::class);

$displayName = 'Huraga';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ protected function setUp(): void {
);
}

public function testDispatchStartEvent() {
public function testDispatchStartEvent(): void {
$this->timezoneService->method('getUserTimezone')->with('user')->willReturn('Europe/Berlin');

$absence = new Absence();
Expand Down Expand Up @@ -94,7 +94,7 @@ public function testDispatchStartEvent() {
]);
}

public function testDispatchStopEvent() {
public function testDispatchStopEvent(): void {
$this->timezoneService->method('getUserTimezone')->with('user')->willReturn('Europe/Berlin');

$absence = new Absence();
Expand Down Expand Up @@ -126,7 +126,7 @@ public function testDispatchStopEvent() {
]);
}

public function testDoesntDispatchUnknownEvent() {
public function testDoesntDispatchUnknownEvent(): void {
$this->timezoneService->method('getUserTimezone')->with('user')->willReturn('Europe/Berlin');

$absence = new Absence();
Expand Down
4 changes: 2 additions & 2 deletions apps/dav/tests/unit/CalDAV/AppCalendar/AppCalendarTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ public function testDelete(): void {
$this->appCalendar->delete();
}

public function testCreateFile() {
public function testCreateFile(): void {
$this->writeableCalendar->expects($this->exactly(3))
->method('createFromString')
->withConsecutive(['some-name', 'data'], ['other-name', ''], ['name', 'some data']);
Expand All @@ -69,7 +69,7 @@ public function testCreateFile() {
fclose($fp);
}

public function testCreateFile_readOnly() {
public function testCreateFile_readOnly(): void {
// If writing is not supported
$this->expectException(\Sabre\DAV\Exception\Forbidden::class);
$this->expectExceptionMessage('Creating a new entry is not allowed');
Expand Down
26 changes: 13 additions & 13 deletions apps/dav/tests/unit/CalDAV/AppCalendar/CalendarObjectTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,15 +33,15 @@ protected function setUp(): void {
$this->calendarObject = new CalendarObject($this->calendar, $this->backend, $this->vobject);
}

public function testGetOwner() {
public function testGetOwner(): void {
$this->assertEquals($this->calendarObject->getOwner(), 'owner');
}

public function testGetGroup() {
public function testGetGroup(): void {
$this->assertEquals($this->calendarObject->getGroup(), 'group');
}

public function testGetACL() {
public function testGetACL(): void {
$this->calendar->expects($this->exactly(2))
->method('getPermissions')
->willReturnOnConsecutiveCalls(Constants::PERMISSION_READ, Constants::PERMISSION_ALL);
Expand Down Expand Up @@ -70,17 +70,17 @@ public function testGetACL() {
]);
}

public function testSetACL() {
public function testSetACL(): void {
$this->expectException(\Sabre\DAV\Exception\Forbidden::class);
$this->calendarObject->setACL([]);
}

public function testPut_readOnlyBackend() {
public function testPut_readOnlyBackend(): void {
$this->expectException(\Sabre\DAV\Exception\Forbidden::class);
$this->calendarObject->put('foo');
}

public function testPut_noPermissions() {
public function testPut_noPermissions(): void {
$this->expectException(\Sabre\DAV\Exception\Forbidden::class);

$backend = $this->createMock(ICreateFromString::class);
Expand All @@ -93,7 +93,7 @@ public function testPut_noPermissions() {
$calendarObject->put('foo');
}

public function testPut() {
public function testPut(): void {
$backend = $this->createMock(ICreateFromString::class);
$calendarObject = new CalendarObject($this->calendar, $backend, $this->vobject);

Expand All @@ -110,27 +110,27 @@ public function testPut() {
$calendarObject->put('foo');
}

public function testGet() {
public function testGet(): void {
$this->vobject->expects($this->once())
->method('serialize')
->willReturn('foo');
$this->assertEquals($this->calendarObject->get(), 'foo');
}

public function testDelete_notWriteable() {
public function testDelete_notWriteable(): void {
$this->expectException(\Sabre\DAV\Exception\Forbidden::class);
$this->calendarObject->delete();
}

public function testDelete_noPermission() {
public function testDelete_noPermission(): void {
$backend = $this->createMock(ICreateFromString::class);
$calendarObject = new CalendarObject($this->calendar, $backend, $this->vobject);

$this->expectException(\Sabre\DAV\Exception\Forbidden::class);
$calendarObject->delete();
}

public function testDelete() {
public function testDelete(): void {
$backend = $this->createMock(ICreateFromString::class);
$calendarObject = new CalendarObject($this->calendar, $backend, $this->vobject);

Expand All @@ -153,7 +153,7 @@ public function testDelete() {
$calendarObject->delete();
}

public function testGetName() {
public function testGetName(): void {
$this->vobject->expects($this->exactly(2))
->method('getBaseComponent')
->willReturnOnConsecutiveCalls((object)['UID' => 'someid'], (object)['UID' => 'someid', 'X-FILENAME' => 'real-filename.ics']);
Expand All @@ -162,7 +162,7 @@ public function testGetName() {
$this->assertEquals($this->calendarObject->getName(), 'real-filename.ics');
}

public function testSetName() {
public function testSetName(): void {
$this->expectException(\Sabre\DAV\Exception\Forbidden::class);
$this->calendarObject->setName('Some name');
}
Expand Down
4 changes: 2 additions & 2 deletions apps/dav/tests/unit/CalDAV/CachedSubscriptionProviderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ protected function setUp(): void {
$this->provider = new CachedSubscriptionProvider($this->backend);
}

public function testGetCalendars() {
public function testGetCalendars(): void {
$calendars = $this->provider->getCalendars(
'user-principal-123',
[]
Expand All @@ -58,7 +58,7 @@ public function testGetCalendars() {
$this->assertInstanceOf(CachedSubscriptionImpl::class, $calendars[1]);
}

public function testGetCalendarsFilterByUri() {
public function testGetCalendarsFilterByUri(): void {
$calendars = $this->provider->getCalendars(
'user-principal-123',
['subscription-1']
Expand Down
10 changes: 5 additions & 5 deletions apps/dav/tests/unit/CalDAV/CalDavBackendTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -1490,7 +1490,7 @@ public function testPruneOutdatedSyncTokens(): void {
self::assertSame(0, $deleted);
}

public function testSearchAndExpandRecurrences() {
public function testSearchAndExpandRecurrences(): void {
$calendarId = $this->createTestCalendar();
$calendarInfo = [
'id' => $calendarId,
Expand Down Expand Up @@ -1646,7 +1646,7 @@ public function testRestoreChanges(): void {
self::assertEquals([$uri2], $changesAfter['deleted']);
}

public function testSearchWithLimitAndTimeRange() {
public function testSearchWithLimitAndTimeRange(): void {
$calendarId = $this->createTestCalendar();
$calendarInfo = [
'id' => $calendarId,
Expand Down Expand Up @@ -1703,7 +1703,7 @@ public function testSearchWithLimitAndTimeRange() {
);
}

public function testSearchWithLimitAndTimeRangeShouldNotReturnMoreObjectsThenLimit() {
public function testSearchWithLimitAndTimeRangeShouldNotReturnMoreObjectsThenLimit(): void {
$calendarId = $this->createTestCalendar();
$calendarInfo = [
'id' => $calendarId,
Expand Down Expand Up @@ -1753,7 +1753,7 @@ public function testSearchWithLimitAndTimeRangeShouldNotReturnMoreObjectsThenLim
);
}

public function testSearchWithLimitAndTimeRangeShouldReturnObjectsInTheSameOrder() {
public function testSearchWithLimitAndTimeRangeShouldReturnObjectsInTheSameOrder(): void {
$calendarId = $this->createTestCalendar();
$calendarInfo = [
'id' => $calendarId,
Expand Down Expand Up @@ -1810,7 +1810,7 @@ public function testSearchWithLimitAndTimeRangeShouldReturnObjectsInTheSameOrder
);
}

public function testSearchShouldReturnObjectsInTheSameOrderMissingDate() {
public function testSearchShouldReturnObjectsInTheSameOrderMissingDate(): void {
$calendarId = $this->createTestCalendar();
$calendarInfo = [
'id' => $calendarId,
Expand Down
2 changes: 1 addition & 1 deletion apps/dav/tests/unit/CalDAV/CalendarTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -442,7 +442,7 @@ public function providesConfidentialClassificationData() {
];
}

public function testRemoveVAlarms() {
public function testRemoveVAlarms(): void {
$publicObjectData = <<<EOD
BEGIN:VCALENDAR
VERSION:2.0
Expand Down
2 changes: 1 addition & 1 deletion apps/dav/tests/unit/CalDAV/Schedule/IMipPluginTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -467,7 +467,7 @@ public function testParsingRecurrence(): void {
$this->assertEquals('1.1', $message->getScheduleStatus());
}

public function testEmailValidationFailed() {
public function testEmailValidationFailed(): void {
$message = new Message();
$message->method = 'REQUEST';
$message->message = new VCalendar();
Expand Down
Loading

0 comments on commit 49dd79e

Please sign in to comment.