Skip to content

Commit 3dabfd4

Browse files
Adds PHPUnit 10.5 support (#65)
1 parent 0a77111 commit 3dabfd4

File tree

5 files changed

+87
-15
lines changed

5 files changed

+87
-15
lines changed
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
name: "Check Coding Standards"
2+
3+
on:
4+
pull_request:
5+
6+
jobs:
7+
coding-standards:
8+
name: "Check Coding Standards"
9+
10+
runs-on: ubuntu-latest
11+
12+
steps:
13+
- name: Checkout
14+
uses: actions/checkout@v4
15+
16+
- name: Setup PHP
17+
uses: shivammathur/setup-php@v2
18+
with:
19+
php-version: "7.4"
20+
tools: composer:v2, cs2pr
21+
22+
- name: Install dependencies
23+
run: composer require phpcsstandards/php_codesniffer --no-interaction --no-progress
24+
25+
- name: "Run phpcs"
26+
run: vendor/bin/phpcs -q --standard=PSR2 classes/ tests/ --report=checkstyle | cs2pr

.github/workflows/phpmd.yml

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
name: "Check phpmd"
2+
3+
on:
4+
pull_request:
5+
6+
jobs:
7+
coding-standards:
8+
name: "Check phpmd"
9+
10+
runs-on: ubuntu-latest
11+
12+
steps:
13+
- name: Checkout
14+
uses: actions/checkout@v4
15+
16+
- name: Setup PHP
17+
uses: shivammathur/setup-php@v2
18+
with:
19+
php-version: "7.4"
20+
tools: composer:v2
21+
22+
- name: Install dependencies
23+
run: composer require phpmd/phpmd --no-interaction --no-progress
24+
25+
- name: Run phpmd
26+
run: vendor/bin/phpmd classes/ text cleancode,codesize,controversial,design,naming,unusedcode

.github/workflows/tests.yml

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ jobs:
2323
- '7.1'
2424
- '7.0'
2525
phpunit-version:
26+
- '10.5.0'
2627
- '10.4.0'
2728
- '10.3.0'
2829
- '10.2.0'
@@ -193,6 +194,8 @@ jobs:
193194
phpunit-version: '6.0.0'
194195

195196
# PHP 8.0 Exclusions
197+
- php-version: '8.0'
198+
phpunit-version: '10.5.0'
196199
- php-version: '8.0'
197200
phpunit-version: '10.4.0'
198201
- php-version: '8.0'
@@ -245,6 +248,8 @@ jobs:
245248
phpunit-version: '6.0.0'
246249

247250
# PHP 7.4 Exclusions
251+
- php-version: '7.4'
252+
phpunit-version: '10.5.0'
248253
- php-version: '7.4'
249254
phpunit-version: '10.4.0'
250255
- php-version: '7.4'
@@ -283,6 +288,8 @@ jobs:
283288
phpunit-version: '6.0.0'
284289

285290
# PHP 7.3 Exclusions
291+
- php-version: '7.3'
292+
phpunit-version: '10.5.0'
286293
- php-version: '7.3'
287294
phpunit-version: '10.4.0'
288295
- php-version: '7.3'
@@ -295,6 +302,8 @@ jobs:
295302
phpunit-version: '10.0.0'
296303

297304
# PHP 7.2 Exclusions
305+
- php-version: '7.2'
306+
phpunit-version: '10.5.0'
298307
- php-version: '7.2'
299308
phpunit-version: '10.4.0'
300309
- php-version: '7.2'
@@ -321,6 +330,8 @@ jobs:
321330
phpunit-version: '9.0.0'
322331

323332
# PHP 7.1 Exclusions
333+
- php-version: '7.1'
334+
phpunit-version: '10.5.0'
324335
- php-version: '7.1'
325336
phpunit-version: '10.4.0'
326337
- php-version: '7.1'
@@ -359,6 +370,8 @@ jobs:
359370
phpunit-version: '8.0.0'
360371

361372
# PHP 7.0 Exclusions
373+
- php-version: '7.0'
374+
phpunit-version: '10.5.0'
362375
- php-version: '7.0'
363376
phpunit-version: '10.4.0'
364377
- php-version: '7.0'
@@ -411,21 +424,15 @@ jobs:
411424
name: PHPUnit ${{ matrix.phpunit-version }} on PHP ${{ matrix.php-version }}
412425
steps:
413426
- name: Checkout
414-
uses: actions/checkout@v3
427+
uses: actions/checkout@v4
415428

416429
- name: Install PHP
417430
uses: shivammathur/setup-php@v2
418431
with:
419432
php-version: ${{ matrix.php-version }}
420433

421434
- name: Install Dependencies
422-
run: composer require phpunit/phpunit:~${{ matrix.phpunit-version }} squizlabs/php_codesniffer phpmd/phpmd
435+
run: composer require phpunit/phpunit:~${{ matrix.phpunit-version }} --no-interaction --no-progress
423436

424437
- name: PHPUnit
425438
run: vendor/bin/phpunit
426-
427-
- name: PHPCS
428-
run: vendor/bin/phpcs --standard=PSR2 classes/ tests/
429-
430-
- name: PHPMD
431-
run: vendor/bin/phpmd classes/ text cleancode,codesize,controversial,design,naming,unusedcode

classes/PHPMock.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -210,7 +210,7 @@ private function prepareCustomTemplates()
210210
$reflectionTemplates = $reflection->getProperty('templates');
211211
$reflectionTemplates->setAccessible(true);
212212

213-
$reflectionTemplates->setValue($templates);
213+
$reflectionTemplates->setValue(null, $templates);
214214

215215
break;
216216
}

tests/MockObjectProxyTest.php

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -34,12 +34,25 @@ public function testExpects()
3434
{
3535
$matcher = $this->getMockBuilder(Invocation::class)->getMock();
3636

37-
$methods = class_exists(ConfigurableMethod::class)
38-
? new ConfigurableMethod(
39-
MockDelegateFunctionBuilder::METHOD,
40-
Mockery::mock(Type::class)
41-
)
42-
: [MockDelegateFunctionBuilder::METHOD];
37+
if (class_exists(ConfigurableMethod::class)) {
38+
if (class_exists(\PHPUnit\Runner\Version::class)
39+
&& version_compare(\PHPUnit\Runner\Version::id(), '10.5.0') >= 0
40+
) {
41+
$methods = new ConfigurableMethod(
42+
MockDelegateFunctionBuilder::METHOD,
43+
[],
44+
0,
45+
Mockery::mock(Type::class)
46+
);
47+
} else {
48+
$methods = new ConfigurableMethod(
49+
MockDelegateFunctionBuilder::METHOD,
50+
Mockery::mock(Type::class)
51+
);
52+
}
53+
} else {
54+
$methods = [MockDelegateFunctionBuilder::METHOD];
55+
}
4356

4457
if (class_exists(\PHPUnit\Runner\Version::class)
4558
&& version_compare(\PHPUnit\Runner\Version::id(), '8.4.0') >= 0

0 commit comments

Comments
 (0)