mirror of
https://github.com/nextcloud/server.git
synced 2026-02-18 18:28:50 -05:00
refactor: Cleanup some unit tests
- use declare(strict_types=1) - use strong typing - Remove some weird things in ControllerTest Signed-off-by: Carl Schwan <carl.schwan@nextcloud.com>
This commit is contained in:
parent
e2a81709d0
commit
60c2875670
38 changed files with 138 additions and 169 deletions
|
|
@ -1,5 +1,7 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
/**
|
||||
* SPDX-FileCopyrightText: 2016-2024 Nextcloud GmbH and Nextcloud contributors
|
||||
* SPDX-FileCopyrightText: 2016 ownCloud, Inc.
|
||||
|
|
|
|||
|
|
@ -17,8 +17,7 @@ use PHPUnit\Framework\MockObject\MockObject;
|
|||
use Test\TestCase;
|
||||
|
||||
class AccountPropertyCollectionTest extends TestCase {
|
||||
/** @var IAccountPropertyCollection */
|
||||
protected $collection;
|
||||
protected IAccountPropertyCollection $collection;
|
||||
|
||||
protected const COLLECTION_NAME = 'my_multivalue_property';
|
||||
|
||||
|
|
@ -28,10 +27,7 @@ class AccountPropertyCollectionTest extends TestCase {
|
|||
$this->collection = new AccountPropertyCollection(self::COLLECTION_NAME);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return IAccountProperty|MockObject
|
||||
*/
|
||||
protected function makePropertyMock(string $propertyName): MockObject {
|
||||
protected function makePropertyMock(string $propertyName): IAccountProperty&MockObject {
|
||||
$mock = $this->createMock(IAccountProperty::class);
|
||||
$mock->expects($this->any())
|
||||
->method('getName')
|
||||
|
|
|
|||
|
|
@ -1,5 +1,7 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
/**
|
||||
* SPDX-FileCopyrightText: 2018 Nextcloud GmbH and Nextcloud contributors
|
||||
* SPDX-License-Identifier: AGPL-3.0-or-later
|
||||
|
|
|
|||
|
|
@ -1,5 +1,7 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
/**
|
||||
* SPDX-FileCopyrightText: 2018 Nextcloud GmbH and Nextcloud contributors
|
||||
* SPDX-License-Identifier: AGPL-3.0-or-later
|
||||
|
|
|
|||
|
|
@ -1,5 +1,7 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
/**
|
||||
* SPDX-FileCopyrightText: 2016 Nextcloud GmbH and Nextcloud contributors
|
||||
* SPDX-License-Identifier: AGPL-3.0-or-later
|
||||
|
|
@ -24,14 +26,10 @@ use Test\TestCase;
|
|||
* @group DB
|
||||
*/
|
||||
class HooksTest extends TestCase {
|
||||
/** @var LoggerInterface|MockObject */
|
||||
private $logger;
|
||||
|
||||
/** @var AccountManager|MockObject */
|
||||
private $accountManager;
|
||||
|
||||
/** @var Hooks */
|
||||
private $hooks;
|
||||
private LoggerInterface&MockObject $logger;
|
||||
private AccountManager&MockObject $accountManager;
|
||||
private Hooks $hooks;
|
||||
|
||||
protected function setUp(): void {
|
||||
parent::setUp();
|
||||
|
|
|
|||
|
|
@ -1,5 +1,7 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
/**
|
||||
* SPDX-FileCopyrightText: 2016-2024 Nextcloud GmbH and Nextcloud contributors
|
||||
* SPDX-FileCopyrightText: 2016 ownCloud, Inc.
|
||||
|
|
@ -8,6 +10,7 @@
|
|||
|
||||
namespace Test\Activity;
|
||||
|
||||
use OC\Activity\Manager;
|
||||
use OCP\Activity\Exceptions\IncompleteActivityException;
|
||||
use OCP\Activity\IConsumer;
|
||||
use OCP\Activity\IEvent;
|
||||
|
|
@ -23,8 +26,7 @@ use PHPUnit\Framework\MockObject\MockObject;
|
|||
use Test\TestCase;
|
||||
|
||||
class ManagerTest extends TestCase {
|
||||
/** @var \OC\Activity\Manager */
|
||||
private $activityManager;
|
||||
private Manager $activityManager;
|
||||
|
||||
protected IRequest&MockObject $request;
|
||||
protected IUserSession&MockObject $session;
|
||||
|
|
@ -43,7 +45,7 @@ class ManagerTest extends TestCase {
|
|||
$this->richTextFormatter = $this->createMock(IRichTextFormatter::class);
|
||||
$this->time = $this->createMock(ITimeFactory::class);
|
||||
|
||||
$this->activityManager = new \OC\Activity\Manager(
|
||||
$this->activityManager = new Manager(
|
||||
$this->request,
|
||||
$this->session,
|
||||
$this->config,
|
||||
|
|
|
|||
|
|
@ -1,5 +1,7 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
/**
|
||||
* SPDX-FileCopyrightText: 2017 Nextcloud GmbH and Nextcloud contributors
|
||||
* SPDX-License-Identifier: AGPL-3.0-or-later
|
||||
|
|
@ -9,19 +11,15 @@ namespace Test\App\AppStore\Bundles;
|
|||
|
||||
use OC\App\AppStore\Bundles\Bundle;
|
||||
use OCP\IL10N;
|
||||
use PHPUnit\Framework\MockObject\MockObject;
|
||||
use Test\TestCase;
|
||||
|
||||
abstract class BundleBase extends TestCase {
|
||||
/** @var IL10N|\PHPUnit\Framework\MockObject\MockObject */
|
||||
protected $l10n;
|
||||
/** @var Bundle */
|
||||
protected $bundle;
|
||||
/** @var string */
|
||||
protected $bundleIdentifier;
|
||||
/** @var string */
|
||||
protected $bundleName;
|
||||
/** @var array */
|
||||
protected $bundleAppIds;
|
||||
protected IL10N&MockObject $l10n;
|
||||
protected Bundle $bundle;
|
||||
protected string $bundleIdentifier;
|
||||
protected string $bundleName;
|
||||
protected array $bundleAppIds;
|
||||
|
||||
protected function setUp(): void {
|
||||
parent::setUp();
|
||||
|
|
|
|||
|
|
@ -1,5 +1,7 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
/**
|
||||
* SPDX-FileCopyrightText: 2017 Nextcloud GmbH and Nextcloud contributors
|
||||
* SPDX-License-Identifier: AGPL-3.0-or-later
|
||||
|
|
@ -15,13 +17,12 @@ use OC\App\AppStore\Bundles\HubBundle;
|
|||
use OC\App\AppStore\Bundles\PublicSectorBundle;
|
||||
use OC\App\AppStore\Bundles\SocialSharingBundle;
|
||||
use OCP\IL10N;
|
||||
use PHPUnit\Framework\MockObject\MockObject;
|
||||
use Test\TestCase;
|
||||
|
||||
class BundleFetcherTest extends TestCase {
|
||||
/** @var IL10N|\PHPUnit\Framework\MockObject\MockObject */
|
||||
private $l10n;
|
||||
/** @var BundleFetcher */
|
||||
private $bundleFetcher;
|
||||
private IL10N&MockObject $l10n;
|
||||
private BundleFetcher $bundleFetcher;
|
||||
|
||||
protected function setUp(): void {
|
||||
parent::setUp();
|
||||
|
|
|
|||
|
|
@ -1,5 +1,7 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
/**
|
||||
* SPDX-FileCopyrightText: 2017 Nextcloud GmbH and Nextcloud contributors
|
||||
* SPDX-License-Identifier: AGPL-3.0-or-later
|
||||
|
|
|
|||
|
|
@ -1,5 +1,7 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
/**
|
||||
* SPDX-FileCopyrightText: 2017 Nextcloud GmbH and Nextcloud contributors
|
||||
* SPDX-License-Identifier: AGPL-3.0-or-later
|
||||
|
|
|
|||
|
|
@ -1,5 +1,7 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
/**
|
||||
* SPDX-FileCopyrightText: 2017 Nextcloud GmbH and Nextcloud contributors
|
||||
* SPDX-License-Identifier: AGPL-3.0-or-later
|
||||
|
|
|
|||
|
|
@ -1,5 +1,7 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
/**
|
||||
* SPDX-FileCopyrightText: 2017 Nextcloud GmbH and Nextcloud contributors
|
||||
* SPDX-License-Identifier: AGPL-3.0-or-later
|
||||
|
|
|
|||
|
|
@ -1,5 +1,7 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
/**
|
||||
* SPDX-FileCopyrightText: 2024 Nextcloud GmbH and Nextcloud contributors
|
||||
* SPDX-License-Identifier: AGPL-3.0-or-later
|
||||
|
|
@ -15,7 +17,7 @@ use OCP\Files\SimpleFS\ISimpleFolder;
|
|||
use PHPUnit\Framework\MockObject\MockObject;
|
||||
|
||||
class AppDiscoverFetcherTest extends FetcherBase {
|
||||
protected CompareVersion|MockObject $compareVersion;
|
||||
protected CompareVersion&MockObject $compareVersion;
|
||||
|
||||
protected function setUp(): void {
|
||||
parent::setUp();
|
||||
|
|
|
|||
File diff suppressed because one or more lines are too long
|
|
@ -1,5 +1,7 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
/**
|
||||
* SPDX-FileCopyrightText: 2016 Nextcloud GmbH and Nextcloud contributors
|
||||
* SPDX-License-Identifier: AGPL-3.0-or-later
|
||||
|
|
|
|||
|
|
@ -1,5 +1,7 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
/**
|
||||
* SPDX-FileCopyrightText: 2016 Nextcloud GmbH and Nextcloud contributors
|
||||
* SPDX-License-Identifier: AGPL-3.0-or-later
|
||||
|
|
@ -20,30 +22,21 @@ use OCP\Http\Client\IClientService;
|
|||
use OCP\Http\Client\IResponse;
|
||||
use OCP\IConfig;
|
||||
use OCP\Support\Subscription\IRegistry;
|
||||
use PHPUnit\Framework\MockObject\MockObject;
|
||||
use Psr\Log\LoggerInterface;
|
||||
use Test\TestCase;
|
||||
|
||||
abstract class FetcherBase extends TestCase {
|
||||
/** @var Factory|\PHPUnit\Framework\MockObject\MockObject */
|
||||
protected $appDataFactory;
|
||||
/** @var IAppData|\PHPUnit\Framework\MockObject\MockObject */
|
||||
protected $appData;
|
||||
/** @var IClientService|\PHPUnit\Framework\MockObject\MockObject */
|
||||
protected $clientService;
|
||||
/** @var ITimeFactory|\PHPUnit\Framework\MockObject\MockObject */
|
||||
protected $timeFactory;
|
||||
/** @var IConfig|\PHPUnit\Framework\MockObject\MockObject */
|
||||
protected $config;
|
||||
/** @var LoggerInterface|\PHPUnit\Framework\MockObject\MockObject */
|
||||
protected $logger;
|
||||
/** @var IRegistry|\PHPUnit\Framework\MockObject\MockObject */
|
||||
protected $registry;
|
||||
/** @var Fetcher */
|
||||
protected $fetcher;
|
||||
/** @var string */
|
||||
protected $fileName;
|
||||
/** @var string */
|
||||
protected $endpoint;
|
||||
protected Factory&MockObject $appDataFactory;
|
||||
protected IAppData&MockObject $appData;
|
||||
protected IClientService&MockObject $clientService;
|
||||
protected ITimeFactory&MockObject $timeFactory;
|
||||
protected IConfig&MockObject $config;
|
||||
protected LoggerInterface&MockObject $logger;
|
||||
protected IRegistry&MockObject $registry;
|
||||
protected Fetcher $fetcher;
|
||||
protected string $fileName;
|
||||
protected string $endpoint;
|
||||
|
||||
protected function setUp(): void {
|
||||
parent::setUp();
|
||||
|
|
|
|||
|
|
@ -1,5 +1,7 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
/**
|
||||
* SPDX-FileCopyrightText: 2016 Nextcloud GmbH and Nextcloud contributors
|
||||
* SPDX-License-Identifier: AGPL-3.0-or-later
|
||||
|
|
@ -12,8 +14,7 @@ use OC\App\AppStore\Version\VersionParser;
|
|||
use Test\TestCase;
|
||||
|
||||
class VersionParserTest extends TestCase {
|
||||
/** @var VersionParser */
|
||||
private $versionParser;
|
||||
private VersionParser $versionParser;
|
||||
|
||||
protected function setUp(): void {
|
||||
parent::setUp();
|
||||
|
|
|
|||
|
|
@ -1,5 +1,7 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
/**
|
||||
* SPDX-FileCopyrightText: 2016 Nextcloud GmbH and Nextcloud contributors
|
||||
* SPDX-License-Identifier: AGPL-3.0-or-later
|
||||
|
|
|
|||
|
|
@ -14,8 +14,7 @@ use OC\App\CompareVersion;
|
|||
use Test\TestCase;
|
||||
|
||||
class CompareVersionTest extends TestCase {
|
||||
/** @var CompareVersion */
|
||||
private $compare;
|
||||
private CompareVersion $compare;
|
||||
|
||||
protected function setUp(): void {
|
||||
parent::setUp();
|
||||
|
|
|
|||
|
|
@ -1,5 +1,7 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
/**
|
||||
* SPDX-FileCopyrightText: 2016-2023 Nextcloud GmbH and Nextcloud contributors
|
||||
* SPDX-FileCopyrightText: 2014-2016 ownCloud, Inc.
|
||||
|
|
@ -9,11 +11,11 @@ namespace Test\App;
|
|||
|
||||
use OC\App\DependencyAnalyzer;
|
||||
use OC\App\Platform;
|
||||
use PHPUnit\Framework\MockObject\MockObject;
|
||||
use Test\TestCase;
|
||||
|
||||
class DependencyAnalyzerTest extends TestCase {
|
||||
/** @var Platform|\PHPUnit\Framework\MockObject\MockObject */
|
||||
private $platformMock;
|
||||
private Platform&MockObject $platformMock;
|
||||
|
||||
private DependencyAnalyzer $analyser;
|
||||
|
||||
|
|
|
|||
|
|
@ -1,5 +1,7 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
/**
|
||||
* SPDX-FileCopyrightText: 2016-2023 Nextcloud GmbH and Nextcloud contributors
|
||||
* SPDX-FileCopyrightText: 2014-2016 ownCloud, Inc.
|
||||
|
|
@ -13,8 +15,7 @@ use OCP\Cache\CappedMemoryCache;
|
|||
use Test\TestCase;
|
||||
|
||||
class InfoParserTest extends TestCase {
|
||||
/** @var CappedMemoryCache */
|
||||
private static $cache;
|
||||
private static CappedMemoryCache $cache;
|
||||
|
||||
public static function setUpBeforeClass(): void {
|
||||
self::$cache = new CappedMemoryCache();
|
||||
|
|
|
|||
|
|
@ -1,5 +1,7 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
/**
|
||||
* SPDX-FileCopyrightText: 2020-2023 Nextcloud GmbH and Nextcloud contributors
|
||||
* SPDX-FileCopyrightText: 2014-2016 ownCloud, Inc.
|
||||
|
|
@ -10,12 +12,8 @@ namespace Test\App;
|
|||
use OC\App\PlatformRepository;
|
||||
|
||||
class PlatformRepositoryTest extends \Test\TestCase {
|
||||
/**
|
||||
* @param $expected
|
||||
* @param $input
|
||||
*/
|
||||
#[\PHPUnit\Framework\Attributes\DataProvider('providesVersions')]
|
||||
public function testVersion($input, $expected): void {
|
||||
public function testVersion(string $input, string $expected): void {
|
||||
$pr = new PlatformRepository();
|
||||
$normalizedVersion = $pr->normalizeVersion($input);
|
||||
$this->assertEquals($expected, $normalizedVersion);
|
||||
|
|
|
|||
|
|
@ -16,11 +16,9 @@ use PHPUnit\Framework\MockObject\MockObject;
|
|||
use Test\TestCase;
|
||||
|
||||
class BootContextTest extends TestCase {
|
||||
/** @var IAppContainer|MockObject */
|
||||
private $appContainer;
|
||||
private IAppContainer&MockObject $appContainer;
|
||||
|
||||
/** @var BootContext */
|
||||
private $context;
|
||||
private BootContext $context;
|
||||
|
||||
protected function setUp(): void {
|
||||
parent::setUp();
|
||||
|
|
|
|||
|
|
@ -27,29 +27,14 @@ use Psr\Log\LoggerInterface;
|
|||
use Test\TestCase;
|
||||
|
||||
class CoordinatorTest extends TestCase {
|
||||
/** @var IAppManager|MockObject */
|
||||
private $appManager;
|
||||
|
||||
/** @var IServerContainer|MockObject */
|
||||
private $serverContainer;
|
||||
|
||||
/** @var Registry|MockObject */
|
||||
private $crashReporterRegistry;
|
||||
|
||||
/** @var IManager|MockObject */
|
||||
private $dashboardManager;
|
||||
|
||||
/** @var IEventDispatcher|MockObject */
|
||||
private $eventDispatcher;
|
||||
|
||||
/** @var IEventLogger|MockObject */
|
||||
private $eventLogger;
|
||||
|
||||
/** @var LoggerInterface|MockObject */
|
||||
private $logger;
|
||||
|
||||
/** @var Coordinator */
|
||||
private $coordinator;
|
||||
private IAppManager&MockObject $appManager;
|
||||
private IServerContainer&MockObject $serverContainer;
|
||||
private Registry&MockObject $crashReporterRegistry;
|
||||
private IManager&MockObject $dashboardManager;
|
||||
private IEventDispatcher&MockObject $eventDispatcher;
|
||||
private IEventLogger&MockObject $eventLogger;
|
||||
private LoggerInterface&MockObject $logger;
|
||||
private Coordinator $coordinator;
|
||||
|
||||
protected function setUp(): void {
|
||||
parent::setUp();
|
||||
|
|
|
|||
|
|
@ -11,15 +11,14 @@ namespace lib\AppFramework\Bootstrap;
|
|||
|
||||
use OC\AppFramework\Bootstrap\FunctionInjector;
|
||||
use OC\AppFramework\Utility\SimpleContainer;
|
||||
use OCP\AppFramework\QueryException;
|
||||
use Psr\Container\ContainerExceptionInterface;
|
||||
use Test\TestCase;
|
||||
|
||||
interface Foo {
|
||||
}
|
||||
|
||||
class FunctionInjectorTest extends TestCase {
|
||||
/** @var SimpleContainer */
|
||||
private $container;
|
||||
private SimpleContainer $container;
|
||||
|
||||
protected function setUp(): void {
|
||||
parent::setUp();
|
||||
|
|
@ -28,7 +27,7 @@ class FunctionInjectorTest extends TestCase {
|
|||
}
|
||||
|
||||
public function testInjectFnNotRegistered(): void {
|
||||
$this->expectException(QueryException::class);
|
||||
$this->expectException(ContainerExceptionInterface::class);
|
||||
|
||||
(new FunctionInjector($this->container))->injectFn(static function (Foo $p1): void {
|
||||
});
|
||||
|
|
|
|||
|
|
@ -20,11 +20,8 @@ use Psr\Log\LoggerInterface;
|
|||
use Test\TestCase;
|
||||
|
||||
class RegistrationContextTest extends TestCase {
|
||||
/** @var LoggerInterface|MockObject */
|
||||
private $logger;
|
||||
|
||||
/** @var RegistrationContext */
|
||||
private $context;
|
||||
private LoggerInterface&MockObject $logger;
|
||||
private RegistrationContext $context;
|
||||
|
||||
protected function setUp(): void {
|
||||
parent::setUp();
|
||||
|
|
|
|||
|
|
@ -1,5 +1,7 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
/**
|
||||
* SPDX-FileCopyrightText: 2016-2024 Nextcloud GmbH and Nextcloud contributors
|
||||
* SPDX-FileCopyrightText: 2016 ownCloud, Inc.
|
||||
|
|
@ -18,8 +20,7 @@ class ChildApiController extends ApiController {
|
|||
|
||||
|
||||
class ApiControllerTest extends \Test\TestCase {
|
||||
/** @var ChildApiController */
|
||||
protected $controller;
|
||||
protected ChildApiController $controller;
|
||||
|
||||
public function testCors(): void {
|
||||
$request = new Request(
|
||||
|
|
|
|||
|
|
@ -1,5 +1,7 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
/**
|
||||
* SPDX-FileCopyrightText: 2018 Nextcloud GmbH and Nextcloud contributors
|
||||
* SPDX-License-Identifier: AGPL-3.0-or-later
|
||||
|
|
@ -13,17 +15,13 @@ use OCP\AppFramework\Http\TemplateResponse;
|
|||
use OCP\IRequest;
|
||||
use OCP\ISession;
|
||||
use OCP\IURLGenerator;
|
||||
use PHPUnit\Framework\MockObject\MockObject;
|
||||
|
||||
class AuthPublicShareControllerTest extends \Test\TestCase {
|
||||
/** @var IRequest|\PHPUnit\Framework\MockObject\MockObject */
|
||||
private $request;
|
||||
/** @var ISession|\PHPUnit\Framework\MockObject\MockObject */
|
||||
private $session;
|
||||
/** @var IURLGenerator|\PHPUnit\Framework\MockObject\MockObject */
|
||||
private $urlGenerator;
|
||||
|
||||
/** @var AuthPublicShareController|\PHPUnit\Framework\MockObject\MockObject */
|
||||
private $controller;
|
||||
private IRequest&MockObject $request;
|
||||
private ISession&MockObject $session;
|
||||
private IURLGenerator&MockObject $urlGenerator;
|
||||
private AuthPublicShareController&MockObject $controller;
|
||||
|
||||
|
||||
protected function setUp(): void {
|
||||
|
|
|
|||
|
|
@ -8,7 +8,6 @@
|
|||
|
||||
namespace Test\AppFramework\Controller;
|
||||
|
||||
use OC\AppFramework\DependencyInjection\DIContainer;
|
||||
use OC\AppFramework\Http\Request;
|
||||
use OCP\AppFramework\Controller;
|
||||
use OCP\AppFramework\Http\DataResponse;
|
||||
|
|
@ -18,7 +17,7 @@ use OCP\IRequest;
|
|||
use OCP\IRequestId;
|
||||
|
||||
class ChildController extends Controller {
|
||||
public function __construct($appName, $request) {
|
||||
public function __construct(string $appName, IRequest $request) {
|
||||
parent::__construct($appName, $request);
|
||||
$this->registerResponder('tom', function ($respone) {
|
||||
return 'hi';
|
||||
|
|
@ -33,7 +32,7 @@ class ChildController extends Controller {
|
|||
return $in;
|
||||
}
|
||||
|
||||
public function customDataResponse($in) {
|
||||
public function customDataResponse(mixed $in): DataResponse {
|
||||
$response = new DataResponse($in, 300);
|
||||
$response->addHeader('test', 'something');
|
||||
return $response;
|
||||
|
|
@ -41,12 +40,8 @@ class ChildController extends Controller {
|
|||
};
|
||||
|
||||
class ControllerTest extends \Test\TestCase {
|
||||
/**
|
||||
* @var Controller
|
||||
*/
|
||||
private $controller;
|
||||
private $app;
|
||||
private $request;
|
||||
private Controller $controller;
|
||||
private Request $request;
|
||||
|
||||
protected function setUp(): void {
|
||||
parent::setUp();
|
||||
|
|
@ -65,15 +60,7 @@ class ControllerTest extends \Test\TestCase {
|
|||
$this->createMock(IConfig::class)
|
||||
);
|
||||
|
||||
$this->app = $this->getMockBuilder(DIContainer::class)
|
||||
->onlyMethods(['getAppName'])
|
||||
->setConstructorArgs(['test'])
|
||||
->getMock();
|
||||
$this->app->expects($this->any())
|
||||
->method('getAppName')
|
||||
->willReturn('apptemplate_advanced');
|
||||
|
||||
$this->controller = new ChildController($this->app, $request);
|
||||
$this->controller = new ChildController('apptemplate_advanced', $request);
|
||||
$this->overwriteService(IRequest::class, $request);
|
||||
$this->request = $request;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,7 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
/**
|
||||
* SPDX-FileCopyrightText: 2016-2024 Nextcloud GmbH and Nextcloud contributors
|
||||
* SPDX-FileCopyrightText: 2016 ownCloud, Inc.
|
||||
|
|
|
|||
|
|
@ -1,5 +1,7 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
/**
|
||||
* SPDX-FileCopyrightText: 2018 Nextcloud GmbH and Nextcloud contributors
|
||||
* SPDX-License-Identifier: AGPL-3.0-or-later
|
||||
|
|
@ -10,6 +12,7 @@ namespace Test\AppFramework\Controller;
|
|||
use OCP\AppFramework\PublicShareController;
|
||||
use OCP\IRequest;
|
||||
use OCP\ISession;
|
||||
use PHPUnit\Framework\MockObject\MockObject;
|
||||
|
||||
class TestController extends PublicShareController {
|
||||
public function __construct(
|
||||
|
|
@ -36,10 +39,8 @@ class TestController extends PublicShareController {
|
|||
}
|
||||
|
||||
class PublicShareControllerTest extends \Test\TestCase {
|
||||
/** @var IRequest|\PHPUnit\Framework\MockObject\MockObject */
|
||||
private $request;
|
||||
/** @var ISession|\PHPUnit\Framework\MockObject\MockObject */
|
||||
private $session;
|
||||
private IRequest&MockObject $request;
|
||||
private ISession&MockObject $session;
|
||||
|
||||
protected function setUp(): void {
|
||||
parent::setUp();
|
||||
|
|
|
|||
|
|
@ -73,7 +73,7 @@ class TestEntity extends Entity {
|
|||
|
||||
|
||||
class EntityTest extends \Test\TestCase {
|
||||
private $entity;
|
||||
private TestEntity $entity;
|
||||
|
||||
protected function setUp(): void {
|
||||
parent::setUp();
|
||||
|
|
|
|||
|
|
@ -64,9 +64,8 @@ class QBDBTestMapper extends QBMapper {
|
|||
* @group DB
|
||||
*/
|
||||
class QBMapperDBTest extends TestCase {
|
||||
/** @var \Doctrine\DBAL\Connection|IDBConnection */
|
||||
protected $connection;
|
||||
protected $schemaSetup = false;
|
||||
protected IDBConnection $connection;
|
||||
protected bool $schemaSetup = false;
|
||||
|
||||
protected function setUp(): void {
|
||||
parent::setUp();
|
||||
|
|
|
|||
|
|
@ -15,8 +15,7 @@ use RuntimeException;
|
|||
use Test\TestCase;
|
||||
|
||||
class TransactionalTest extends TestCase {
|
||||
/** @var IDBConnection|MockObject */
|
||||
private IDBConnection $db;
|
||||
private IDBConnection&MockObject $db;
|
||||
|
||||
protected function setUp(): void {
|
||||
parent::setUp();
|
||||
|
|
|
|||
|
|
@ -1,5 +1,7 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
/**
|
||||
* SPDX-FileCopyrightText: 2016-2024 Nextcloud GmbH and Nextcloud contributors
|
||||
* SPDX-FileCopyrightText: 2016 ownCloud, Inc.
|
||||
|
|
|
|||
|
|
@ -34,11 +34,8 @@ class ClassB {
|
|||
}
|
||||
|
||||
class DIIntergrationTests extends TestCase {
|
||||
/** @var DIContainer */
|
||||
private $container;
|
||||
|
||||
/** @var ServerContainer */
|
||||
private $server;
|
||||
private DIContainer $container;
|
||||
private ServerContainer $server;
|
||||
|
||||
protected function setUp(): void {
|
||||
parent::setUp();
|
||||
|
|
|
|||
|
|
@ -1,5 +1,7 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
/**
|
||||
* SPDX-FileCopyrightText: 2016-2024 Nextcloud GmbH and Nextcloud contributors
|
||||
* SPDX-FileCopyrightText: 2016 ownCloud, Inc.
|
||||
|
|
@ -16,8 +18,7 @@ use OCP\AppFramework\Http\ContentSecurityPolicy;
|
|||
* @package OC\AppFramework\Http
|
||||
*/
|
||||
class ContentSecurityPolicyTest extends \Test\TestCase {
|
||||
/** @var ContentSecurityPolicy */
|
||||
private $contentSecurityPolicy;
|
||||
private ContentSecurityPolicy $contentSecurityPolicy;
|
||||
|
||||
protected function setUp(): void {
|
||||
parent::setUp();
|
||||
|
|
|
|||
|
|
@ -1,5 +1,7 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
/**
|
||||
* SPDX-FileCopyrightText: 2016-2024 Nextcloud GmbH and Nextcloud contributors
|
||||
* SPDX-FileCopyrightText: 2016 ownCloud, Inc.
|
||||
|
|
@ -14,10 +16,7 @@ use OCP\IRequest;
|
|||
use OCP\Server;
|
||||
|
||||
class DataResponseTest extends \Test\TestCase {
|
||||
/**
|
||||
* @var DataResponse
|
||||
*/
|
||||
private $response;
|
||||
private DataResponse $response;
|
||||
|
||||
protected function setUp(): void {
|
||||
parent::setUp();
|
||||
|
|
|
|||
Loading…
Reference in a new issue