Skip to content

Commit d1e64b5

Browse files
authored
Merge pull request #31 from YouweGit/feature/v3-dependency-updates
Refresh PHPUnit setup
2 parents 3e1206b + 07b0731 commit d1e64b5

24 files changed

+392
-333
lines changed

Diff for: .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

Diff for: 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

Diff 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)

Diff for: 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": "*"

Diff for: 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\.#'

Diff for: 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;

Diff for: 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

Diff for: src/Installer/ArchiveExcludeInstaller.php

+11-9
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,13 @@
1212
use Composer\Factory;
1313
use Composer\IO\IOInterface;
1414
use Composer\Json\JsonFile;
15+
use Exception;
1516
use Youwe\FileMapping\FileMappingInterface;
1617
use Youwe\TestingSuite\Composer\MappingResolver;
1718

1819
/**
19-
* @SuppressWarnings(PHPMD.ShortVariable)
20-
* @SuppressWarnings(PHPMD.StaticAccess)
20+
* @SuppressWarnings("PHPMD.ShortVariable")
21+
* @SuppressWarnings("PHPMD.StaticAccess")
2122
*/
2223
class ArchiveExcludeInstaller implements InstallerInterface
2324
{
@@ -41,7 +42,7 @@ class ArchiveExcludeInstaller implements InstallerInterface
4142
'/.env.dev',
4243
'/.gitattributes',
4344
'/.gitignore',
44-
'/tests'
45+
'/tests',
4546
];
4647

4748
/**
@@ -50,15 +51,15 @@ class ArchiveExcludeInstaller implements InstallerInterface
5051
* @param MappingResolver $resolver
5152
* @param IOInterface $io
5253
* @param JsonFile|null $file
53-
* @param string $destination
54+
* @param string |null $destination
5455
* @param array|null $defaults
5556
*/
5657
public function __construct(
5758
MappingResolver $resolver,
5859
IOInterface $io,
59-
JsonFile $file = null,
60-
string $destination = null,
61-
array $defaults = null
60+
?JsonFile $file = null,
61+
?string $destination = null,
62+
?array $defaults = null,
6263
) {
6364
$this->resolver = $resolver;
6465
$this->io = $io;
@@ -71,6 +72,7 @@ public function __construct(
7172
* Install.
7273
*
7374
* @return void
75+
* @throws Exception
7476
*/
7577
public function install(): void
7678
{
@@ -94,7 +96,7 @@ function (FileMappingInterface $mapping): string {
9496
},
9597
iterator_to_array(
9698
$this->resolver->resolve()
97-
)
99+
),
98100
)
99101
);
100102

@@ -107,7 +109,7 @@ function (FileMappingInterface $mapping): string {
107109
$this->io->write(
108110
sprintf(
109111
'<info>Added:</info> %s to archive exclude in composer.json',
110-
$file
112+
$file,
111113
)
112114
);
113115
}

Diff for: src/Installer/ConfigInstaller.php

+6-5
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,13 @@
1010
namespace Youwe\TestingSuite\Composer\Installer;
1111

1212
use Composer\Factory;
13-
use Composer\IO\IOInterface;
1413
use Composer\Json\JsonFile;
14+
use Seld\JsonLint\ParsingException;
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());
@@ -44,6 +44,7 @@ public function __construct(
4444
* Install.
4545
*
4646
* @return void
47+
* @throws ParsingException
4748
*/
4849
public function install(): void
4950
{
@@ -52,7 +53,7 @@ public function install(): void
5253

5354
$config = array_replace_recursive(
5455
$this->resolver->resolve(),
55-
$config
56+
$config,
5657
);
5758

5859
$definition['config'] = $config;

Diff for: src/Installer/FilesInstaller.php

+26-20
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
{
@@ -38,7 +38,7 @@ class FilesInstaller implements InstallerInterface
3838
public function __construct(
3939
MappingResolver $mappingResolver,
4040
ComposerFileInstaller $fileInstaller,
41-
IOInterface $io
41+
IOInterface $io,
4242
) {
4343
$this->mappingResolver = $mappingResolver;
4444
$this->fileInstaller = $fileInstaller;
@@ -63,7 +63,7 @@ public function install(): void
6363
$this->io->write(
6464
sprintf(
6565
'<info>Installed:</info> %s',
66-
$mapping->getRelativeDestination()
66+
$mapping->getRelativeDestination(),
6767
)
6868
);
6969
}
@@ -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,59 +87,65 @@ 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
],
92-
'YouweMagento2'
92+
'YouweMagento2',
9393
);
9494
} elseif ($name === "phpmd.xml") {
9595
$this->updatePath(
9696
$unixFileMapping->getDestination(),
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
],
102-
'./vendor/youwe/coding-standard-magento2/src/YouweMagento2/phpmd.xml'
102+
'./vendor/youwe/coding-standard-magento2/src/YouweMagento2/phpmd.xml',
103103
);
104104
} elseif ($name === "grumphp.yml") {
105105
$this->updatePath(
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
],
111-
'vendor/youwe/testing-suite/config/magento2/grumphp.yml'
111+
'vendor/youwe/testing-suite/config/magento2/grumphp.yml',
112112
);
113113
}
114114
} elseif ($this->mappingResolver->getTypeResolver()->resolve() === 'magento') {
115115
if ($name === "phpcs.xml") {
116116
$this->updatePath(
117117
$unixFileMapping->getDestination(),
118-
['./vendor/mediact/coding-standard-magento1/src/MediactMagento1'],
119-
'./vendor/youwe/coding-standard-magento1/src/Magento1'
118+
[
119+
'./vendor/mediact/coding-standard-magento1/src/MediactMagento1',
120+
],
121+
'./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'],
127-
'./vendor/youwe/coding-standard/src/Global'
128+
[
129+
'./vendor/mediact/coding-standard/src/MediaCT',
130+
],
131+
'./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
],
136-
'./vendor/youwe/coding-standard/src/Global/phpmd.xml'
140+
'./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'],
142-
'vendor/youwe/testing-suite/config/default/grumphp.yml'
145+
[
146+
'vendor/mediact/testing-suite/config/default/grumphp.yml',
147+
],
148+
'vendor/youwe/testing-suite/config/default/grumphp.yml',
143149
);
144150
}
145151
}
@@ -155,13 +161,13 @@ private function resolveYouwePathing(FileMappingInterface $unixFileMapping): voi
155161
private function updatePath(
156162
string $destination,
157163
array $oldPaths,
158-
string $newPath
164+
string $newPath,
159165
): void {
160166
$file = file_get_contents($destination);
161167
$newFile = str_replace(
162168
$oldPaths,
163169
$newPath,
164-
$file
170+
$file,
165171
);
166172
file_put_contents($destination, $newFile);
167173
}

0 commit comments

Comments
 (0)