Skip to content

Commit 5ff096a

Browse files
committed
whipped up route annotation test
1 parent ce5a15e commit 5ff096a

File tree

2 files changed

+39
-0
lines changed

2 files changed

+39
-0
lines changed

tests/Maker/MakeControllerTest.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,5 +106,15 @@ public function getTestDetails()
106106
$this->assertStringContainsString('created: templates/foo/bar/cool/index.html.twig', $output);
107107
}),
108108
];
109+
110+
yield 'controller_uses_attributes' => [MakerTestDetails::createTest(
111+
$this->getMakerInstance(MakeController::class),
112+
[
113+
'AttributeController',
114+
])
115+
->addExtraDependencies('twig')
116+
->setRequiredPhpVersion(80000)
117+
->setFixtureFilesPath(__DIR__.'/../fixtures/MakeControllerAttributes'),
118+
];
109119
}
110120
}
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
<?php
2+
3+
namespace App\Tests;
4+
5+
use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;
6+
7+
/**
8+
* @author Jesse Rushlow <[email protected]>
9+
*/
10+
class GeneratedControllerTest extends WebTestCase
11+
{
12+
/**
13+
* This tests passes as is, but I can do better.....
14+
*/
15+
public function testControllerHasRouteAttribute(): void
16+
{
17+
self::markTestIncomplete('Im a WIP');
18+
19+
$reflected = new \ReflectionClass(\App\Controller\AttributeController::class);
20+
21+
$methodAttributes = $reflected->getMethods()[0]->getAttributes();
22+
23+
self::assertCount(1, $methodAttributes);
24+
25+
$attributeName = $methodAttributes[0]->getName();
26+
27+
self::assertSame('Symfony\Component\Routing\Annotation\Route', $attributeName);
28+
}
29+
}

0 commit comments

Comments
 (0)