Skip to content

Commit 1ccf39a

Browse files
refactor: add and apply nextcloud rector rules
Signed-off-by: Christoph Wurst <1374172+ChristophWurst@users.noreply.github.com>
1 parent 8d84ac9 commit 1ccf39a

File tree

57 files changed

+611
-256
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

57 files changed

+611
-256
lines changed

rector.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
* SPDX-License-Identifier: AGPL-3.0-or-later
88
*/
99

10+
use Nextcloud\Rector\Set\NextcloudSets;
1011
use Rector\Config\RectorConfig;
1112
use Rector\PHPUnit\Set\PHPUnitSetList;
1213
use Rector\TypeDeclaration\Rector\Class_\AddTestsVoidReturnTypeWhereNoReturnRector;
@@ -24,6 +25,7 @@
2425
)
2526
->withSets([
2627
PHPUnitSetList::PHPUNIT_90,
28+
NextcloudSets::NEXTCLOUD_30,
2729
])
2830
->withPhpSets(
2931
php74: true,

tests/Integration/Migration/MigrateImportantFromImapAndDbTest.php

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,8 @@ protected function setUp(): void {
4444
}
4545

4646
public function testMigrateImportantOnImap() {
47-
$account = $this->createMock(Account::class);
48-
$mailbox = $this->createMock(Mailbox::class);
47+
$account = $this->createStub(Account::class);
48+
$mailbox = $this->createStub(Mailbox::class);
4949
$uids = [1,2,3];
5050

5151
$this->messageMapper->expects($this->once())
@@ -62,8 +62,8 @@ public function testMigrateImportantOnImap() {
6262
}
6363

6464
public function testMigrateImportantOnImapNoUids() {
65-
$account = $this->createMock(Account::class);
66-
$mailbox = $this->createMock(Mailbox::class);
65+
$account = $this->createStub(Account::class);
66+
$mailbox = $this->createStub(Mailbox::class);
6767
$uids = [];
6868

6969
$this->messageMapper->expects($this->once())
@@ -79,8 +79,8 @@ public function testMigrateImportantOnImapNoUids() {
7979
}
8080

8181
public function testMigrateImportantOnImapExceptionGetFlagged() {
82-
$account = $this->createMock(Account::class);
83-
$mailbox = $this->createMock(Mailbox::class);
82+
$account = $this->createStub(Account::class);
83+
$mailbox = $this->createStub(Mailbox::class);
8484
$e = new Horde_Imap_Client_Exception('');
8585

8686
$this->messageMapper->expects($this->once())
@@ -97,7 +97,7 @@ public function testMigrateImportantOnImapExceptionGetFlagged() {
9797
}
9898

9999
public function testMigrateImportantOnImapExceptionOnFlag() {
100-
$account = $this->createMock(Account::class);
100+
$account = $this->createStub(Account::class);
101101
$mailbox = new Mailbox();
102102
$mailbox->setName('INBOX');
103103
$e = new Horde_Imap_Client_Exception('');
@@ -139,7 +139,7 @@ public function migrateImportantFromDb() {
139139
}
140140

141141
public function testMigrateImportantFromDbNoUids() {
142-
$account = $this->createMock(Account::class);
142+
$account = $this->createStub(Account::class);
143143
$mailbox = new Mailbox();
144144
$mailbox->setId(1);
145145
$uids = [];
@@ -157,7 +157,7 @@ public function testMigrateImportantFromDbNoUids() {
157157
}
158158

159159
public function testMigrateImportantFromDbExceptionOnFlag() {
160-
$account = $this->createMock(Account::class);
160+
$account = $this->createStub(Account::class);
161161
$mailbox = new Mailbox();
162162
$mailbox->setId(1);
163163
$mailbox->setName('INBOX');

tests/Integration/UserMigration/MailAccountMigratorIntegrationTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ public function testMigrate(): void {
6161
return $exportContents[$path];
6262
});
6363

64-
$output = $this->createMock(OutputInterface::class);
64+
$output = $this->createStub(OutputInterface::class);
6565

6666
$this->migrator->export(
6767
$sourceUser,

tests/Unit/BackgroundJob/QuotaJobTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ public function testUserDoesntExist(): void {
8585
->method('findById')
8686
->with(123)
8787
->willReturn($account);
88-
$user = $this->createMock(IUser::class);
88+
$user = $this->createStub(IUser::class);
8989
$this->serviceMock->getParameter('userManager')
9090
->expects(self::once())
9191
->method('get')

tests/Unit/BackgroundJob/SyncJobTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ public function testUserDoesntExist(): void {
116116
->method('findById')
117117
->with(123)
118118
->willReturn($account);
119-
$user = $this->createMock(IUser::class);
119+
$user = $this->createStub(IUser::class);
120120
$this->serviceMock->getParameter('userManager')
121121
->expects(self::once())
122122
->method('get')

tests/Unit/Controller/AccountsControllerTest.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -239,7 +239,7 @@ public function testCreateManualSuccess(): void {
239239
$smtpSslMode = 'none';
240240
$smtpUser = 'user@domain.tld';
241241
$smtpPassword = 'mypassword';
242-
$account = $this->createMock(Account::class);
242+
$account = $this->createStub(Account::class);
243243
$this->setupService->expects(self::once())
244244
->method('createNewAccount')
245245
->with($accountName, $email, $imapHost, $imapPort, $imapSslMode, $imapUser, $imapPassword, $smtpHost, $smtpPort, $smtpSslMode, $smtpUser, $smtpPassword, $this->userId, 'password')
@@ -316,7 +316,7 @@ public function testUpdateManualSuccess(): void {
316316
$smtpSslMode = 'none';
317317
$smtpUser = 'user@domain.tld';
318318
$smtpPassword = 'mypassword';
319-
$account = $this->createMock(Account::class);
319+
$account = $this->createStub(Account::class);
320320
$this->setupService->expects(self::once())
321321
->method('createNewAccount')
322322
->with($accountName, $email, $imapHost, $imapPort, $imapSslMode, $imapUser, $imapPassword, $smtpHost, $smtpPort, $smtpSslMode, $smtpUser, $smtpPassword, $this->userId, 'password', $id)
@@ -370,7 +370,7 @@ public function testDraft(): void {
370370
$id = 123;
371371
$newId = 1245;
372372
$newUid = 124;
373-
$account = $this->createMock(Account::class);
373+
$account = $this->createStub(Account::class);
374374
$mailbox = new Mailbox();
375375
$this->accountService->expects(self::once())
376376
->method('find')

tests/Unit/Controller/MailboxesApiControllerTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,8 +74,8 @@ public function testListMailboxesWithoutUser() {
7474

7575

7676
public function testListMailboxes() {
77-
$account = $this->createMock(Account::class);
78-
$folder = $this->createMock(Folder::class);
77+
$account = $this->createStub(Account::class);
78+
$folder = $this->createStub(Folder::class);
7979
$accountId = 42;
8080
$this->accountService->expects($this->once())
8181
->method('find')

tests/Unit/Controller/MailboxesControllerTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ public function testShow() {
113113
}
114114

115115
public function testCreate() {
116-
$account = $this->createMock(Account::class);
116+
$account = $this->createStub(Account::class);
117117
$mailbox = new Mailbox();
118118
$accountId = 28;
119119
$this->accountService->expects($this->once())

tests/Unit/Controller/MessagesControllerTest.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -234,8 +234,8 @@ public function testGetHtmlBody(): void {
234234
->method('find')
235235
->with($this->equalTo($this->userId), $this->equalTo($accountId))
236236
->will($this->returnValue($this->account));
237-
$client = $this->createMock(Horde_Imap_Client_Socket::class);
238-
$imapMessage = $this->createMock(IMAPMessage::class);
237+
$client = $this->createStub(Horde_Imap_Client_Socket::class);
238+
$imapMessage = $this->createStub(IMAPMessage::class);
239239
$this->mailManager->expects($this->exactly(2))
240240
->method('getImapMessage')
241241
->with($client, $this->account, $mailbox, 123, true)
@@ -409,7 +409,7 @@ public function testSaveAllAttachments() {
409409
$mailbox = new \OCA\Mail\Db\Mailbox();
410410
$mailbox->setName('INBOX');
411411
$mailbox->setAccountId($accountId);
412-
$client = $this->createMock(Horde_Imap_Client_Socket::class);
412+
$client = $this->createStub(Horde_Imap_Client_Socket::class);
413413
$this->mailManager->expects($this->once())
414414
->method('getMessage')
415415
->with($this->userId, $id)
@@ -1109,7 +1109,7 @@ public function testExport() {
11091109
->with($this->equalTo($this->userId), $this->equalTo($accountId))
11101110
->will($this->returnValue($this->account));
11111111
$source = file_get_contents(__DIR__ . '/../../data/mail-message-123.txt');
1112-
$client = $this->createMock(Horde_Imap_Client_Socket::class);
1112+
$client = $this->createStub(Horde_Imap_Client_Socket::class);
11131113
$this->mailManager->expects($this->exactly(1))
11141114
->method('getSource')
11151115
->with($client, $this->account, $folderId, 123)

tests/Unit/Controller/OutOfOfficeControllerTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,8 @@ public function testFollowSystem(bool $followSystem): void {
5353
->with(IAvailabilityCoordinator::class)
5454
->willReturn(true);
5555

56-
$user = $this->createMock(IUser::class);
57-
$state = $this->createMock(OutOfOfficeState::class);
56+
$user = $this->createStub(IUser::class);
57+
$state = $this->createStub(OutOfOfficeState::class);
5858

5959
$mailAccount = new MailAccount();
6060
$mailAccount->setId(1);

0 commit comments

Comments
 (0)