-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[FEATURE] Exclude release candidate versions from platform versions
- Loading branch information
Showing
3 changed files
with
61 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace MobilisticsGmbH\MamoConnector\Service; | ||
|
||
class VersionFilterService | ||
{ | ||
/** | ||
* Remove all release candidates from the given array of versions. | ||
* | ||
* Note: this currently does not do proper semver parsing, and only checks for the string 'rc' in the version. | ||
* | ||
* @param array<string> $versions | ||
* @return array<string> | ||
*/ | ||
public function removeReleaseCandidates(array $versions): array | ||
{ | ||
return array_values( | ||
array_filter( | ||
$versions, | ||
static fn ($version) => ! str_contains(strtolower($version), 'rc') | ||
) | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace MobilisticsGmbH\MamoConnector\Tests\Service; | ||
|
||
use MobilisticsGmbH\MamoConnector\Service\VersionFilterService; | ||
use PHPUnit\Framework\TestCase; | ||
|
||
class VersionFilterServiceTest extends TestCase | ||
{ | ||
public function testRemoveRCDoesNotChangeWhenNoRCVersions(): void | ||
{ | ||
$versions = ['6.4.20.2', '6.5.8.2']; | ||
|
||
$filteredVersions = $this->getFilterVersionService()->removeReleaseCandidates($versions); | ||
static::assertSame($versions, $filteredVersions); | ||
} | ||
|
||
public function testRemoveRCRemovesRCVersions(): void | ||
{ | ||
$versions = ['6.4.20.2', '6.5.8.2', '6.6.0.0-rc1']; | ||
|
||
$filteredVersions = $this->getFilterVersionService()->removeReleaseCandidates($versions); | ||
static::assertSame(['6.4.20.2', '6.5.8.2'], $filteredVersions); | ||
} | ||
|
||
private function getFilterVersionService(): VersionFilterService | ||
{ | ||
return new VersionFilterService(); | ||
} | ||
} |