diff --git a/apps/files_trashbin/tests/BackgroundJob/ExpireTrashTest.php b/apps/files_trashbin/tests/BackgroundJob/ExpireTrashTest.php index d8cce61ca523e..bf5d6bc65ae9e 100644 --- a/apps/files_trashbin/tests/BackgroundJob/ExpireTrashTest.php +++ b/apps/files_trashbin/tests/BackgroundJob/ExpireTrashTest.php @@ -48,9 +48,6 @@ class ExpireTrashTest extends TestCase { /** @var IJobList|MockObject */ private $jobList; - /** @var LoggerInterface|MockObject */ - private $logger; - /** @var ITimeFactory|MockObject */ private $time; @@ -61,8 +58,10 @@ protected function setUp(): void { $this->userManager = $this->createMock(IUserManager::class); $this->expiration = $this->createMock(Expiration::class); $this->jobList = $this->createMock(IJobList::class); - $this->logger = $this->createMock(ILogger::class); + $this->time = $this->createMock(ITimeFactory::class); + $this->time->method('getTime') + ->willReturn(99999999999); $this->jobList->expects($this->once()) ->method('setLastRun'); @@ -71,8 +70,12 @@ protected function setUp(): void { } public function testConstructAndRun(): void { - $job = new ExpireTrash($this->config, $this->userManager, $this->expiration); - $job->execute($this->jobList, $this->logger); + $this->config->method('getAppValue') + ->with('files_trashbin', 'background_job_expire_trash', 'yes') + ->willReturn('yes'); + + $job = new ExpireTrash($this->config, $this->userManager, $this->expiration, $this->time); + $job->start($this->jobList); } public function testBackgroundJobDeactivated(): void { diff --git a/apps/files_versions/tests/BackgroundJob/ExpireVersionsTest.php b/apps/files_versions/tests/BackgroundJob/ExpireVersionsTest.php index ca584ae9f5390..442a7020d8959 100644 --- a/apps/files_versions/tests/BackgroundJob/ExpireVersionsTest.php +++ b/apps/files_versions/tests/BackgroundJob/ExpireVersionsTest.php @@ -28,7 +28,6 @@ use OCP\AppFramework\Utility\ITimeFactory; use OCP\BackgroundJob\IJobList; use OCP\IConfig; -use OCP\ILogger; use OCP\IUserManager; use PHPUnit\Framework\MockObject\MockObject; use Test\TestCase; @@ -68,7 +67,12 @@ public function testBackgroundJobDeactivated(): void { $this->expiration->expects($this->never()) ->method('getMaxAgeAsTimestamp'); - $job = new ExpireVersions($this->config, $this->userManager, $this->expiration, $this->createMock(ITimeFactory::class)); + $timeFactory = $this->createMock(ITimeFactory::class); + $timeFactory->method('getTime') + ->with() + ->willReturn(99999999999); + + $job = new ExpireVersions($this->config, $this->userManager, $this->expiration, $timeFactory); $job->start($this->jobList); } } diff --git a/apps/updatenotification/tests/Settings/AdminTest.php b/apps/updatenotification/tests/Settings/AdminTest.php index 852504fb45aa4..489679dfabd8d 100644 --- a/apps/updatenotification/tests/Settings/AdminTest.php +++ b/apps/updatenotification/tests/Settings/AdminTest.php @@ -36,13 +36,16 @@ use OCP\IDateTimeFormatter; use OCP\IGroup; use OCP\IGroupManager; +use OCP\IUserManager; use OCP\L10N\IFactory; use OCP\L10N\ILanguageIterator; use OCP\Support\Subscription\IRegistry; +use OCP\UserInterface; +use OCP\User\Backend\ICountUsersBackend; use OCP\Util; -use Test\TestCase; -use OCP\IUserManager; +use OC\User\Backend; use Psr\Log\LoggerInterface; +use Test\TestCase; class AdminTest extends TestCase { /** @var IFactory|\PHPUnit\Framework\MockObject\MockObject */ @@ -89,9 +92,9 @@ protected function setUp(): void { } public function testGetFormWithUpdate() { - $backend1 = $this->createMock(UserInterface::class); - $backend2 = $this->createMock(UserInterface::class); - $backend3 = $this->createMock(UserInterface::class); + $backend1 = $this->createMock(CountUsersBackend::class); + $backend2 = $this->createMock(CountUsersBackend::class); + $backend3 = $this->createMock(CountUsersBackend::class); $backend1 ->expects($this->once()) ->method('implementsActions') @@ -213,9 +216,9 @@ public function testGetFormWithUpdate() { } public function testGetFormWithUpdateAndChangedUpdateServer() { - $backend1 = $this->createMock(UserInterface::class); - $backend2 = $this->createMock(UserInterface::class); - $backend3 = $this->createMock(UserInterface::class); + $backend1 = $this->createMock(CountUsersBackend::class); + $backend2 = $this->createMock(CountUsersBackend::class); + $backend3 = $this->createMock(CountUsersBackend::class); $backend1 ->expects($this->once()) ->method('implementsActions') @@ -337,9 +340,9 @@ public function testGetFormWithUpdateAndChangedUpdateServer() { } public function testGetFormWithUpdateAndCustomersUpdateServer() { - $backend1 = $this->createMock(UserInterface::class); - $backend2 = $this->createMock(UserInterface::class); - $backend3 = $this->createMock(UserInterface::class); + $backend1 = $this->createMock(CountUsersBackend::class); + $backend2 = $this->createMock(CountUsersBackend::class); + $backend3 = $this->createMock(CountUsersBackend::class); $backend1 ->expects($this->once()) ->method('implementsActions') @@ -543,3 +546,7 @@ public function testFilterChanges($changes, $userLang, $expectation) { $this->assertSame($expectation, $result); } } + +abstract class CountUsersBackend implements UserInterface, ICountUsersBackend { + +} diff --git a/lib/private/BackgroundJob/Legacy/QueuedJob.php b/lib/private/BackgroundJob/Legacy/QueuedJob.php deleted file mode 100644 index 680c12046c91e..0000000000000 --- a/lib/private/BackgroundJob/Legacy/QueuedJob.php +++ /dev/null @@ -1,38 +0,0 @@ - - * @author Morris Jobke - * @author Robin Appelman - * - * @license AGPL-3.0 - * - * This code is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License, version 3, - * as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License, version 3, - * along with this program. If not, see - * - */ -namespace OC\BackgroundJob\Legacy; - -/** - * @deprecated internal class, use \OCP\BackgroundJob\QueuedJob - */ -class QueuedJob extends \OCP\BackgroundJob\QueuedJob { - public function run($argument) { - $class = $argument['klass']; - $method = $argument['method']; - $parameters = $argument['parameters']; - if (is_callable([$class, $method])) { - call_user_func([$class, $method], $parameters); - } - } -} diff --git a/lib/private/BackgroundJob/Legacy/RegularJob.php b/lib/private/BackgroundJob/Legacy/RegularJob.php deleted file mode 100644 index c01d58efa2fba..0000000000000 --- a/lib/private/BackgroundJob/Legacy/RegularJob.php +++ /dev/null @@ -1,41 +0,0 @@ - - * @author Robin Appelman - * - * @license AGPL-3.0 - * - * This code is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License, version 3, - * as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License, version 3, - * along with this program. If not, see - * - */ -namespace OC\BackgroundJob\Legacy; - -use OCP\AutoloadNotAllowedException; - -/** - * @deprecated internal class, use \OCP\BackgroundJob\QueuedJob - */ -class RegularJob extends \OCP\BackgroundJob\Job { - public function run($argument) { - try { - if (is_callable($argument)) { - call_user_func($argument); - } - } catch (AutoloadNotAllowedException $e) { - // job is from a disabled app, ignore - return null; - } - } -} diff --git a/lib/private/Command/CallableJob.php b/lib/private/Command/CallableJob.php index 7f515660955e8..8bb3c76c9afad 100644 --- a/lib/private/Command/CallableJob.php +++ b/lib/private/Command/CallableJob.php @@ -21,7 +21,7 @@ */ namespace OC\Command; -use OCP\BackgroundJob\QueuedJob; +use OC\BackgroundJob\QueuedJob; class CallableJob extends QueuedJob { protected function run($serializedCallable) { diff --git a/lib/private/Command/ClosureJob.php b/lib/private/Command/ClosureJob.php index 7ca45cd5fc01d..5639852e4db89 100644 --- a/lib/private/Command/ClosureJob.php +++ b/lib/private/Command/ClosureJob.php @@ -22,7 +22,7 @@ */ namespace OC\Command; -use OCP\BackgroundJob\QueuedJob; +use OC\BackgroundJob\QueuedJob; use Laravel\SerializableClosure\SerializableClosure as LaravelClosure; use Opis\Closure\SerializableClosure as OpisClosure; diff --git a/lib/private/Command/CommandJob.php b/lib/private/Command/CommandJob.php index 477fd2a868333..5b267162c81a1 100644 --- a/lib/private/Command/CommandJob.php +++ b/lib/private/Command/CommandJob.php @@ -22,7 +22,7 @@ */ namespace OC\Command; -use OCP\BackgroundJob\QueuedJob; +use OC\BackgroundJob\QueuedJob; use OCP\Command\ICommand; /** diff --git a/tests/Core/Controller/AvatarControllerTest.php b/tests/Core/Controller/AvatarControllerTest.php index 256f566579520..4ef6266d632a6 100644 --- a/tests/Core/Controller/AvatarControllerTest.php +++ b/tests/Core/Controller/AvatarControllerTest.php @@ -35,10 +35,10 @@ function is_uploaded_file($filename) { use OC\Core\Controller\AvatarController; use OCP\AppFramework\Http; use OCP\Files\File; +use OCP\Files\SimpleFS\ISimpleFile; use OCP\Files\IRootFolder; use OCP\Files\NotFoundException; use OCP\Files\NotPermittedException; -use OCP\Files\SimpleFS\ISimpleFile; use OCP\IAvatar; use OCP\IAvatarManager; use OCP\ICache; diff --git a/tests/lib/App/DependencyAnalyzerTest.php b/tests/lib/App/DependencyAnalyzerTest.php index 1e37948d7834e..75cc991cf99a2 100644 --- a/tests/lib/App/DependencyAnalyzerTest.php +++ b/tests/lib/App/DependencyAnalyzerTest.php @@ -35,7 +35,7 @@ protected function setUp(): void { ->willReturn('5.4.3'); $this->platformMock->expects($this->any()) ->method('getIntSize') - ->willReturn('4'); + ->willReturn(4); $this->platformMock->expects($this->any()) ->method('getDatabase') ->willReturn('mysql');