Skip to content

Commit 1447f18

Browse files
Merge pull request #55405 from nextcloud/carl/cleanup-some-tests
refactor: Cleanup some unit tests
2 parents c214ec4 + 60c2875 commit 1447f18

38 files changed

Lines changed: 138 additions & 169 deletions

tests/lib/Accounts/AccountManagerTest.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
<?php
22

3+
declare(strict_types=1);
4+
35
/**
46
* SPDX-FileCopyrightText: 2016-2024 Nextcloud GmbH and Nextcloud contributors
57
* SPDX-FileCopyrightText: 2016 ownCloud, Inc.

tests/lib/Accounts/AccountPropertyCollectionTest.php

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,7 @@
1717
use Test\TestCase;
1818

1919
class AccountPropertyCollectionTest extends TestCase {
20-
/** @var IAccountPropertyCollection */
21-
protected $collection;
20+
protected IAccountPropertyCollection $collection;
2221

2322
protected const COLLECTION_NAME = 'my_multivalue_property';
2423

@@ -28,10 +27,7 @@ public function setUp(): void {
2827
$this->collection = new AccountPropertyCollection(self::COLLECTION_NAME);
2928
}
3029

31-
/**
32-
* @return IAccountProperty|MockObject
33-
*/
34-
protected function makePropertyMock(string $propertyName): MockObject {
30+
protected function makePropertyMock(string $propertyName): IAccountProperty&MockObject {
3531
$mock = $this->createMock(IAccountProperty::class);
3632
$mock->expects($this->any())
3733
->method('getName')

tests/lib/Accounts/AccountPropertyTest.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
<?php
22

3+
declare(strict_types=1);
4+
35
/**
46
* SPDX-FileCopyrightText: 2018 Nextcloud GmbH and Nextcloud contributors
57
* SPDX-License-Identifier: AGPL-3.0-or-later

tests/lib/Accounts/AccountTest.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
<?php
22

3+
declare(strict_types=1);
4+
35
/**
46
* SPDX-FileCopyrightText: 2018 Nextcloud GmbH and Nextcloud contributors
57
* SPDX-License-Identifier: AGPL-3.0-or-later

tests/lib/Accounts/HooksTest.php

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
<?php
22

3+
declare(strict_types=1);
4+
35
/**
46
* SPDX-FileCopyrightText: 2016 Nextcloud GmbH and Nextcloud contributors
57
* SPDX-License-Identifier: AGPL-3.0-or-later
@@ -24,14 +26,10 @@
2426
* @group DB
2527
*/
2628
class HooksTest extends TestCase {
27-
/** @var LoggerInterface|MockObject */
28-
private $logger;
29-
30-
/** @var AccountManager|MockObject */
31-
private $accountManager;
3229

33-
/** @var Hooks */
34-
private $hooks;
30+
private LoggerInterface&MockObject $logger;
31+
private AccountManager&MockObject $accountManager;
32+
private Hooks $hooks;
3533

3634
protected function setUp(): void {
3735
parent::setUp();

tests/lib/Activity/ManagerTest.php

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
<?php
22

3+
declare(strict_types=1);
4+
35
/**
46
* SPDX-FileCopyrightText: 2016-2024 Nextcloud GmbH and Nextcloud contributors
57
* SPDX-FileCopyrightText: 2016 ownCloud, Inc.
@@ -8,6 +10,7 @@
810

911
namespace Test\Activity;
1012

13+
use OC\Activity\Manager;
1114
use OCP\Activity\Exceptions\IncompleteActivityException;
1215
use OCP\Activity\IConsumer;
1316
use OCP\Activity\IEvent;
@@ -23,8 +26,7 @@
2326
use Test\TestCase;
2427

2528
class ManagerTest extends TestCase {
26-
/** @var \OC\Activity\Manager */
27-
private $activityManager;
29+
private Manager $activityManager;
2830

2931
protected IRequest&MockObject $request;
3032
protected IUserSession&MockObject $session;
@@ -43,7 +45,7 @@ protected function setUp(): void {
4345
$this->richTextFormatter = $this->createMock(IRichTextFormatter::class);
4446
$this->time = $this->createMock(ITimeFactory::class);
4547

46-
$this->activityManager = new \OC\Activity\Manager(
48+
$this->activityManager = new Manager(
4749
$this->request,
4850
$this->session,
4951
$this->config,

tests/lib/App/AppStore/Bundles/BundleBase.php

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
<?php
22

3+
declare(strict_types=1);
4+
35
/**
46
* SPDX-FileCopyrightText: 2017 Nextcloud GmbH and Nextcloud contributors
57
* SPDX-License-Identifier: AGPL-3.0-or-later
@@ -9,19 +11,15 @@
911

1012
use OC\App\AppStore\Bundles\Bundle;
1113
use OCP\IL10N;
14+
use PHPUnit\Framework\MockObject\MockObject;
1215
use Test\TestCase;
1316

1417
abstract class BundleBase extends TestCase {
15-
/** @var IL10N|\PHPUnit\Framework\MockObject\MockObject */
16-
protected $l10n;
17-
/** @var Bundle */
18-
protected $bundle;
19-
/** @var string */
20-
protected $bundleIdentifier;
21-
/** @var string */
22-
protected $bundleName;
23-
/** @var array */
24-
protected $bundleAppIds;
18+
protected IL10N&MockObject $l10n;
19+
protected Bundle $bundle;
20+
protected string $bundleIdentifier;
21+
protected string $bundleName;
22+
protected array $bundleAppIds;
2523

2624
protected function setUp(): void {
2725
parent::setUp();

tests/lib/App/AppStore/Bundles/BundleFetcherTest.php

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
<?php
22

3+
declare(strict_types=1);
4+
35
/**
46
* SPDX-FileCopyrightText: 2017 Nextcloud GmbH and Nextcloud contributors
57
* SPDX-License-Identifier: AGPL-3.0-or-later
@@ -15,13 +17,12 @@
1517
use OC\App\AppStore\Bundles\PublicSectorBundle;
1618
use OC\App\AppStore\Bundles\SocialSharingBundle;
1719
use OCP\IL10N;
20+
use PHPUnit\Framework\MockObject\MockObject;
1821
use Test\TestCase;
1922

2023
class BundleFetcherTest extends TestCase {
21-
/** @var IL10N|\PHPUnit\Framework\MockObject\MockObject */
22-
private $l10n;
23-
/** @var BundleFetcher */
24-
private $bundleFetcher;
24+
private IL10N&MockObject $l10n;
25+
private BundleFetcher $bundleFetcher;
2526

2627
protected function setUp(): void {
2728
parent::setUp();

tests/lib/App/AppStore/Bundles/EducationBundleTest.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
<?php
22

3+
declare(strict_types=1);
4+
35
/**
46
* SPDX-FileCopyrightText: 2017 Nextcloud GmbH and Nextcloud contributors
57
* SPDX-License-Identifier: AGPL-3.0-or-later

tests/lib/App/AppStore/Bundles/EnterpriseBundleTest.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
<?php
22

3+
declare(strict_types=1);
4+
35
/**
46
* SPDX-FileCopyrightText: 2017 Nextcloud GmbH and Nextcloud contributors
57
* SPDX-License-Identifier: AGPL-3.0-or-later

0 commit comments

Comments
 (0)