-
Notifications
You must be signed in to change notification settings - Fork 62
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixes duplicate entries and adds a test (#249)
* Fixes duplicate entries and adds a test * CS Fixes
- Loading branch information
Showing
2 changed files
with
74 additions
and
14 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,68 @@ | ||
<?php | ||
|
||
namespace RectorLaravel\Tests\Sets; | ||
|
||
use PHPUnit\Framework\Assert; | ||
use PHPUnit\Framework\TestCase; | ||
use Rector\Set\Contract\SetInterface; | ||
use RectorLaravel\Set\LaravelSetList; | ||
use RectorLaravel\Set\LaravelSetProvider; | ||
|
||
final class LaravelSetProviderTest extends TestCase | ||
{ | ||
private const LARAVEL_VERSION_SETS = [ | ||
LaravelSetList::LARAVEL_50, | ||
LaravelSetList::LARAVEL_51, | ||
LaravelSetList::LARAVEL_52, | ||
LaravelSetList::LARAVEL_53, | ||
LaravelSetList::LARAVEL_54, | ||
LaravelSetList::LARAVEL_55, | ||
LaravelSetList::LARAVEL_56, | ||
LaravelSetList::LARAVEL_57, | ||
LaravelSetList::LARAVEL_58, | ||
LaravelSetList::LARAVEL_60, | ||
LaravelSetList::LARAVEL_70, | ||
LaravelSetList::LARAVEL_80, | ||
LaravelSetList::LARAVEL_90, | ||
LaravelSetList::LARAVEL_100, | ||
LaravelSetList::LARAVEL_110, | ||
]; | ||
|
||
public function testItProvidesSets(): void | ||
{ | ||
$laravelSetProvider = new LaravelSetProvider(); | ||
|
||
Assert::assertContainsOnlyInstancesOf( | ||
SetInterface::class, | ||
$laravelSetProvider->provide() | ||
); | ||
} | ||
|
||
public function testItReturnsUniqueSets(): void | ||
{ | ||
$laravelSetProvider = new LaravelSetProvider(); | ||
|
||
$sets = $laravelSetProvider->provide(); | ||
|
||
$uniqueSets = array_unique(array_map(fn (SetInterface $set) => $set->getSetFilePath(), $sets)); | ||
|
||
Assert::assertCount(count($sets), $uniqueSets); | ||
} | ||
|
||
public function testItProvidesAllLaravelVersions(): void | ||
{ | ||
$laravelSetProvider = new LaravelSetProvider(); | ||
|
||
$sets = $laravelSetProvider->provide(); | ||
|
||
$sets = array_filter( | ||
array_map( | ||
fn (SetInterface $set) => $set->getSetFilePath(), | ||
$sets | ||
), | ||
fn (string $filePath) => in_array($filePath, self::LARAVEL_VERSION_SETS, true), | ||
); | ||
|
||
Assert::assertCount(count(self::LARAVEL_VERSION_SETS), $sets); | ||
} | ||
} |