Skip to content

Commit 73c6d1d

Browse files
authored
Add test to ensure all the e2e tests are listed in the GitHub Actions workflow (#778)
1 parent ede4ea9 commit 73c6d1d

File tree

8 files changed

+215
-4
lines changed

8 files changed

+215
-4
lines changed

.github/workflows/e2e-tests.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,8 @@ jobs:
8181
- 'e2e_030'
8282
- 'e2e_031'
8383
- 'e2e_032'
84+
- 'e2e_033'
85+
- 'e2e_034'
8486
php:
8587
- '8.1'
8688

composer.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,8 @@
3232
"ergebnis/composer-normalize": "^2.28",
3333
"humbug/box": "^4.0",
3434
"phpspec/prophecy-phpunit": "^2.0",
35-
"phpunit/phpunit": "^9.0"
35+
"phpunit/phpunit": "^9.0",
36+
"symfony/yaml": "^6.1"
3637
},
3738
"replace": {
3839
"symfony/polyfill-php73": "*"

composer.lock

Lines changed: 75 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

phpstan.neon.dist

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,3 +57,5 @@ parameters:
5757
path: 'src/Scoper/SymfonyScoper.php'
5858
- message: '#Class Isolated\\Symfony\\Component\\Finder\\Finder not found\.#'
5959
path: 'tests/Configuration/DefaultConfigurationTest.php'
60+
- message: '#Cannot access offset#'
61+
path: 'tests/AutoReview/GAE2ECollector.php'

tests/AutoReview/E2ECollectorTest.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616

1717
use PHPUnit\Framework\TestCase;
1818
use function count;
19-
use function in_array;
2019

2120
/**
2221
* @covers \Humbug\PhpScoper\AutoReview\E2ECollector
@@ -40,6 +39,6 @@ public function test_it_ignores_non_e2e_tests(): void
4039
{
4140
$names = E2ECollector::getE2ENames();
4241

43-
self::assertFalse(in_array('e2e_000', $names, true));
42+
self::assertNotContains('e2e_000', $names);
4443
}
4544
}
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
/*
6+
* This file is part of the humbug/php-scoper package.
7+
*
8+
* Copyright (c) 2017 Théo FIDRY <[email protected]>,
9+
* Pádraic Brady <[email protected]>
10+
*
11+
* For the full copyright and license information, please view the LICENSE
12+
* file that was distributed with this source code.
13+
*/
14+
15+
namespace Humbug\PhpScoper\AutoReview;
16+
17+
use Humbug\PhpScoper\NotInstantiable;
18+
use Symfony\Component\Yaml\Yaml;
19+
use function sort;
20+
use const SORT_STRING;
21+
22+
final class GAE2ECollector
23+
{
24+
use NotInstantiable;
25+
26+
private const GA_FILE = __DIR__.'/../../.github/workflows/e2e-tests.yaml';
27+
28+
/**
29+
* @return list<string>
30+
*/
31+
public static function getExecutedE2ETests(): array
32+
{
33+
static $names;
34+
35+
if (!isset($names)) {
36+
$names = self::findE2ENames();
37+
}
38+
39+
return $names;
40+
}
41+
42+
/**
43+
* @return list<string>
44+
*/
45+
private static function findE2ENames(): array
46+
{
47+
$parsedYaml = Yaml::parseFile(self::GA_FILE);
48+
49+
/** @var string[] $names */
50+
$names = $parsedYaml['jobs']['e2e-tests']['strategy']['matrix']['e2e'];
51+
52+
sort($names, SORT_STRING);
53+
54+
return $names;
55+
}
56+
}
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
/*
6+
* This file is part of the humbug/php-scoper package.
7+
*
8+
* Copyright (c) 2017 Théo FIDRY <[email protected]>,
9+
* Pádraic Brady <[email protected]>
10+
*
11+
* For the full copyright and license information, please view the LICENSE
12+
* file that was distributed with this source code.
13+
*/
14+
15+
namespace Humbug\PhpScoper\AutoReview;
16+
17+
use PHPUnit\Framework\TestCase;
18+
use function count;
19+
20+
/**
21+
* @covers \Humbug\PhpScoper\AutoReview\GAE2ECollector
22+
*
23+
* @internal
24+
*/
25+
class GAE2ECollectorTest extends TestCase
26+
{
27+
public function test_it_collects_the_e2e_test_names(): void
28+
{
29+
$names = GAE2ECollector::getExecutedE2ETests();
30+
31+
self::assertGreaterThan(0, count($names));
32+
33+
foreach ($names as $name) {
34+
self::assertMatchesRegularExpression('/^e2e_\d{3}$/', $name);
35+
}
36+
}
37+
38+
public function test_it_ignores_non_e2e_tests(): void
39+
{
40+
$names = GAE2ECollector::getExecutedE2ETests();
41+
42+
self::assertNotContains('e2e_000', $names);
43+
}
44+
}

tests/AutoReview/GAE2ETest.php

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
/*
6+
* This file is part of the humbug/php-scoper package.
7+
*
8+
* Copyright (c) 2017 Théo FIDRY <[email protected]>,
9+
* Pádraic Brady <[email protected]>
10+
*
11+
* For the full copyright and license information, please view the LICENSE
12+
* file that was distributed with this source code.
13+
*/
14+
15+
namespace Humbug\PhpScoper\AutoReview;
16+
17+
use PHPUnit\Framework\TestCase;
18+
19+
/**
20+
* @coversNothing
21+
*
22+
* @internal
23+
*/
24+
class GAE2ETest extends TestCase
25+
{
26+
public function test_github_actions_executes_all_the_e2e_tests(): void
27+
{
28+
$expected = E2ECollector::getE2ENames();
29+
$actual = GAE2ECollector::getExecutedE2ETests();
30+
31+
self::assertEqualsCanonicalizing($expected, $actual);
32+
}
33+
}

0 commit comments

Comments
 (0)