Skip to content

Commit 49334e4

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

11 files changed

Lines changed: 37 additions & 106 deletions

File tree

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
@@ -801,8 +801,6 @@
801801
'OC\\Avatar\\UserAvatar' => $baseDir . '/lib/private/Avatar/UserAvatar.php',
802802
'OC\\BackgroundJob\\Job' => $baseDir . '/lib/private/BackgroundJob/Job.php',
803803
'OC\\BackgroundJob\\JobList' => $baseDir . '/lib/private/BackgroundJob/JobList.php',
804-
'OC\\BackgroundJob\\Legacy\\QueuedJob' => $baseDir . '/lib/private/BackgroundJob/Legacy/QueuedJob.php',
805-
'OC\\BackgroundJob\\Legacy\\RegularJob' => $baseDir . '/lib/private/BackgroundJob/Legacy/RegularJob.php',
806804
'OC\\BackgroundJob\\QueuedJob' => $baseDir . '/lib/private/BackgroundJob/QueuedJob.php',
807805
'OC\\BackgroundJob\\TimedJob' => $baseDir . '/lib/private/BackgroundJob/TimedJob.php',
808806
'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
@@ -834,8 +834,6 @@ class ComposerStaticInit749170dad3f5e7f9ca158f5a9f04f6a2
834834
'OC\\Avatar\\UserAvatar' => __DIR__ . '/../../..' . '/lib/private/Avatar/UserAvatar.php',
835835
'OC\\BackgroundJob\\Job' => __DIR__ . '/../../..' . '/lib/private/BackgroundJob/Job.php',
836836
'OC\\BackgroundJob\\JobList' => __DIR__ . '/../../..' . '/lib/private/BackgroundJob/JobList.php',
837-
'OC\\BackgroundJob\\Legacy\\QueuedJob' => __DIR__ . '/../../..' . '/lib/private/BackgroundJob/Legacy/QueuedJob.php',
838-
'OC\\BackgroundJob\\Legacy\\RegularJob' => __DIR__ . '/../../..' . '/lib/private/BackgroundJob/Legacy/RegularJob.php',
839837
'OC\\BackgroundJob\\QueuedJob' => __DIR__ . '/../../..' . '/lib/private/BackgroundJob/QueuedJob.php',
840838
'OC\\BackgroundJob\\TimedJob' => __DIR__ . '/../../..' . '/lib/private/BackgroundJob/TimedJob.php',
841839
'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

lib/private/Command/CommandJob.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 OCP\Command\ICommand;
2727

2828
/**

0 commit comments

Comments
 (0)