8000 Fix AttributeClassLoaderTestCase · bartrail/symfony@a6b11c6 · GitHub
[go: up one dir, main page]

Skip to content

Commit a6b11c6

Browse files
committed
Fix AttributeClassLoaderTestCase
+ Added ->setUp() - Removed 'abstract' so it'd be picked up by Tests. * Changed getNamespace() to full path Qualified Name. * Rename file AttributeClassLoaderTestCase to AttributeClassLoaderTest and the class.
1 parent 3368c3f commit a6b11c6

File tree

1 file changed

+17
-10
lines changed

1 file changed

+17
-10
lines changed

src/Symfony/Component/Routing/Tests/Loader/AttributeClassLoaderTestCase.php renamed to src/Symfony/Component/Routing/Tests/Loader/AttributeClassLoaderTest.php

Lines changed: 17 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313

1414
use PHPUnit\Framework\TestCase;
1515
use Symfony\Component\Routing\Alias;
16-
use Symfony\Component\Routing\Loader\AttributeClassLoader;
1716
use Symfony\Component\Routing\Tests\Fixtures\AttributeFixtures\AbstractClassController;
1817
use Symfony\Component\Routing\Tests\Fixtures\AttributeFixtures\ActionPathController;
1918
use Symfony\Component\Routing\Tests\Fixtures\AttributeFixtures\BazClass;
@@ -40,10 +39,18 @@
4039
use Symfony\Component\Routing\Tests\Fixtures\AttributeFixtures\RouteWithEnv;
4140
use Symfony\Component\Routing\Tests\Fixtures\AttributeFixtures\RouteWithPrefixController;
4241
use Symfony\Component\Routing\Tests\Fixtures\AttributeFixtures\Utf8ActionControllers;
42+
use Symfony\Component\Routing\Tests\Fixtures\TraceableAttributeClassLoader;
4343

44-
abstract class AttributeClassLoaderTestCase extends TestCase
44+
class AttributeClassLoaderTest extends TestCase
4545
{
46-
protected AttributeClassLoader $loader;
46+
protected TraceableAttributeClassLoader $loader;
47+
48+
protected function setUp(string $env = null): void
49+
{
50+
parent::setUp();
51+
52+
$this->loader = new TraceableAttributeClassLoader($env);
53+
}
4754

4855
/**
4956
* @dataProvider provideTestSupportsChecksResource
@@ -77,7 +84,7 @@ public function testSimplePathRoute()
7784
$routes = $this->loader->load(ActionPathController::class);
7885
$this->assertCount(1, $routes);
7986
$this->assertEquals('/path', $routes->get('action')->getPath());
80-
$this->assertEquals(new Alias('action'), $routes->getAlias('Symfony\Component\Routing\Tests\Fixtures\AttributeFixtures' .'\ActionPathController::action'));
87+
$this->assertEquals(new Alias('action'), $routes->getAlias('Symfony\Component\Routing\Tests\Fixtures\AttributeFixtures\ActionPathController::action'));
8188
}
8289

8390
public function testRequirementsWithoutPlaceholderName()
@@ -101,11 +108,11 @@ public function testInvokableControllerLoader()
101108

102109
public function testInvokableFQCNAliasConflictController()
103110
{
104-
$routes = $this->loader->load($this->getNamespace().'\InvokableFQCNAliasConflictController');
111+
$routes = $this->loader->load('Symfony\Component\Routing\Tests\Fixtures\AttributeFixtures\InvokableFQCNAliasConflictController');
105112
$this->assertCount(1, $routes);
106-
$this->assertEquals('/foobarccc', $routes->get($this->getNamespace().'\InvokableFQCNAliasConflictController')->getPath());
107-
$this->assertNull($routes->getAlias($this->getNamespace().'\InvokableFQCNAliasConflictController'));
108-
$this->assertEquals(new Alias($this->getNamespace().'\InvokableFQCNAliasConflictController'), $routes->getAlias($this->getNamespace().'\InvokableFQCNAliasConflictController::__invoke'));
113+
$this->assertEquals('/foobarccc', $routes->get('Symfony\Component\Routing\Tests\Fixtures\AttributeFixtures\InvokableFQCNAliasConflictController')->getPath());
114+
$this->assertNull($routes->getAlias('Symfony\Component\Routing\Tests\Fixtures\AttributeFixtures\InvokableFQCNAliasConflictController'));
115+
$this->assertEquals(new Alias('Symfony\Component\Routing\Tests\Fixtures\AttributeFixtures\InvokableFQCNAliasConflictController'), $routes->getAlias('Symfony\Component\Routing\Tests\Fixtures\AttributeFixtures\InvokableFQCNAliasConflictController::__invoke'));
109116
}
110117

111118
public function testInvokableMethodControllerLoader()
@@ -164,8 +171,8 @@ public function testMethodActionControllers()
164171
$this->assertSame(['put', 'post'], array_keys($routes->all()));
165172
$this->assertEquals('/the/path', $routes->get('put')->getPath());
166173
$this->assertEquals('/the/path', $routes->get('post')->getPath());
167-
$this->assertEquals(new Alias('post'), $routes->getAlias('Symfony\Component\Routing\Tests\Fixtures\AttributeFixtures' .'\MethodActionControllers::post'));
168-
$this->assertEquals(new Alias('put'), $routes->getAlias('Symfony\Component\Routing\Tests\Fixtures\AttributeFixtures' .'\MethodActionControllers::put'));
174+
$this->assertEquals(new Alias('post'), $routes->getAlias('Symfony\Component\Routing\Tests\Fixtures\AttributeFixtures\MethodActionControllers::post'));
175+
$this->assertEquals(new Alias('put'), $routes->getAlias('Symfony\Component\Routing\Tests\Fixtures\AttributeFixtures\MethodActionControllers::put'));
169176
}
170177

171178
public function testInvokableClassRouteLoadWithMethodAnnotation()

0 commit comments

Comments
 (0)
0