8000 Copy tests from https://github.com/symfony/symfony/pull/48170 · symfony/symfony@3bf53c8 · GitHub
[go: up one dir, main page]

Skip to content

Commit 3bf53c8

Browse files
committed
Copy tests from #48170
1 parent 45eea41 commit 3bf53c8

File tree

4 files changed

+80
-0
lines changed

4 files changed

+80
-0
lines changed
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
<?php
2+
3+
/*
4+
* This file is part of the Symfony package.
5+
*
6+
* (c) Fabien Potencier <fabien@symfony.com>
7+
*
8+
* For the full copyright and license information, please view the LICENSE
9+
* file that was distributed with this source code.
10+
*/
11+
12+
namespace Symfony\Component\Routing\Tests\Fixtures\Psr4Controllers\SubNamespace;
13+
14+
use Symfony\Component\HttpFoundation\Response;
15+
16+
/**
17+
* An irrelevant class.
18+
*
19+
* This fixture is not referenced anywhere. Its presence makes sure, classes without attributes are silently ignored
20+
* when loading routes from a directory.
21+
*/
22+
final class IrrelevantClass
23+
{
24+
public function irrelevantAction(): Response
25+
{
26+
return new Response(status: Response::HTTP_NO_CONTENT);
27+
}
28+
}
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
<?php
2+
3+
/*
4+
* This file is part of the Symfony package.
5+
*
6+
* (c) Fabien Potencier <fabien@symfony.com>
7+
*
8+
* For the full copyright and license information, please view the LICENSE
9+
* file that was distributed with this source code.
10+
*/
11+
12+
namespace Symfony\Component\Routing\Tests\Fixtures\Psr4Controllers\SubNamespace;
13+
14+
use Symfony\Component\HttpFoundation\Response;
15+
use Symfony\Component\Routing\Annotation\Route;
16+
17+
abstract class MyAbstractController
18+
{
19+
#[Route('/a/route/from/an/abstract/controller', name: 'from_abstract')]
20+
public function someAction(): Response
21+
{
22+
return new Response(status: Response::HTTP_NO_CONTENT);
23+
}
24+
}
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
<?php
2+
3+
/*
4+
* This file is part of the Symfony package.
5+
*
6+
* (c) Fabien Potencier <fabien@symfony.com>
7+
*
8+
* For the full copyright and license information, please view the LICENSE
9+
* file that was distributed with this source code.
10+
*/
11+
12+
namespace Symfony\Component\Routing\Tests\Fixtures\Psr4Controllers\SubNamespace;
13+
14+
use Symfony\Component\Routing\Annotation\Route;
15+
16+
#[Route('/my/child/controller', name: 'my_child_controller_')]
17+
final class MyChildController extends MyAbstractController
18+
{
19+
}

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

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
use Symfony\Component\Routing\RouteCollection;
2222
use Symfony\Component\Routing\Tests\Fixtures\Psr4Controllers\MyController;
2323
use Symfony\Component\Routing\Tests\Fixtures\Psr4Controllers\SubNamespace\EvenDeeperNamespace\MyOtherController;
24+
use Symfony\Component\Routing\Tests\Fixtures\Psr4Controllers\SubNamespace\MyChildController;
2425
use Symfony\Component\Routing\Tests\Fixtures\Psr4Controllers\SubNamespace\MyControllerWithATrait;
2526

2627
class Psr4DirectoryLoaderTest extends TestCase
@@ -56,6 +57,14 @@ public function testTraitController()
5657
$this->assertSame(MyControllerWithATrait::class.'::someAction', $route->getDefault('_controller'));
5758
}
5859

60+
public function testAbstractController()
61+
{
62+
$route = $this->loadPsr4Controllers()->get('my_child_controller_from_abstract');
63+
64+
$this->assertSame('/my/child/controller/a/route/from/an/abstract/controller', $route->getPath());
65+
$this->assertSame(MyChildController::class.'::someAction', $route->getDefault('_controller'));
66+
}
67+
5968
/**
6069
* @dataProvider provideNamespacesThatNeedTrimming
6170
*/

0 commit comments

Comments
 (0)
0