Skip to content

Commit

Permalink
Adds PHPUnit 10.5 support (#65)
Browse files Browse the repository at this point in the history
  • Loading branch information
michalbundyra authored Dec 1, 2023
1 parent 0a77111 commit 3dabfd4
Show file tree
Hide file tree
Showing 5 changed files with 87 additions and 15 deletions.
26 changes: 26 additions & 0 deletions .github/workflows/coding-standards.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
name: "Check Coding Standards"

on:
pull_request:

jobs:
coding-standards:
name: "Check Coding Standards"

runs-on: ubuntu-latest

steps:
- name: Checkout
uses: actions/checkout@v4

- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: "7.4"
tools: composer:v2, cs2pr

- name: Install dependencies
run: composer require phpcsstandards/php_codesniffer --no-interaction --no-progress

- name: "Run phpcs"
run: vendor/bin/phpcs -q --standard=PSR2 classes/ tests/ --report=checkstyle | cs2pr
26 changes: 26 additions & 0 deletions .github/workflows/phpmd.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
name: "Check phpmd"

on:
pull_request:

jobs:
coding-standards:
name: "Check phpmd"

runs-on: ubuntu-latest

steps:
- name: Checkout
uses: actions/checkout@v4

- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: "7.4"
tools: composer:v2

- name: Install dependencies
run: composer require phpmd/phpmd --no-interaction --no-progress

- name: Run phpmd
run: vendor/bin/phpmd classes/ text cleancode,codesize,controversial,design,naming,unusedcode
23 changes: 15 additions & 8 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ jobs:
- '7.1'
- '7.0'
phpunit-version:
- '10.5.0'
- '10.4.0'
- '10.3.0'
- '10.2.0'
Expand Down Expand Up @@ -193,6 +194,8 @@ jobs:
phpunit-version: '6.0.0'

# PHP 8.0 Exclusions
- php-version: '8.0'
phpunit-version: '10.5.0'
- php-version: '8.0'
phpunit-version: '10.4.0'
- php-version: '8.0'
Expand Down Expand Up @@ -245,6 +248,8 @@ jobs:
phpunit-version: '6.0.0'

# PHP 7.4 Exclusions
- php-version: '7.4'
phpunit-version: '10.5.0'
- php-version: '7.4'
phpunit-version: '10.4.0'
- php-version: '7.4'
Expand Down Expand Up @@ -283,6 +288,8 @@ jobs:
phpunit-version: '6.0.0'

# PHP 7.3 Exclusions
- php-version: '7.3'
phpunit-version: '10.5.0'
- php-version: '7.3'
phpunit-version: '10.4.0'
- php-version: '7.3'
Expand All @@ -295,6 +302,8 @@ jobs:
phpunit-version: '10.0.0'

# PHP 7.2 Exclusions
- php-version: '7.2'
phpunit-version: '10.5.0'
- php-version: '7.2'
phpunit-version: '10.4.0'
- php-version: '7.2'
Expand All @@ -321,6 +330,8 @@ jobs:
phpunit-version: '9.0.0'

# PHP 7.1 Exclusions
- php-version: '7.1'
phpunit-version: '10.5.0'
- php-version: '7.1'
phpunit-version: '10.4.0'
- php-version: '7.1'
Expand Down Expand Up @@ -359,6 +370,8 @@ jobs:
phpunit-version: '8.0.0'

# PHP 7.0 Exclusions
- php-version: '7.0'
phpunit-version: '10.5.0'
- php-version: '7.0'
phpunit-version: '10.4.0'
- php-version: '7.0'
Expand Down Expand Up @@ -411,21 +424,15 @@ jobs:
name: PHPUnit ${{ matrix.phpunit-version }} on PHP ${{ matrix.php-version }}
steps:
- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Install PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php-version }}

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

- name: PHPUnit
run: vendor/bin/phpunit

- name: PHPCS
run: vendor/bin/phpcs --standard=PSR2 classes/ tests/

- name: PHPMD
run: vendor/bin/phpmd classes/ text cleancode,codesize,controversial,design,naming,unusedcode
2 changes: 1 addition & 1 deletion classes/PHPMock.php
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ private function prepareCustomTemplates()
$reflectionTemplates = $reflection->getProperty('templates');
$reflectionTemplates->setAccessible(true);

$reflectionTemplates->setValue($templates);
$reflectionTemplates->setValue(null, $templates);

break;
}
Expand Down
25 changes: 19 additions & 6 deletions tests/MockObjectProxyTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,25 @@ public function testExpects()
{
$matcher = $this->getMockBuilder(Invocation::class)->getMock();

$methods = class_exists(ConfigurableMethod::class)
? new ConfigurableMethod(
MockDelegateFunctionBuilder::METHOD,
Mockery::mock(Type::class)
)
: [MockDelegateFunctionBuilder::METHOD];
if (class_exists(ConfigurableMethod::class)) {
if (class_exists(\PHPUnit\Runner\Version::class)
&& version_compare(\PHPUnit\Runner\Version::id(), '10.5.0') >= 0
) {
$methods = new ConfigurableMethod(
MockDelegateFunctionBuilder::METHOD,
[],
0,
Mockery::mock(Type::class)
);
} else {
$methods = new ConfigurableMethod(
MockDelegateFunctionBuilder::METHOD,
Mockery::mock(Type::class)
);
}
} else {
$methods = [MockDelegateFunctionBuilder::METHOD];
}

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

0 comments on commit 3dabfd4

Please sign in to comment.