Skip to content

Commit d03bb36

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

File tree

10 files changed

+38
-102
lines changed

10 files changed

+38
-102
lines changed

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/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
/**

tests/Core/Controller/AvatarControllerTest.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ function is_uploaded_file($filename) {
3535
use OC\Core\Controller\AvatarController;
3636
use OCP\AppFramework\Http;
3737
use OCP\Files\File;
38+
use OCP\Files\SimpleFS\ISimpleFile;
3839
use OCP\Files\IRootFolder;
3940
use OCP\Files\NotFoundException;
4041
use OCP\Files\NotPermittedException;

tests/lib/App/DependencyAnalyzerTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ protected function setUp(): void {
3535
->willReturn('5.4.3');
3636
$this->platformMock->expects($this->any())
3737
->method('getIntSize')
38-
->willReturn('4');
38+
->willReturn(4);
3939
$this->platformMock->expects($this->any())
4040
->method('getDatabase')
4141
->willReturn('mysql');

0 commit comments

Comments
 (0)