Skip to content

Commit 8304f25

Browse files
authored
[ci] handle reset-password 8.1.10 version constraint (#1201)
1 parent f048ee3 commit 8304f25

File tree

2 files changed

+39
-1
lines changed

2 files changed

+39
-1
lines changed

src/Test/MakerTestDetails.php

Lines changed: 34 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@ final class MakerTestDetails
2222
private string $rootNamespace = 'App';
2323
private int $requiredPhpVersion = 80000;
2424
private array $requiredPackageVersions = [];
25+
private int $blockedPhpVersionUpper = 0;
26+
private int $blockedPhpVersionLower = 0;
2527

2628
public function __construct(
2729
private MakerInterface $maker,
@@ -73,6 +75,22 @@ public function setRequiredPhpVersion(int $version): self
7375
return $this;
7476
}
7577

78+
/**
79+
* Skip a test from running between a range of PHP Versions.
80+
*
81+
* @param int $lowerLimit Versions below this value will be allowed
82+
* @param int $upperLimit Versions above this value will be allowed
83+
*
84+
* @internal
85+
*/
86+
public function setSkippedPhpVersions(int $lowerLimit, int $upperLimit): self
87+
{
88+
$this->blockedPhpVersionUpper = $upperLimit;
89+
$this->blockedPhpVersionLower = $lowerLimit;
90+
91+
return $this;
92+
}
93+
7694
public function addRequiredPackageVersion(string $packageName, string $versionConstraint): self
7795
{
7896
$this->requiredPackageVersions[] = ['name' => $packageName, 'version_constraint' => $versionConstraint];
@@ -118,7 +136,22 @@ public function getDependencyBuilder(): DependencyBuilder
118136

119137
public function isSupportedByCurrentPhpVersion(): bool
120138
{
121-
return \PHP_VERSION_ID >= $this->requiredPhpVersion;
139+
$hasPhpVersionConstraint = $this->blockedPhpVersionLower > 0 && $this->blockedPhpVersionUpper > 0;
140+
$isSupported = false;
141+
142+
if (!$hasPhpVersionConstraint) {
143+
$isSupported = true;
144+
}
145+
146+
if (\PHP_VERSION_ID > $this->blockedPhpVersionUpper) {
147+
$isSupported = true;
148+
}
149+
150+
if (\PHP_VERSION_ID < $this->blockedPhpVersionLower) {
151+
$isSupported = true;
152+
}
153+
154+
return $isSupported && \PHP_VERSION_ID >= $this->requiredPhpVersion;
122155
}
123156

124157
public function getRequiredPackageVersions(): array

tests/Maker/MakeResetPasswordTest.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ protected function getMakerClass(): string
2727
public function getTestDetails(): \Generator
2828
{
2929
yield 'it_generates_with_normal_setup' => [$this->createMakerTest()
30+
->setSkippedPhpVersions(80100, 80109)
3031
->run(function (MakerTestRunner $runner) {
3132
$this->makeUser($runner);
3233

@@ -81,6 +82,7 @@ public function getTestDetails(): \Generator
8182
];
8283

8384
yield 'it_generates_with_translator_installed' => [$this->createMakerTest()
85+
->setSkippedPhpVersions(80100, 80109)
8486
->addExtraDependencies('symfony/translation')
8587
->run(function (MakerTestRunner $runner) {
8688
$this->makeUser($runner);
@@ -97,6 +99,7 @@ public function getTestDetails(): \Generator
9799
];
98100

99101
yield 'it_generates_with_custom_config' => [$this->createMakerTest()
102+
->setSkippedPhpVersions(80100, 80109)
100103
->run(function (MakerTestRunner $runner) {
101104
$runner->deleteFile('config/packages/reset_password.yaml');
102105
$runner->writeFile(
@@ -131,6 +134,7 @@ public function getTestDetails(): \Generator
131134
];
132135

133136
yield 'it_amends_configuration' => [$this->createMakerTest()
137+
->setSkippedPhpVersions(80100, 80109)
134138
->run(function (MakerTestRunner $runner) {
135139
$runner->modifyYamlFile('config/packages/reset_password.yaml', function (array $config) {
136140
$config['symfonycasts_reset_password']['lifetime'] = 9999;
@@ -157,6 +161,7 @@ public function getTestDetails(): \Generator
157161
];
158162

159163
yield 'it_generates_with_custom_user' => [$this->createMakerTest()
164+
->setSkippedPhpVersions(80100, 80109)
160165
->run(function (MakerTestRunner $runner) {
161166
$this->makeUser($runner, 'emailAddress', 'UserCustom', false);
162167

0 commit comments

Comments
 (0)