Fix many tests and warnings

Signed-off-by: Carl Schwan <carl@carlschwan.eu>
pull/33047/head
Carl Schwan 2 years ago
parent 48d9c4d2b0
commit 49334e4d9c
No known key found for this signature in database
GPG Key ID: C3AA6B3A5EFA7AC5

@ -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 @@ class ExpireTrashTest extends TestCase {
$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 @@ class ExpireTrashTest extends TestCase {
}
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 {

@ -28,7 +28,6 @@ use OCA\Files_Versions\Expiration;
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 @@ class ExpireVersionsTest extends TestCase {
$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);
}
}

@ -36,13 +36,16 @@ use OCP\IConfig;
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 @@ class AdminTest extends TestCase {
}
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 @@ class AdminTest extends TestCase {
}
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 @@ class AdminTest extends TestCase {
}
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 @@ class AdminTest extends TestCase {
$this->assertSame($expectation, $result);
}
}
abstract class CountUsersBackend implements UserInterface, ICountUsersBackend {
}

@ -801,8 +801,6 @@ return array(
'OC\\Avatar\\UserAvatar' => $baseDir . '/lib/private/Avatar/UserAvatar.php',
'OC\\BackgroundJob\\Job' => $baseDir . '/lib/private/BackgroundJob/Job.php',
'OC\\BackgroundJob\\JobList' => $baseDir . '/lib/private/BackgroundJob/JobList.php',
'OC\\BackgroundJob\\Legacy\\QueuedJob' => $baseDir . '/lib/private/BackgroundJob/Legacy/QueuedJob.php',
'OC\\BackgroundJob\\Legacy\\RegularJob' => $baseDir . '/lib/private/BackgroundJob/Legacy/RegularJob.php',
'OC\\BackgroundJob\\QueuedJob' => $baseDir . '/lib/private/BackgroundJob/QueuedJob.php',
'OC\\BackgroundJob\\TimedJob' => $baseDir . '/lib/private/BackgroundJob/TimedJob.php',
'OC\\Broadcast\\Events\\BroadcastEvent' => $baseDir . '/lib/private/Broadcast/Events/BroadcastEvent.php',

@ -834,8 +834,6 @@ class ComposerStaticInit749170dad3f5e7f9ca158f5a9f04f6a2
'OC\\Avatar\\UserAvatar' => __DIR__ . '/../../..' . '/lib/private/Avatar/UserAvatar.php',
'OC\\BackgroundJob\\Job' => __DIR__ . '/../../..' . '/lib/private/BackgroundJob/Job.php',
'OC\\BackgroundJob\\JobList' => __DIR__ . '/../../..' . '/lib/private/BackgroundJob/JobList.php',
'OC\\BackgroundJob\\Legacy\\QueuedJob' => __DIR__ . '/../../..' . '/lib/private/BackgroundJob/Legacy/QueuedJob.php',
'OC\\BackgroundJob\\Legacy\\RegularJob' => __DIR__ . '/../../..' . '/lib/private/BackgroundJob/Legacy/RegularJob.php',
'OC\\BackgroundJob\\QueuedJob' => __DIR__ . '/../../..' . '/lib/private/BackgroundJob/QueuedJob.php',
'OC\\BackgroundJob\\TimedJob' => __DIR__ . '/../../..' . '/lib/private/BackgroundJob/TimedJob.php',
'OC\\Broadcast\\Events\\BroadcastEvent' => __DIR__ . '/../../..' . '/lib/private/Broadcast/Events/BroadcastEvent.php',

@ -1,38 +0,0 @@
<?php
/**
* @copyright Copyright (c) 2016, ownCloud, Inc.
*
* @author Christoph Wurst <christoph@winzerhof-wurst.at>
* @author Morris Jobke <hey@morrisjobke.de>
* @author Robin Appelman <robin@icewind.nl>
*
* @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 <http://www.gnu.org/licenses/>
*
*/
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);
}
}
}

@ -1,41 +0,0 @@
<?php
/**
* @copyright Copyright (c) 2016, ownCloud, Inc.
*
* @author Morris Jobke <hey@morrisjobke.de>
* @author Robin Appelman <robin@icewind.nl>
*
* @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 <http://www.gnu.org/licenses/>
*
*/
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;
}
}
}

@ -21,7 +21,7 @@
*/
namespace OC\Command;
use OCP\BackgroundJob\QueuedJob;
use OC\BackgroundJob\QueuedJob;
class CallableJob extends QueuedJob {
protected function run($serializedCallable) {

@ -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;

@ -22,7 +22,7 @@
*/
namespace OC\Command;
use OCP\BackgroundJob\QueuedJob;
use OC\BackgroundJob\QueuedJob;
use OCP\Command\ICommand;
/**

@ -35,7 +35,7 @@ class DependencyAnalyzerTest extends TestCase {
->willReturn('5.4.3');
$this->platformMock->expects($this->any())
->method('getIntSize')
->willReturn('4');
->willReturn(4);
$this->platformMock->expects($this->any())
->method('getDatabase')
->willReturn('mysql');

Loading…
Cancel
Save