Skip to content

Commit 340ea17

Browse files
authored
Merge pull request #55870 from nextcloud/chore/phpunit-11
chore: migrate to PHPUnit 11
2 parents fafc07a + 6336eac commit 340ea17

File tree

29 files changed

+895
-753
lines changed

29 files changed

+895
-753
lines changed

.github/workflows/phpunit-32bits.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,4 +68,4 @@ jobs:
6868
php -f tests/enable_all.php
6969
7070
- name: PHPUnit
71-
run: composer run test -- --exclude-group PRIMARY-azure,PRIMARY-s3,PRIMARY-swift,Memcached,Redis,RoutingWeirdness
71+
run: composer run test -- --exclude-group PRIMARY-azure --exclude-group PRIMARY-s3 --exclude-group PRIMARY-swift --exclude-group Memcached --exclude-group Redis --exclude-group RoutingWeirdness

.github/workflows/phpunit-memcached.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ jobs:
9999
php -f tests/enable_all.php
100100
101101
- name: PHPUnit memcached tests
102-
run: composer run test -- --group Memcache,Memcached --log-junit junit.xml ${{ matrix.coverage && '--coverage-clover ./clover.xml' || '' }}
102+
run: composer run test -- --group Memcache --group Memcached --log-junit junit.xml ${{ matrix.coverage && '--coverage-clover ./clover.xml' || '' }}
103103

104104
- name: Upload code coverage
105105
if: ${{ !cancelled() && matrix.coverage }}

.github/workflows/phpunit-nodb.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ jobs:
105105
php -f tests/enable_all.php
106106
107107
- name: PHPUnit nodb testsuite
108-
run: composer run test -- --exclude-group DB,SLOWDB --log-junit junit.xml ${{ matrix.coverage && '--coverage-clover ./clover.nodb.xml' || '' }}
108+
run: composer run test -- --exclude-group DB --exclude-group SLOWDB --log-junit junit.xml ${{ matrix.coverage && '--coverage-clover ./clover.nodb.xml' || '' }}
109109

110110
- name: Upload nodb code coverage
111111
if: ${{ !cancelled() && matrix.coverage }}

apps/dav/tests/unit/CalDAV/Schedule/IMipPluginCharsetTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,7 @@ public function testCharsetMailProvider(): void {
175175
->with('core', 'mail_providers_enabled', true)
176176
->willReturn(true);
177177
$mailMessage = new MailProviderMessage();
178-
$mailService = $this->createStubForIntersectionOfInterfaces([IService::class, IMessageSend::class]);
178+
$mailService = $this->createMockForIntersectionOfInterfaces([IService::class, IMessageSend::class]);
179179
$mailService->method('initiateMessage')
180180
->willReturn($mailMessage);
181181
$mailService->expects(self::once())

apps/dav/tests/unit/Listener/OutOfOfficeListenerTest.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,9 +36,7 @@
3636
use Sabre\VObject\Reader;
3737
use Test\TestCase;
3838

39-
/**
40-
* @covers \OCA\DAV\Listener\OutOfOfficeListener
41-
*/
39+
#[\PHPUnit\Framework\Attributes\CoversClass(OutOfOfficeListener::class)]
4240
class OutOfOfficeListenerTest extends TestCase {
4341

4442
private ServerFactory&MockObject $serverFactory;

apps/settings/tests/SetupChecks/AppDirsWithDifferentOwnerTest.php

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,14 @@
1010

1111
use OCA\Settings\SetupChecks\AppDirsWithDifferentOwner;
1212
use OCP\IL10N;
13+
use PHPUnit\Framework\MockObject\MockObject;
1314
use Test\TestCase;
1415

1516
class AppDirsWithDifferentOwnerTest extends TestCase {
16-
private IL10N $l10n;
1717
private AppDirsWithDifferentOwner $check;
1818

19+
private IL10N&MockObject $l10n;
20+
1921
/**
2022
* Holds a list of directories created during tests.
2123
*
@@ -42,8 +44,6 @@ protected function setUp(): void {
4244
* Then calls the 'getAppDirsWithDifferentOwner' method.
4345
* The result is expected to be empty since
4446
* there are no directories with different owners than the current user.
45-
*
46-
* @return void
4747
*/
4848
public function testAppDirectoryOwnersOk(): void {
4949
$tempDir = tempnam(sys_get_temp_dir(), 'apps') . 'dir';
@@ -69,8 +69,6 @@ public function testAppDirectoryOwnersOk(): void {
6969
/**
7070
* Calls the check for a none existing app root that is marked as not writable.
7171
* It's expected that no error happens since the check shouldn't apply.
72-
*
73-
* @return void
7472
*/
7573
public function testAppDirectoryOwnersNotWritable(): void {
7674
$tempDir = tempnam(sys_get_temp_dir(), 'apps') . 'dir';
@@ -89,11 +87,9 @@ public function testAppDirectoryOwnersNotWritable(): void {
8987

9088
/**
9189
* Removes directories created during tests.
92-
*
93-
* @after
94-
* @return void
9590
*/
96-
public function removeTestDirectories() {
91+
#[\PHPUnit\Framework\Attributes\After()]
92+
public function removeTestDirectories(): void {
9793
foreach ($this->dirsToRemove as $dirToRemove) {
9894
rmdir($dirToRemove);
9995
}

autotest.sh

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ else
5353
fi
5454

5555
if ! [ -x "$PHPUNIT" ]; then
56-
echo "phpunit executable not found, please install phpunit version >= 10.5 manually or via:" >&2
56+
echo "phpunit executable not found, please install phpunit version >= 11.5 manually or via:" >&2
5757
echo " composer install" >&2
5858
exit 3
5959
fi
@@ -69,8 +69,8 @@ PHPUNIT_VERSION=$($PHPUNIT --version | cut -d" " -f2)
6969
PHPUNIT_MAJOR_VERSION=$(echo "$PHPUNIT_VERSION" | cut -d"." -f1)
7070
PHPUNIT_MINOR_VERSION=$(echo "$PHPUNIT_VERSION" | cut -d"." -f2)
7171

72-
if ! [ "$PHPUNIT_MAJOR_VERSION" -gt 10 -o \( "$PHPUNIT_MAJOR_VERSION" -eq 10 -a "$PHPUNIT_MINOR_VERSION" -ge 5 \) ]; then
73-
echo "phpunit version >= 10.5 required. Version found: $PHPUNIT_VERSION" >&2
72+
if ! [ "$PHPUNIT_MAJOR_VERSION" -gt 11 -o \( "$PHPUNIT_MAJOR_VERSION" -eq 11 -a "$PHPUNIT_MINOR_VERSION" -ge 5 \) ]; then
73+
echo "phpunit version >= 11.5 required. Version found: $PHPUNIT_VERSION" >&2
7474
exit 4
7575
fi
7676

build/integration/composer.json

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,14 @@
11
{
22
"config": {
33
"platform": {
4-
"php": "8.1"
4+
"php": "8.2"
55
},
66
"sort-packages": true
77
},
88
"require-dev": {
99
"behat/behat": "^3.15",
10-
"dms/phpunit-arraysubset-asserts": "^0.5",
1110
"guzzlehttp/guzzle": "^7.9",
12-
"phpunit/phpunit": "^9.6",
11+
"phpunit/phpunit": "^11.5",
1312
"sabre/dav": "^4.7",
1413
"symfony/event-dispatcher": "^6.4"
1514
}

0 commit comments

Comments
 (0)