Skip to content

Commit 9cc7a37

Browse files
committed
refactor: review annotations in controller tests
1 parent 24d6800 commit 9cc7a37

File tree

11 files changed

+44
-41
lines changed

11 files changed

+44
-41
lines changed

Tests/Functional/AppKernel.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -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

Lines changed: 12 additions & 16 deletions
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

Lines changed: 0 additions & 7 deletions
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
Lines changed: 0 additions & 7 deletions
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

Lines changed: 1 addition & 1 deletion
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

Lines changed: 1 addition & 1 deletion
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"
Lines changed: 8 additions & 0 deletions
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

Lines changed: 0 additions & 8 deletions
This file was deleted.
Lines changed: 8 additions & 0 deletions
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'
Lines changed: 11 additions & 0 deletions
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

0 commit comments

Comments
 (0)