humbug /
box
| 1 | <?php |
||
| 2 | |||
| 3 | declare(strict_types=1); |
||
| 4 | |||
| 5 | /* |
||
| 6 | * This file is part of the box project. |
||
| 7 | * |
||
| 8 | * (c) Kevin Herrera <[email protected]> |
||
| 9 | * Théo Fidry <[email protected]> |
||
| 10 | * |
||
| 11 | * This source file is subject to the MIT license that is bundled |
||
| 12 | * with this source code in the file LICENSE. |
||
| 13 | */ |
||
| 14 | |||
| 15 | namespace KevinGH\RequirementChecker\AutoReview; |
||
| 16 | |||
| 17 | use Fidry\Makefile\Rule; |
||
| 18 | use Fidry\Makefile\Test\BaseMakefileTestCase; |
||
| 19 | use PHPUnit\Framework\Attributes\CoversNothing; |
||
| 20 | |||
| 21 | /** |
||
| 22 | * @internal |
||
| 23 | */ |
||
| 24 | #[CoversNothing] |
||
| 25 | final class E2EMakefileTest extends BaseMakefileTestCase |
||
| 26 | { |
||
| 27 | public const MAKEFILE_PATH = __DIR__.'/../../Makefile.e2e'; |
||
| 28 | |||
| 29 | protected static function getMakefilePath(): string |
||
| 30 | { |
||
| 31 | return self::MAKEFILE_PATH; |
||
| 32 | } |
||
| 33 | |||
| 34 | protected function getExpectedHelpOutput(): string |
||
| 35 | { |
||
| 36 | self::markTestSkipped('There is no help command.'); |
||
|
0 ignored issues
–
show
|
|||
| 37 | } |
||
| 38 | |||
| 39 | public function test_the_e2e_target_must_contain_all_the_e2e_targets(): void |
||
| 40 | { |
||
| 41 | $e2eRule = MakefileE2ECollector::getE2ERule(); |
||
| 42 | $e2eTestTargets = self::getE2ETestRules(); |
||
| 43 | |||
| 44 | $e2eRulePrerequisites = $e2eRule->getPrerequisites(); |
||
| 45 | array_shift($e2eRulePrerequisites); // Remove docker-images |
||
| 46 | |||
| 47 | // Sanity check |
||
| 48 | self::assertGreaterThan(0, count($e2eRule->getPrerequisites())); |
||
| 49 | |||
| 50 | self::assertEqualsCanonicalizing( |
||
| 51 | $e2eRulePrerequisites, |
||
| 52 | array_map( |
||
| 53 | static fn (Rule $rule) => $rule->getTarget(), |
||
| 54 | $e2eTestTargets, |
||
| 55 | ), |
||
| 56 | ); |
||
| 57 | } |
||
| 58 | |||
| 59 | /** |
||
| 60 | * @return Rule |
||
| 61 | */ |
||
| 62 | private static function getE2ETestRules(): array |
||
| 63 | { |
||
| 64 | return array_values( |
||
|
0 ignored issues
–
show
|
|||
| 65 | array_filter( |
||
| 66 | self::getParsedRules(), |
||
| 67 | static fn (Rule $rule) => str_starts_with($rule->getTarget(), '_test_e2e_') && !$rule->isComment() && !$rule->isPhony(), |
||
| 68 | ), |
||
| 69 | ); |
||
| 70 | } |
||
| 71 | } |
||
| 72 |
For hinted functions/methods where all return statements with the correct type are only reachable via conditions, ?null? gets implicitly returned which may be incompatible with the hinted type. Let?s take a look at an example: