Skip to content

Commit 5f9b8eb

Browse files
Merge pull request #662 from alexislefebvre/chore-migrate-conf-files-to-PHP
chore: migrate configuration files to PHP and attributes
2 parents ebeea41 + f371799 commit 5f9b8eb

File tree

10 files changed

+80
-72
lines changed

10 files changed

+80
-72
lines changed

.github/workflows/tests.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -93,8 +93,8 @@ jobs:
9393
phpunit/phpunit=${{ matrix.phpunit-version }}
9494
9595
# This is needed to fix builds where the `annotation_reader` service may not be set up if
96-
# the Annotations package is not in the production dependencies
97-
- name: Require Annotations v1/v2 to require for PHP 8+
96+
# the doctrine/annotations package is not in the production dependencies
97+
- name: Move doctrine/annotations v1/v2 to require (non-dev) for PHP 8+
9898
run: composer require --no-update "doctrine/annotations:^1.8.0|^2.0"
9999

100100
- name: Install Composer dependencies

src/DependencyInjection/LiipFunctionalTestExtension.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515

1616
use Symfony\Component\Config\FileLocator;
1717
use Symfony\Component\DependencyInjection\ContainerBuilder;
18-
use Symfony\Component\DependencyInjection\Loader\XmlFileLoader;
18+
use Symfony\Component\DependencyInjection\Loader\PhpFileLoader;
1919
use Symfony\Component\HttpKernel\DependencyInjection\Extension;
2020

2121
class LiipFunctionalTestExtension extends Extension
@@ -27,11 +27,11 @@ public function load(array $configs, ContainerBuilder $container): void
2727
{
2828
$config = $this->processConfiguration(new Configuration(), $configs);
2929

30-
$loader = new XmlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config'));
31-
$loader->load('functional_test.xml');
30+
$loader = new PhpFileLoader($container, new FileLocator(__DIR__.'/../Resources/config'));
31+
$loader->load('functional_test.php');
3232

3333
if (interface_exists('Symfony\Component\Validator\Validator\ValidatorInterface')) {
34-
$loader->load('validator.xml');
34+
$loader->load('validator.php');
3535
}
3636

3737
foreach ($config as $key => $value) {
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
<?php
2+
3+
/*
4+
* This file is part of the Liip/FunctionalTestBundle
5+
*
6+
* (c) Lukas Kahwe Smith <[email protected]>
7+
*
8+
* This source file is subject to the MIT license that is bundled
9+
* with this source code in the file LICENSE.
10+
*/
11+
12+
namespace Symfony\Component\DependencyInjection\Loader\Configurator;
13+
14+
return static function (ContainerConfigurator $container) {
15+
$services = $container->services();
16+
17+
$services->set('liip_functional_test.exception_listener', \Liip\FunctionalTestBundle\EventListener\ExceptionListener::class)
18+
->public()
19+
->tag('kernel.event_subscriber');
20+
21+
$services->set('liip_functional_test.query.count_client', \Liip\FunctionalTestBundle\QueryCountClient::class)
22+
->args([
23+
service('kernel'),
24+
'%test.client.parameters%',
25+
service('test.client.history'),
26+
service('test.client.cookiejar'),
27+
])
28+
->call('setQueryCounter', [service('liip_functional_test.query.counter')]);
29+
30+
$services->set('liip_functional_test.query.counter', \Liip\FunctionalTestBundle\QueryCounter::class)
31+
->args([
32+
'%liip_functional_test.query.max_query_count%',
33+
service('annotation_reader')->nullOnInvalid(),
34+
]);
35+
};

src/Resources/config/functional_test.xml

Lines changed: 0 additions & 27 deletions
This file was deleted.

src/Resources/config/validator.php

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
<?php
2+
3+
/*
4+
* This file is part of the Liip/FunctionalTestBundle
5+
*
6+
* (c) Lukas Kahwe Smith <[email protected]>
7+
*
8+
* This source file is subject to the MIT license that is bundled
9+
* with this source code in the file LICENSE.
10+
*/
11+
12+
namespace Symfony\Component\DependencyInjection\Loader\Configurator;
13+
14+
return static function (ContainerConfigurator $container) {
15+
$services = $container->services();
16+
17+
$services->set('liip_functional_test.validator', \Liip\FunctionalTestBundle\Validator\DataCollectingValidator::class)
18+
->public()
19+
->decorate('validator', 'validator.inner', 0, \Symfony\Component\DependencyInjection\ContainerInterface::IGNORE_ON_INVALID_REFERENCE)
20+
->args([service('validator.inner')->ignoreOnInvalid()])
21+
->tag('kernel.event_subscriber');
22+
};

src/Resources/config/validator.xml

Lines changed: 0 additions & 18 deletions
This file was deleted.

tests/App/Entity/User.php

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,26 @@
1313

1414
namespace Liip\Acme\Tests\App\Entity;
1515

16+
use Doctrine\ORM\Mapping as ORM;
1617
use Symfony\Component\Security\Core\User\UserInterface;
1718

19+
#[
20+
ORM\Entity,
21+
ORM\Table(name: 'liip_user'),
22+
]
1823
class User implements UserInterface
1924
{
25+
#[ORM\Id]
26+
#[ORM\Column(type: 'integer')]
2027
private ?int $id = null;
28+
29+
#[ORM\Column(type: 'string', length: 255)]
2130
private string $name;
31+
32+
#[ORM\Column(type: 'string', length: 255)]
2233
private string $email;
34+
35+
#[ORM\Column(type: 'string', length: 255)]
2336
private string $salt;
2437

2538
public function __construct()

tests/App/Resources/config/doctrine/User.orm.yml

Lines changed: 0 additions & 19 deletions
This file was deleted.

tests/App/config.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,8 @@ doctrine:
3636
connection: default
3737
mappings:
3838
LiipFunctionalTestBundle:
39-
type: "yml"
40-
dir: "%kernel.project_dir%/Resources/config/doctrine"
39+
type: "attribute"
40+
dir: "%kernel.project_dir%/Entity"
4141
prefix: 'Liip\Acme\Tests\App\Entity'
4242
is_bundle: false
4343

tests/Traits/LiipAcmeFixturesTrait.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,9 +54,11 @@ private function resetSchema(): void
5454
$commandTester = new CommandTester($command);
5555
$return = $commandTester->execute([
5656
'--force' => true,
57+
'--complete' => true,
5758
]);
5859

5960
$this->assertSame(0, $return, $commandTester->getDisplay());
61+
$this->assertStringNotContainsString('No Metadata Classes to process', $commandTester->getDisplay());
6062

6163
$manager = $this->getContainer()->get('doctrine')->getManager();
6264

0 commit comments

Comments
 (0)