Skip to content

Commit 5a9de1a

Browse files
authored
Merge pull request #605 from deguif/review-controller-annotation-tests
Review annotations in controller tests
2 parents 9d95754 + fd189a1 commit 5a9de1a

File tree

11 files changed

+46
-43
lines changed

11 files changed

+46
-43
lines changed

Tests/Functional/AppKernel.php

+4-2
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,9 @@
3232

3333
class AppKernel extends Kernel
3434
{
35-
private $config;
35+
private string|null $config;
3636

37-
private $fwConfig;
37+
private string $fwConfig;
3838

3939
public function __construct(string $fwConfig, ?string $config)
4040
{
@@ -75,6 +75,8 @@ public function registerContainerConfiguration(LoaderInterface $loader)
7575
if ($this->config) {
7676
$loader->load($this->config);
7777
}
78+
79+
$loader->load($this->getProjectDir() . '/config/services.yaml');
7880
}
7981

8082
public function getCacheDir(): string

Tests/Functional/Fixture/TestBundle/Controller/AppleController.php

+12-16
Original file line numberDiff line numberDiff line change
@@ -4,31 +4,27 @@
44

55
namespace JMS\TranslationBundle\Tests\Functional\Fixture\TestBundle\Controller;
66

7-
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Template;
7+
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
8+
use Symfony\Component\HttpFoundation\Response;
9+
use Symfony\Component\HttpKernel\Attribute\AsController;
810
use Symfony\Component\Routing\Annotation\Route;
911

1012
/**
1113
* @author Johannes
12-
*
13-
* @Route("/apples")
1414
*/
15-
class AppleController
15+
#[AsController()]
16+
#[Route('/apples')]
17+
class AppleController extends AbstractController
1618
{
17-
/**
18-
* @Route("/view")
19-
* @Template("@Test/Apple/view.html.twig")
20-
*/
21-
public function viewAction()
19+
#[Route('/view')]
20+
public function viewAction(): Response
2221
{
23-
return ['nbApples' => 5];
22+
return $this->render('@Test/Apple/view.html.twig', ['nbApples' => 5]);
2423
}
2524

26-
/**
27-
* @Route("/view_sf5")
28-
* @Template("@Test/Apple/view_sf5.html.twig")
29-
*/
30-
public function viewsf5Action()
25+
#[Route('/view_sf5')]
26+
public function viewsf5Action(): Response
3127
{
32-
return ['nbApples' => 5];
28+
return $this->render('@Test/Apple/view_sf5.html.twig', ['nbApples' => 5]);
3329
}
3430
}

Tests/Functional/config/default.yml

-7
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,3 @@ imports:
66
framework:
77
templating:
88
engines: [twig, php]
9-
10-
parameters:
11-
translation_output_dir: "%kernel.project_dir%/Fixture/TestBundle/Resources/translations"
12-
13-
services:
14-
logger:
15-
class: Psr\Log\NullLogger
-7
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,3 @@
11
imports:
22
- { resource: twig.yml }
33
- { resource: bundle.yml }
4-
5-
parameters:
6-
translation_output_dir: "%kernel.project_dir%/Fixture/TestBundle/Resources/translations"
7-
8-
services:
9-
logger:
10-
class: Psr\Log\NullLogger

Tests/Functional/config/framework.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,4 @@ framework:
1313
translator:
1414
enabled: true
1515
router:
16-
resource: "%kernel.project_dir%/config/routing.yml"
16+
resource: "%kernel.project_dir%/config/routing.yaml"

Tests/Functional/config/framework_sf6.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,4 @@ framework:
1313
translator:
1414
enabled: true
1515
router:
16-
resource: "%kernel.project_dir%/config/routing.yml"
16+
resource: "%kernel.project_dir%/config/routing_sf6.yaml"

Tests/Functional/config/routing.yaml

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
JMSTranslationBundle_ui:
2+
resource: '@JMSTranslationBundle/Controller/'
3+
type: 'annotation'
4+
prefix: /_trans
5+
6+
TestBundle:
7+
resource: '@TestBundle/Controller/'
8+
type: 'annotation'

Tests/Functional/config/routing.yml

-8
This file was deleted.
+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
JMSTranslationBundle_ui:
2+
resource: '@JMSTranslationBundle/Controller/'
3+
type: 'attribute'
4+
prefix: /_trans
5+
6+
TestBundle:
7+
resource: '@TestBundle/Controller/'
8+
type: 'attribute'

Tests/Functional/config/services.yaml

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
parameters:
2+
translation_output_dir: '%kernel.project_dir%/Fixture/TestBundle/Resources/translations'
3+
4+
services:
5+
logger:
6+
class: Psr\Log\NullLogger
7+
8+
JMS\TranslationBundle\Tests\Functional\Fixture\TestBundle\Controller\:
9+
resource: '@TestBundle/Controller/'
10+
autowire: true
11+
autoconfigure: true

composer.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535
},
3636
"require-dev": {
3737
"doctrine/annotations": "^1.11",
38-
"doctrine/coding-standard": "^8.2.1",
38+
"doctrine/coding-standard": "^9.0",
3939
"matthiasnoback/symfony-dependency-injection-test": "^4.1",
4040
"nyholm/nsa": "^1.0.1",
4141
"symfony/phpunit-bridge": "^5.4 || ^6.4",

0 commit comments

Comments
 (0)