diff --git a/.github/workflows/e2e-tests.yaml b/.github/workflows/e2e-tests.yaml index c2c01667..67b167b6 100644 --- a/.github/workflows/e2e-tests.yaml +++ b/.github/workflows/e2e-tests.yaml @@ -81,6 +81,8 @@ jobs: - 'e2e_030' - 'e2e_031' - 'e2e_032' + - 'e2e_033' + - 'e2e_034' php: - '8.1' diff --git a/composer.json b/composer.json index 81a2471b..57ea0f3a 100644 --- a/composer.json +++ b/composer.json @@ -32,7 +32,8 @@ "ergebnis/composer-normalize": "^2.28", "humbug/box": "^4.0", "phpspec/prophecy-phpunit": "^2.0", - "phpunit/phpunit": "^9.0" + "phpunit/phpunit": "^9.0", + "symfony/yaml": "^6.1" }, "replace": { "symfony/polyfill-php73": "*" diff --git a/composer.lock b/composer.lock index dd5e69ef..79a2bc89 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "8867aae5e760fa05fe4637f115a507e1", + "content-hash": "b8098ab48a0d8ec909cc16e3e75ab7f0", "packages": [ { "name": "composer/package-versions-deprecated", @@ -5160,6 +5160,80 @@ ], "time": "2022-10-07T08:04:03+00:00" }, + { + "name": "symfony/yaml", + "version": "v6.1.6", + "source": { + "type": "git", + "url": "https://github.com/symfony/yaml.git", + "reference": "66c6b0cf52b00f74614a2cf7ae7db08ea1095931" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/yaml/zipball/66c6b0cf52b00f74614a2cf7ae7db08ea1095931", + "reference": "66c6b0cf52b00f74614a2cf7ae7db08ea1095931", + "shasum": "" + }, + "require": { + "php": ">=8.1", + "symfony/polyfill-ctype": "^1.8" + }, + "conflict": { + "symfony/console": "<5.4" + }, + "require-dev": { + "symfony/console": "^5.4|^6.0" + }, + "suggest": { + "symfony/console": "For validating YAML files using the lint command" + }, + "bin": [ + "Resources/bin/yaml-lint" + ], + "type": "library", + "autoload": { + "psr-4": { + "Symfony\\Component\\Yaml\\": "" + }, + "exclude-from-classmap": [ + "/Tests/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Fabien Potencier", + "email": "fabien@symfony.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Loads and dumps YAML files", + "homepage": "https://symfony.com", + "support": { + "source": "https://github.com/symfony/yaml/tree/v6.1.6" + }, + "funding": [ + { + "url": "https://symfony.com/sponsor", + "type": "custom" + }, + { + "url": "https://github.com/fabpot", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", + "type": "tidelift" + } + ], + "time": "2022-10-07T08:04:03+00:00" + }, { "name": "theseer/tokenizer", "version": "1.2.1", diff --git a/phpstan.neon.dist b/phpstan.neon.dist index 62fdc6b3..6df1b89c 100644 --- a/phpstan.neon.dist +++ b/phpstan.neon.dist @@ -57,3 +57,5 @@ parameters: path: 'src/Scoper/SymfonyScoper.php' - message: '#Class Isolated\\Symfony\\Component\\Finder\\Finder not found\.#' path: 'tests/Configuration/DefaultConfigurationTest.php' + - message: '#Cannot access offset#' + path: 'tests/AutoReview/GAE2ECollector.php' diff --git a/tests/AutoReview/E2ECollectorTest.php b/tests/AutoReview/E2ECollectorTest.php index a2010721..6f3029d9 100644 --- a/tests/AutoReview/E2ECollectorTest.php +++ b/tests/AutoReview/E2ECollectorTest.php @@ -16,7 +16,6 @@ use PHPUnit\Framework\TestCase; use function count; -use function in_array; /** * @covers \Humbug\PhpScoper\AutoReview\E2ECollector @@ -40,6 +39,6 @@ public function test_it_ignores_non_e2e_tests(): void { $names = E2ECollector::getE2ENames(); - self::assertFalse(in_array('e2e_000', $names, true)); + self::assertNotContains('e2e_000', $names); } } diff --git a/tests/AutoReview/GAE2ECollector.php b/tests/AutoReview/GAE2ECollector.php new file mode 100644 index 00000000..e0482515 --- /dev/null +++ b/tests/AutoReview/GAE2ECollector.php @@ -0,0 +1,56 @@ +, + * Pádraic Brady + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Humbug\PhpScoper\AutoReview; + +use Humbug\PhpScoper\NotInstantiable; +use Symfony\Component\Yaml\Yaml; +use function sort; +use const SORT_STRING; + +final class GAE2ECollector +{ + use NotInstantiable; + + private const GA_FILE = __DIR__.'/../../.github/workflows/e2e-tests.yaml'; + + /** + * @return list + */ + public static function getExecutedE2ETests(): array + { + static $names; + + if (!isset($names)) { + $names = self::findE2ENames(); + } + + return $names; + } + + /** + * @return list + */ + private static function findE2ENames(): array + { + $parsedYaml = Yaml::parseFile(self::GA_FILE); + + /** @var string[] $names */ + $names = $parsedYaml['jobs']['e2e-tests']['strategy']['matrix']['e2e']; + + sort($names, SORT_STRING); + + return $names; + } +} diff --git a/tests/AutoReview/GAE2ECollectorTest.php b/tests/AutoReview/GAE2ECollectorTest.php new file mode 100644 index 00000000..1011283d --- /dev/null +++ b/tests/AutoReview/GAE2ECollectorTest.php @@ -0,0 +1,44 @@ +, + * Pádraic Brady + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Humbug\PhpScoper\AutoReview; + +use PHPUnit\Framework\TestCase; +use function count; + +/** + * @covers \Humbug\PhpScoper\AutoReview\GAE2ECollector + * + * @internal + */ +class GAE2ECollectorTest extends TestCase +{ + public function test_it_collects_the_e2e_test_names(): void + { + $names = GAE2ECollector::getExecutedE2ETests(); + + self::assertGreaterThan(0, count($names)); + + foreach ($names as $name) { + self::assertMatchesRegularExpression('/^e2e_\d{3}$/', $name); + } + } + + public function test_it_ignores_non_e2e_tests(): void + { + $names = GAE2ECollector::getExecutedE2ETests(); + + self::assertNotContains('e2e_000', $names); + } +} diff --git a/tests/AutoReview/GAE2ETest.php b/tests/AutoReview/GAE2ETest.php new file mode 100644 index 00000000..b0b89262 --- /dev/null +++ b/tests/AutoReview/GAE2ETest.php @@ -0,0 +1,33 @@ +, + * Pádraic Brady + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Humbug\PhpScoper\AutoReview; + +use PHPUnit\Framework\TestCase; + +/** + * @coversNothing + * + * @internal + */ +class GAE2ETest extends TestCase +{ + public function test_github_actions_executes_all_the_e2e_tests(): void + { + $expected = E2ECollector::getE2ENames(); + $actual = GAE2ECollector::getExecutedE2ETests(); + + self::assertEqualsCanonicalizing($expected, $actual); + } +}