Skip to content

Commit b93bead

Browse files
author
Stefan Boonstra
committed
Refresh PHPUnit setup
* Move PHPUnit dependency from require to require-dev * Rewrite unit tests for PHPUnit 12 * Install phpunit upstream with dependency installer while honoring/keeping upstream versions * Add unit tests for package installer changes to install phpunit upstream * Refresh github actions and run workflows for php 8.1, 8.2, 8.3 and 8.4 * Drop php support for versions < 8.1 * Drop composer 1 support * Drop youwe/coding-standard-phpstorm package and add as suggest
1 parent 3e1206b commit b93bead

23 files changed

+335
-281
lines changed

.github/workflows/testing-suite.yml

+16-8
Original file line numberDiff line numberDiff line change
@@ -4,20 +4,28 @@ jobs:
44
PHP:
55
strategy:
66
matrix:
7-
image: [
8-
'srcoder/development-php:php74-fpm',
9-
'srcoder/development-php:php80-fpm',
10-
'srcoder/development-php:php81-fpm'
11-
]
7+
php-version: [8.1, 8.2, 8.3, 8.4]
128
runs-on: ubuntu-latest
139
container:
14-
image: ${{ matrix.image }}
10+
image: ${{ matrix.php-version == '8.1' && 'srcoder/development-php:php81-fpm' ||
11+
matrix.php-version == '8.2' && 'srcoder/development-php:php82-fpm' ||
12+
matrix.php-version == '8.3' && 'srcoder/development-php:php83-fpm' ||
13+
matrix.php-version == '8.4' && 'srcoder/development-php:php84-fpm' }}
1514
steps:
1615
- name: Checkout
1716
uses: actions/checkout@v2
18-
- name: Testing Suite
17+
18+
- name: Install Dependencies
1919
run: |
2020
composer2 install --dev --prefer-dist --no-scripts --no-progress --optimize-autoloader --no-interaction -vvv
2121
composer2 show
22-
composer2 exec -v grumphp run
22+
shell: bash
23+
24+
- name: Run GrumPHP Tasks
25+
run: |
26+
if [[ "${{ matrix.php-version }}" == "8.1" || "${{ matrix.php-version }}" == "8.2" ]]; then
27+
composer2 exec -v grumphp -- run --tasks=composer,jsonlint,xmllint,yamllint,phpcs,phplint,phpmd,phpstan,securitychecker_enlightn
28+
else
29+
composer2 exec -v grumphp -- run
30+
fi
2331
shell: bash

CHANGELOG.md

+24
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,30 @@ All notable changes to this project will be documented in this file.
44
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
55
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
66

7+
## [3.0.0] - Unreleased
8+
### Added
9+
- Added `phpunit/phpunit` to suggested dependencies in `composer.json`.
10+
- Added `youwe/coding-standard-phpstorm` to suggested dependencies in `composer.json`.
11+
- Added support to honor upstream version constraints
12+
- Github action for php 8.3 and php 8.4 to run unit tests against PHPUnit 12.
13+
- Testing suite now attempts to install phpunit upstream if it isn't available yet
14+
- Existing upstream versions are honored if already installed
15+
- Upstream projects not having phpunit installed will install phpunit with an @stable version
16+
17+
### Changed
18+
- Unit tests as part of the testing suite are rewritten for PHPUnit 12
19+
- Updated GitHub Action workflows to support PHP 8.1, 8.2, and 8.3.
20+
- `composer.json`: Dropped support for PHP < 8.1.
21+
- Moved phpunit from require to require-dev
22+
- Changed PHPMD suppressions in docblocks to quote the rule name, due to changes in later versions of PHPStan that create false positives on these docblocks if not quoted.
23+
24+
### Removed
25+
- Removed support for EOL PHP versions. Projects running PHP < 8.1 can stick to version 2 of the testing-suite.
26+
- Removed support for Composer 1. Projects still relying on Composer 1 can stick to version 2 of the testing-suite.
27+
- Removed `youwe/coding-standard-phpstorm` as dependency (it is still listed in suggest)
28+
- Removed `phpunit/phpunit` as direct dependency (it is still in require-dev and installed upstream through the `youwe/dependency-installer`)
29+
- Github actions for php < 8.1
30+
731
## 2.19.1
832
### Changed
933
- `^0.30` restricts updates to only versions within the `0.30.x` range, preventing upgrades to 0.32.0 for

CONTRIBUTING.md

+10-2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,11 @@
1+
Before opening a PR with changes, make sure all the linting steps are successful.
2+
3+
The require-dev dependency for phpunit is set to @stable for the github actions, but the tests themselves\
4+
assume they are running against PHPUnit 12 and php >= 8.3. The github actions only run phpunit tests against\
5+
a php 8.3 container.
6+
17
If a PR is approved please ask one of the following maintainers to get it merged:
2-
[Igor Wulff](https://github.com/igorwulff)
3-
[Dan Wallis](https://github.com/fredden)
8+
9+
- [Igor Wulff](https://github.com/igorwulff)
10+
- [Leon Helmus](https://github.com/leonhelmus)
11+
- [Rutger Rademakers](https://github.com/rutgerrademaker)

composer.json

+8-5
Original file line numberDiff line numberDiff line change
@@ -24,22 +24,25 @@
2424
}
2525
],
2626
"require": {
27-
"php": "^7.2 || ^8.0",
28-
"composer-plugin-api": "^1.1 || ^2.0",
27+
"php": "^8.1",
28+
"composer-plugin-api": "^2.0",
2929
"enlightn/security-checker": "^1.5 || ^2.0",
3030
"kint-php/kint": "@stable",
3131
"php-parallel-lint/php-parallel-lint": "^1.2",
3232
"phpro/grumphp-shim": "^1.13",
3333
"phpstan/phpstan": "@stable",
34-
"phpunit/phpunit": "@stable",
3534
"youwe/coding-standard": "^3.5.0",
36-
"youwe/coding-standard-phpstorm": "^2.3.0",
3735
"youwe/composer-dependency-installer": "^1.4.0",
3836
"youwe/composer-file-installer": "^1.2.0"
3937
},
38+
"suggest": {
39+
"phpunit/phpunit": ">= 9.6",
40+
"youwe/coding-standard-phpstorm": "^2.3.0"
41+
},
4042
"require-dev": {
4143
"composer/composer": "@stable",
42-
"mikey179/vfsstream": "@stable"
44+
"mikey179/vfsstream": "@stable",
45+
"phpunit/phpunit": "@stable"
4346
},
4447
"replace": {
4548
"sensiolabs/security-checker": "*"

phpstan.neon

+1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
parameters:
22
excludePaths:
33
- src/installers.php
4+
- tests/*
45
ignoreErrors:
56
- '#Property Mediact\\TestingSuite\\Composer\\Installer\\ConfigInstaller::\$io is never read, only written\.#'

src/ConfigResolver.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,11 @@ class ConfigResolver
2121
* Constructor.
2222
*
2323
* @param ProjectTypeResolver $typeResolver
24-
* @param string $template
24+
* @param string|null $template
2525
*/
2626
public function __construct(
2727
ProjectTypeResolver $typeResolver,
28-
string $template = null
28+
?string $template = null
2929
) {
3030
$this->typeResolver = $typeResolver;
3131
$this->template = $template ?? $this->template;

src/Factory/ProcessFactory.php

+1
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ class ProcessFactory implements ProcessFactoryInterface
2323
public function create(string $commandLine): Process
2424
{
2525
// See https://github.com/composer/composer/blob/1.10.17/src/Composer/Util/ProcessExecutor.php#L68:L72
26+
// @phpstan-ignore-next-line because phpstan can see it's available, but we cannot guarantee symfony >= 4.2 upstream
2627
return method_exists(Process::class, 'fromShellCommandline')
2728
? Process::fromShellCommandline($commandLine) // Symfony >= 4.2
2829
: new Process($commandLine); // Symfony < 4.2

src/Installer/ArchiveExcludeInstaller.php

+10-7
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,14 @@
1212
use Composer\Factory;
1313
use Composer\IO\IOInterface;
1414
use Composer\Json\JsonFile;
15+
use Exception;
16+
use Seld\JsonLint\ParsingException;
1517
use Youwe\FileMapping\FileMappingInterface;
1618
use Youwe\TestingSuite\Composer\MappingResolver;
1719

1820
/**
19-
* @SuppressWarnings(PHPMD.ShortVariable)
20-
* @SuppressWarnings(PHPMD.StaticAccess)
21+
* @SuppressWarnings("PHPMD.ShortVariable")
22+
* @SuppressWarnings("PHPMD.StaticAccess")
2123
*/
2224
class ArchiveExcludeInstaller implements InstallerInterface
2325
{
@@ -41,7 +43,7 @@ class ArchiveExcludeInstaller implements InstallerInterface
4143
'/.env.dev',
4244
'/.gitattributes',
4345
'/.gitignore',
44-
'/tests'
46+
'/tests',
4547
];
4648

4749
/**
@@ -50,15 +52,15 @@ class ArchiveExcludeInstaller implements InstallerInterface
5052
* @param MappingResolver $resolver
5153
* @param IOInterface $io
5254
* @param JsonFile|null $file
53-
* @param string $destination
55+
* @param string |null $destination
5456
* @param array|null $defaults
5557
*/
5658
public function __construct(
5759
MappingResolver $resolver,
5860
IOInterface $io,
59-
JsonFile $file = null,
60-
string $destination = null,
61-
array $defaults = null
61+
?JsonFile $file = null,
62+
?string $destination = null,
63+
?array $defaults = null
6264
) {
6365
$this->resolver = $resolver;
6466
$this->io = $io;
@@ -71,6 +73,7 @@ public function __construct(
7173
* Install.
7274
*
7375
* @return void
76+
* @throws Exception
7477
*/
7578
public function install(): void
7679
{

src/Installer/ConfigInstaller.php

+3-3
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@
1515
use Youwe\TestingSuite\Composer\ConfigResolver;
1616

1717
/**
18-
* @SuppressWarnings(PHPMD.ShortVariable)
19-
* @SuppressWarnings(PHPMD.StaticAccess)
18+
* @SuppressWarnings("PHPMD.ShortVariable")
19+
* @SuppressWarnings("PHPMD.StaticAccess")
2020
*/
2121
class ConfigInstaller implements InstallerInterface
2222
{
@@ -34,7 +34,7 @@ class ConfigInstaller implements InstallerInterface
3434
*/
3535
public function __construct(
3636
ConfigResolver $resolver,
37-
JsonFile $file = null
37+
?JsonFile $file = null
3838
) {
3939
$this->resolver = $resolver;
4040
$this->file = $file ?? new JsonFile(Factory::getComposerFile());

src/Installer/FilesInstaller.php

+15-9
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
use Youwe\TestingSuite\Composer\MappingResolver;
1616

1717
/**
18-
* @SuppressWarnings(PHPMD.ShortVariable)
18+
* @SuppressWarnings("PHPMD.ShortVariable")
1919
*/
2020
class FilesInstaller implements InstallerInterface
2121
{
@@ -72,7 +72,7 @@ public function install(): void
7272
/**
7373
* @param FileMappingInterface $unixFileMapping
7474
*
75-
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
75+
* @SuppressWarnings("PHPMD.CyclomaticComplexity")
7676
*
7777
* @return void
7878
*/
@@ -87,7 +87,7 @@ private function resolveYouwePathing(FileMappingInterface $unixFileMapping): voi
8787
[
8888
'./vendor/mediact/coding-standard-magento2/src/MediactMagento2',
8989
'./vendor/mediact/coding-standard/src/MediaCT',
90-
'./vendor/youwe/coding-standard-magento2/src/Magento2'
90+
'./vendor/youwe/coding-standard-magento2/src/Magento2',
9191
],
9292
'YouweMagento2'
9393
);
@@ -97,7 +97,7 @@ private function resolveYouwePathing(FileMappingInterface $unixFileMapping): voi
9797
[
9898
'./vendor/mediact/coding-standard-magento2/src/MediactMagento2/phpmd.xml',
9999
'./vendor/mediact/coding-standard/src/MediaCT/phpmd.xml',
100-
'./vendor/youwe/coding-standard-magento2/src/Magento2/phpmd.xml'
100+
'./vendor/youwe/coding-standard-magento2/src/Magento2/phpmd.xml',
101101
],
102102
'./vendor/youwe/coding-standard-magento2/src/YouweMagento2/phpmd.xml'
103103
);
@@ -106,7 +106,7 @@ private function resolveYouwePathing(FileMappingInterface $unixFileMapping): voi
106106
$unixFileMapping->getDestination(),
107107
[
108108
'vendor/mediact/testing-suite/config/default/grumphp.yml',
109-
'vendor/youwe/testing-suite/config/default/grumphp.yml'
109+
'vendor/youwe/testing-suite/config/default/grumphp.yml',
110110
],
111111
'vendor/youwe/testing-suite/config/magento2/grumphp.yml'
112112
);
@@ -115,30 +115,36 @@ private function resolveYouwePathing(FileMappingInterface $unixFileMapping): voi
115115
if ($name === "phpcs.xml") {
116116
$this->updatePath(
117117
$unixFileMapping->getDestination(),
118-
['./vendor/mediact/coding-standard-magento1/src/MediactMagento1'],
118+
[
119+
'./vendor/mediact/coding-standard-magento1/src/MediactMagento1',
120+
],
119121
'./vendor/youwe/coding-standard-magento1/src/Magento1'
120122
);
121123
}
122124
} else {
123125
if ($name === "phpcs.xml") {
124126
$this->updatePath(
125127
$unixFileMapping->getDestination(),
126-
['./vendor/mediact/coding-standard/src/MediaCT'],
128+
[
129+
'./vendor/mediact/coding-standard/src/MediaCT',
130+
],
127131
'./vendor/youwe/coding-standard/src/Global'
128132
);
129133
} elseif ($name === "phpmd.xml") {
130134
$this->updatePath(
131135
$unixFileMapping->getDestination(),
132136
[
133137
'./vendor/mediact/coding-standard/src/MediaCT/phpmd.xml',
134-
'./vendor/youwe/coding-standard-magento2/src/Magento2/phpmd.xml'
138+
'./vendor/youwe/coding-standard-magento2/src/Magento2/phpmd.xml',
135139
],
136140
'./vendor/youwe/coding-standard/src/Global/phpmd.xml'
137141
);
138142
} elseif ($name === "grumphp.yml") {
139143
$this->updatePath(
140144
$unixFileMapping->getDestination(),
141-
['vendor/mediact/testing-suite/config/default/grumphp.yml'],
145+
[
146+
'vendor/mediact/testing-suite/config/default/grumphp.yml',
147+
],
142148
'vendor/youwe/testing-suite/config/default/grumphp.yml'
143149
);
144150
}

0 commit comments

Comments
 (0)