8000 minor #51084 [Routing] Fix `testMissingPrefixLocale` and `testMissing… · symfony/symfony@8b82019 · GitHub
[go: up one dir, main page]

Skip to content

Commit 8b82019

Browse files
minor #51084 [Routing] Fix testMissingPrefixLocale and testMissingRouteLocale (derrabus)
This PR was merged into the 5.4 branch. Discussion ---------- [Routing] Fix `testMissingPrefixLocale` and `testMissingRouteLocale` | Q | A | ------------- | --- | Branch? | 5.4 | Bug fix? | yes | New feature? | no | Deprecations? | no | Tickets | #51082 (comment) | License | MIT | Doc PR | not needed Those two fixtures only exist as annotation versions. Their attribute counterparts were missing. The corresponding tests only expected a `LogicException` which is what `AnnotationClassLoader` would raise for undefined classes as well. This PR adds new assertions for the exception messages which would have discovered the missing fixtures. Finally, the two missing fixtures are added. Commits ------- 6ba9864 [Routing] Fix testMissingPrefixLocale and testMissingRouteLocale
2 parents 0bc39e8 + 6ba9864 commit 8b82019

File tree

3 files changed

+30
-0
lines changed

3 files changed

+30
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<?php
2+
3+
namespace Symfony\Component\Routing\Tests\Fixtures\AttributeFixtures;
4+
5+
use Symfony\Component\Routing\Annotation\Route;
6+
7+
#[Route(path: ['nl' => '/nl'])]
8+
class LocalizedPrefixMissingLocaleActionController
9+
{
10+
#[Route(path: ['nl' => '/actie', 'en' => '/action'], name: 'action')]
11+
public function action()
12+
{
13+
}
14+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<?php
2+
3+
namespace Symfony\Component\Routing\Tests\Fixtures\AttributeFixtures;
4+
5+
use Symfony\Component\Routing\Annotation\Route;
6+
7+
#[Route(path: ['nl' => '/nl', 'en' => '/en'])]
8+
class LocalizedPrefixMissingRouteLocaleActionController
9+
{
10+
#[Route(path: ['nl' => '/actie'], name: 'action')]
11+
public function action()
12+
{
13+
}
14+
}

src/Symfony/Component/Routing/Tests/Loader/AnnotationClassLoaderTestCase.php

+2
Original file line numberDiff line numberDiff line change
@@ -197,12 +197,14 @@ public function testInvokableClassMultipleRouteLoad()
197197
public function testMissingPrefixLocale()
198198
{
199199
$this->expectException(\LogicException::class);
200+
$this->expectExceptionMessage(sprintf('Route to "action" with locale "en" is missing a corresponding prefix in class "%s\LocalizedPrefixMissingLocaleActionController".', $this->getNamespace()));
200201
$this->loader->load($this->getNamespace().'\LocalizedPrefixMissingLocaleActionController');
201202
}
202203

203204
public function testMissingRouteLocale()
204205
{
205206
$this->expectException(\LogicException::class);
207+
$this->expectExceptionMessage(sprintf('Route to "%s\LocalizedPrefixMissingRouteLocaleActionController::action" is missing paths for locale(s) "en".', $this->getNamespace()));
206208
$this->loader->load($this->getNamespace().'\LocalizedPrefixMissingRouteLocaleActionController');
207209
}
208210

0 commit comments

Comments
 (0)
0