Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions src/Controller/FallbackController.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

namespace App\Controller;

use App\FileSystem\RectorFinder;
Expand Down
2 changes: 1 addition & 1 deletion src/Sets/RectorSetsTreeProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ private function createRectorSetsFromSetProviders(array $sets): array
// Only consider rector classes without configuration, just as in the result list.
$rectorClasses = array_filter(
$setRectorsResolver->resolveFromFilePathIncludingConfiguration($set->getSetFilePath()),
static fn ($rectorClass) => is_string($rectorClass),
is_string(...),
);
if ($rectorClasses !== []) {
$rectorSets[] = new RectorSet($set->getGroupName(), $set->getName(), $rectorClasses);
Expand Down
16 changes: 9 additions & 7 deletions tests/Controller/FallbackControllerTest.php
Original file line number Diff line number Diff line change
@@ -1,30 +1,32 @@
<?php

declare(strict_types=1);

namespace App\Tests\Controller;

use App\Tests\AbstractTestCase;
use Illuminate\Foundation\Http\Middleware\PreventRequestForgery;

class FallbackControllerTest extends AbstractTestCase
final class FallbackControllerTest extends AbstractTestCase
{
public function testRedirectsRuleSlug(): void
{
$response = $this->get('/simplify-array-search-rector');
$testResponse = $this->get('/simplify-array-search-rector');

$response->assertRedirect('/rule-detail/simplify-array-search-rector');
$testResponse->assertRedirect('/rule-detail/simplify-array-search-rector');
}

public function testReturns404ForUnknownSlug(): void
{
$response = $this->get('/unknown-rule');
$testResponse = $this->get('/unknown-rule');

$response->assertNotFound();
$testResponse->assertNotFound();
}

public function testRedirectsWithPascalCaseSlug(): void
{
$response = $this->get('/SimplifyArraySearchRector');
$testResponse = $this->get('/SimplifyArraySearchRector');

$response->assertRedirect('/rule-detail/simplify-array-search-rector');
$testResponse->assertRedirect('/rule-detail/simplify-array-search-rector');
}
}
16 changes: 9 additions & 7 deletions tests/Controller/RuleDetailControllerTest.php
Original file line number Diff line number Diff line change
@@ -1,19 +1,21 @@
<?php

declare(strict_types=1);

namespace App\Tests\Controller;

use App\Tests\AbstractTestCase;
use Illuminate\Foundation\Testing\RefreshDatabase;
use Illuminate\Foundation\Testing\WithFaker;
use Tests\TestCase;

class RuleDetailControllerTest extends AbstractTestCase
final class RuleDetailControllerTest extends AbstractTestCase
{
public function testItRendersRulesBySlug(): void
{
$response = $this->get('/rule-detail/simplify-array-search-rector');
$testResponse = $this->get('/rule-detail/simplify-array-search-rector');

$response
$testResponse
->assertOk()
->assertViewIs('homepage.rule_detail')
->assertViewHas('ruleMetadata')
Expand All @@ -24,15 +26,15 @@ public function testItRendersRulesBySlug(): void

public function testItRedirectsToFindRuleIfRuleNotFound(): void
{
$response = $this->get('/rule-detail/unknown-rule');
$testResponse = $this->get('/rule-detail/unknown-rule');

$response->assertRedirect('/find-rule');
$testResponse->assertRedirect('/find-rule');
}

public function testItRedirectsToKebabCaseSlugIfPascalCaseSlug(): void
{
$response = $this->get('/rule-detail/SimplifyArraySearchRector');
$testResponse = $this->get('/rule-detail/SimplifyArraySearchRector');

$response->assertRedirect('/rule-detail/simplify-array-search-rector');
$testResponse->assertRedirect('/rule-detail/simplify-array-search-rector');
}
}
Loading