Skip to content

Commit f60c1a3

Browse files
committed
Fix many tests and warnings
Signed-off-by: Carl Schwan <carl@carlschwan.eu>
1 parent d4c354a commit f60c1a3

12 files changed

Lines changed: 41 additions & 110 deletions

File tree

apps/dav/tests/unit/Controller/DirectControllerTest.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@
3838
use OCP\Files\Folder;
3939
use OCP\Files\IRootFolder;
4040
use OCP\IRequest;
41-
use OCP\IURLGenerator;
41+
use OCP\IUrlGenerator;
4242
use OCP\Security\ISecureRandom;
4343
use Test\TestCase;
4444

@@ -56,7 +56,7 @@ class DirectControllerTest extends TestCase {
5656
/** @var ITimeFactory|\PHPUnit\Framework\MockObject\MockObject */
5757
private $timeFactory;
5858

59-
/** @var IURLGenerator|\PHPUnit\Framework\MockObject\MockObject */
59+
/** @var IUrlGenerator|\PHPUnit\Framework\MockObject\MockObject */
6060
private $urlGenerator;
6161

6262
/** @var DirectController */
@@ -69,7 +69,7 @@ protected function setUp(): void {
6969
$this->directMapper = $this->createMock(DirectMapper::class);
7070
$this->random = $this->createMock(ISecureRandom::class);
7171
$this->timeFactory = $this->createMock(ITimeFactory::class);
72-
$this->urlGenerator = $this->createMock(IURLGenerator::class);
72+
$this->urlGenerator = $this->createMock(IUrlGenerator::class);
7373

7474
$this->controller = new DirectController(
7575
'dav',
@@ -83,7 +83,7 @@ protected function setUp(): void {
8383
);
8484
}
8585

86-
public function testGetUrlNonExistingFileId() {
86+
public function testGetUrlNonExistingFileId(): void {
8787
$userFolder = $this->createMock(Folder::class);
8888
$this->rootFolder->method('getUserFolder')
8989
->with('awesomeUser')

apps/files_trashbin/tests/BackgroundJob/ExpireTrashTest.php

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -48,9 +48,6 @@ class ExpireTrashTest extends TestCase {
4848
/** @var IJobList|MockObject */
4949
private $jobList;
5050

51-
/** @var LoggerInterface|MockObject */
52-
private $logger;
53-
5451
/** @var ITimeFactory|MockObject */
5552
private $time;
5653

@@ -61,8 +58,10 @@ protected function setUp(): void {
6158
$this->userManager = $this->createMock(IUserManager::class);
6259
$this->expiration = $this->createMock(Expiration::class);
6360
$this->jobList = $this->createMock(IJobList::class);
64-
$this->logger = $this->createMock(ILogger::class);
61+
6562
$this->time = $this->createMock(ITimeFactory::class);
63+
$this->time->method('getTime')
64+
->willReturn(99999999999);
6665

6766
$this->jobList->expects($this->once())
6867
->method('setLastRun');
@@ -71,8 +70,12 @@ protected function setUp(): void {
7170
}
7271

7372
public function testConstructAndRun(): void {
74-
$job = new ExpireTrash($this->config, $this->userManager, $this->expiration);
75-
$job->execute($this->jobList, $this->logger);
73+
$this->config->method('getAppValue')
74+
->with('files_trashbin', 'background_job_expire_trash', 'yes')
75+
->willReturn('yes');
76+
77+
$job = new ExpireTrash($this->config, $this->userManager, $this->expiration, $this->time);
78+
$job->start($this->jobList);
7679
}
7780

7881
public function testBackgroundJobDeactivated(): void {

apps/files_versions/tests/BackgroundJob/ExpireVersionsTest.php

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@
2828
use OCP\AppFramework\Utility\ITimeFactory;
2929
use OCP\BackgroundJob\IJobList;
3030
use OCP\IConfig;
31-
use OCP\ILogger;
3231
use OCP\IUserManager;
3332
use PHPUnit\Framework\MockObject\MockObject;
3433
use Test\TestCase;
@@ -68,7 +67,12 @@ public function testBackgroundJobDeactivated(): void {
6867
$this->expiration->expects($this->never())
6968
->method('getMaxAgeAsTimestamp');
7069

71-
$job = new ExpireVersions($this->config, $this->userManager, $this->expiration, $this->createMock(ITimeFactory::class));
70+
$timeFactory = $this->createMock(ITimeFactory::class);
71+
$timeFactory->method('getTime')
72+
->with()
73+
->willReturn(99999999999);
74+
75+
$job = new ExpireVersions($this->config, $this->userManager, $this->expiration, $timeFactory);
7276
$job->start($this->jobList);
7377
}
7478
}

apps/updatenotification/tests/Settings/AdminTest.php

Lines changed: 18 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -36,13 +36,16 @@
3636
use OCP\IDateTimeFormatter;
3737
use OCP\IGroup;
3838
use OCP\IGroupManager;
39+
use OCP\IUserManager;
3940
use OCP\L10N\IFactory;
4041
use OCP\L10N\ILanguageIterator;
4142
use OCP\Support\Subscription\IRegistry;
43+
use OCP\UserInterface;
44+
use OCP\User\Backend\ICountUsersBackend;
4245
use OCP\Util;
43-
use Test\TestCase;
44-
use OCP\IUserManager;
46+
use OC\User\Backend;
4547
use Psr\Log\LoggerInterface;
48+
use Test\TestCase;
4649

4750
class AdminTest extends TestCase {
4851
/** @var IFactory|\PHPUnit\Framework\MockObject\MockObject */
@@ -89,9 +92,9 @@ protected function setUp(): void {
8992
}
9093

9194
public function testGetFormWithUpdate() {
92-
$backend1 = $this->createMock(UserInterface::class);
93-
$backend2 = $this->createMock(UserInterface::class);
94-
$backend3 = $this->createMock(UserInterface::class);
95+
$backend1 = $this->createMock(CountUsersBackend::class);
96+
$backend2 = $this->createMock(CountUsersBackend::class);
97+
$backend3 = $this->createMock(CountUsersBackend::class);
9598
$backend1
9699
->expects($this->once())
97100
->method('implementsActions')
@@ -213,9 +216,9 @@ public function testGetFormWithUpdate() {
213216
}
214217

215218
public function testGetFormWithUpdateAndChangedUpdateServer() {
216-
$backend1 = $this->createMock(UserInterface::class);
217-
$backend2 = $this->createMock(UserInterface::class);
218-
$backend3 = $this->createMock(UserInterface::class);
219+
$backend1 = $this->createMock(CountUsersBackend::class);
220+
$backend2 = $this->createMock(CountUsersBackend::class);
221+
$backend3 = $this->createMock(CountUsersBackend::class);
219222
$backend1
220223
->expects($this->once())
221224
->method('implementsActions')
@@ -337,9 +340,9 @@ public function testGetFormWithUpdateAndChangedUpdateServer() {
337340
}
338341

339342
public function testGetFormWithUpdateAndCustomersUpdateServer() {
340-
$backend1 = $this->createMock(UserInterface::class);
341-
$backend2 = $this->createMock(UserInterface::class);
342-
$backend3 = $this->createMock(UserInterface::class);
343+
$backend1 = $this->createMock(CountUsersBackend::class);
344+
$backend2 = $this->createMock(CountUsersBackend::class);
345+
$backend3 = $this->createMock(CountUsersBackend::class);
343346
$backend1
344347
->expects($this->once())
345348
->method('implementsActions')
@@ -543,3 +546,7 @@ public function testFilterChanges($changes, $userLang, $expectation) {
543546
$this->assertSame($expectation, $result);
544547
}
545548
}
549+
550+
abstract class CountUsersBackend implements UserInterface, ICountUsersBackend {
551+
552+
}

lib/composer/composer/autoload_classmap.php

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -798,8 +798,6 @@
798798
'OC\\Avatar\\UserAvatar' => $baseDir . '/lib/private/Avatar/UserAvatar.php',
799799
'OC\\BackgroundJob\\Job' => $baseDir . '/lib/private/BackgroundJob/Job.php',
800800
'OC\\BackgroundJob\\JobList' => $baseDir . '/lib/private/BackgroundJob/JobList.php',
801-
'OC\\BackgroundJob\\Legacy\\QueuedJob' => $baseDir . '/lib/private/BackgroundJob/Legacy/QueuedJob.php',
802-
'OC\\BackgroundJob\\Legacy\\RegularJob' => $baseDir . '/lib/private/BackgroundJob/Legacy/RegularJob.php',
803801
'OC\\BackgroundJob\\QueuedJob' => $baseDir . '/lib/private/BackgroundJob/QueuedJob.php',
804802
'OC\\BackgroundJob\\TimedJob' => $baseDir . '/lib/private/BackgroundJob/TimedJob.php',
805803
'OC\\Broadcast\\Events\\BroadcastEvent' => $baseDir . '/lib/private/Broadcast/Events/BroadcastEvent.php',

lib/composer/composer/autoload_static.php

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -831,8 +831,6 @@ class ComposerStaticInit749170dad3f5e7f9ca158f5a9f04f6a2
831831
'OC\\Avatar\\UserAvatar' => __DIR__ . '/../../..' . '/lib/private/Avatar/UserAvatar.php',
832832
'OC\\BackgroundJob\\Job' => __DIR__ . '/../../..' . '/lib/private/BackgroundJob/Job.php',
833833
'OC\\BackgroundJob\\JobList' => __DIR__ . '/../../..' . '/lib/private/BackgroundJob/JobList.php',
834-
'OC\\BackgroundJob\\Legacy\\QueuedJob' => __DIR__ . '/../../..' . '/lib/private/BackgroundJob/Legacy/QueuedJob.php',
835-
'OC\\BackgroundJob\\Legacy\\RegularJob' => __DIR__ . '/../../..' . '/lib/private/BackgroundJob/Legacy/RegularJob.php',
836834
'OC\\BackgroundJob\\QueuedJob' => __DIR__ . '/../../..' . '/lib/private/BackgroundJob/QueuedJob.php',
837835
'OC\\BackgroundJob\\TimedJob' => __DIR__ . '/../../..' . '/lib/private/BackgroundJob/TimedJob.php',
838836
'OC\\Broadcast\\Events\\BroadcastEvent' => __DIR__ . '/../../..' . '/lib/private/Broadcast/Events/BroadcastEvent.php',

lib/private/BackgroundJob/Legacy/QueuedJob.php

Lines changed: 0 additions & 38 deletions
This file was deleted.

lib/private/BackgroundJob/Legacy/RegularJob.php

Lines changed: 0 additions & 41 deletions
This file was deleted.

lib/private/Command/CallableJob.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
*/
2222
namespace OC\Command;
2323

24-
use OCP\BackgroundJob\QueuedJob;
24+
use OC\BackgroundJob\QueuedJob;
2525

2626
class CallableJob extends QueuedJob {
2727
protected function run($serializedCallable) {

lib/private/Command/ClosureJob.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
*/
2323
namespace OC\Command;
2424

25-
use OCP\BackgroundJob\QueuedJob;
25+
use OC\BackgroundJob\QueuedJob;
2626
use Laravel\SerializableClosure\SerializableClosure as LaravelClosure;
2727
use Opis\Closure\SerializableClosure as OpisClosure;
2828

0 commit comments

Comments
 (0)