Skip to content

Commit

Permalink
Improve naming of compiler pass classes
Browse files Browse the repository at this point in the history
  • Loading branch information
benr77 committed May 24, 2024
1 parent ea37043 commit ebd8e9b
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
/**
* Automatically registers the custom Doctrine types provided by the Carbon library.
*/
final class RegisterCarbonTypesCompilerPass implements CompilerPassInterface
final class CarbonTypesCompilerPass implements CompilerPassInterface
{
private const TYPE_DEFINITION_PARAMETER = 'doctrine.dbal.connection_factory.types';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
*
* This saves having to specify them all individually in the Doctrine configuration which is tedious.
*/
final class RegisterDoctrineTypesCompilerPass implements CompilerPassInterface
final class CustomTypesCompilerPass implements CompilerPassInterface
{
private const TYPE_DEFINITION_PARAMETER = 'doctrine.dbal.connection_factory.types';

Expand Down
8 changes: 4 additions & 4 deletions src/HeadsnetDoctrineToolsBundle.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

namespace Headsnet\DoctrineToolsBundle;

use Headsnet\DoctrineToolsBundle\CarbonTypes\RegisterCarbonTypesCompilerPass;
use Headsnet\DoctrineToolsBundle\CustomTypes\RegisterDoctrineTypesCompilerPass;
use Headsnet\DoctrineToolsBundle\CarbonTypes\CarbonTypesCompilerPass;
use Headsnet\DoctrineToolsBundle\CustomTypes\CustomTypesCompilerPass;
use Symfony\Component\Config\Definition\Configurator\DefinitionConfigurator;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
Expand Down Expand Up @@ -54,11 +54,11 @@ public function build(ContainerBuilder $container): void
parent::build($container);

$container->addCompilerPass(
new RegisterDoctrineTypesCompilerPass()
new CustomTypesCompilerPass()
);

$container->addCompilerPass(
new RegisterCarbonTypesCompilerPass()
new CarbonTypesCompilerPass()
);
}
}
10 changes: 5 additions & 5 deletions tests/CarbonTypes/RegisterCarbonTypesCompilerPassTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@

use Carbon\Doctrine\DateTimeImmutableType;
use Carbon\Doctrine\DateTimeType;
use Headsnet\DoctrineToolsBundle\CarbonTypes\RegisterCarbonTypesCompilerPass;
use Headsnet\DoctrineToolsBundle\CarbonTypes\CarbonTypesCompilerPass;
use PHPUnit\Framework\Attributes\CoversClass;
use PHPUnit\Framework\Attributes\Test;
use PHPUnit\Framework\TestCase;
use Symfony\Component\DependencyInjection\ContainerBuilder;

#[CoversClass(RegisterCarbonTypesCompilerPass::class)]
#[CoversClass(CarbonTypesCompilerPass::class)]
class RegisterCarbonTypesCompilerPassTest extends TestCase
{
#[Test]
Expand All @@ -21,7 +21,7 @@ public function carbon_types_are_registered(): void
$container->setParameter('doctrine.dbal.connection_factory.types', []);
$container->setParameter('headsnet_doctrine_tools.carbon_types.enabled', true);
$container->setParameter('headsnet_doctrine_tools.carbon_types.replace', true);
$sut = new RegisterCarbonTypesCompilerPass();
$sut = new CarbonTypesCompilerPass();

$sut->process($container);

Expand All @@ -44,7 +44,7 @@ public function carbon_types_are_registered_separately(): void
$container->setParameter('doctrine.dbal.connection_factory.types', []);
$container->setParameter('headsnet_doctrine_tools.carbon_types.enabled', true);
$container->setParameter('headsnet_doctrine_tools.carbon_types.replace', false);
$sut = new RegisterCarbonTypesCompilerPass();
$sut = new CarbonTypesCompilerPass();

$sut->process($container);

Expand All @@ -66,7 +66,7 @@ public function if_disabled_then_register_nothing(): void
$container = new ContainerBuilder();
$container->setParameter('doctrine.dbal.connection_factory.types', []);
$container->setParameter('headsnet_doctrine_tools.carbon_types.enabled', false);
$sut = new RegisterCarbonTypesCompilerPass();
$sut = new CarbonTypesCompilerPass();

$sut->process($container);

Expand Down
8 changes: 4 additions & 4 deletions tests/CustomTypes/RegisterDoctrineTypesCompilerPassTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,15 @@
namespace Headsnet\DoctrineToolsBundle\Tests\CustomTypes;

use Headsnet\DoctrineToolsBundle\CustomTypes\CustomTypeNamer;
use Headsnet\DoctrineToolsBundle\CustomTypes\RegisterDoctrineTypesCompilerPass;
use Headsnet\DoctrineToolsBundle\CustomTypes\CustomTypesCompilerPass;
use Headsnet\DoctrineToolsBundle\Tests\CustomTypes\Fixtures\DummyCustomType;
use Headsnet\DoctrineToolsBundle\Tests\CustomTypes\Fixtures\DummyCustomTypeWithName;
use PHPUnit\Framework\Attributes\CoversClass;
use PHPUnit\Framework\Attributes\Test;
use PHPUnit\Framework\TestCase;
use Symfony\Component\DependencyInjection\ContainerBuilder;

#[CoversClass(RegisterDoctrineTypesCompilerPass::class)]
#[CoversClass(CustomTypesCompilerPass::class)]
#[CoversClass(CustomTypeNamer::class)]
class RegisterDoctrineTypesCompilerPassTest extends TestCase
{
Expand All @@ -24,7 +24,7 @@ public function can_find_and_register_types(): void
$container->setParameter('headsnet_doctrine_tools.custom_types.scan_dirs', [
__DIR__ . '/Fixtures',
]);
$sut = new RegisterDoctrineTypesCompilerPass();
$sut = new CustomTypesCompilerPass();

$sut->process($container);

Expand Down Expand Up @@ -52,7 +52,7 @@ public function ignores_types_that_are_manually_registered(): void
$container->setParameter('headsnet_doctrine_tools.custom_types.scan_dirs', [
__DIR__ . '/Fixtures',
]);
$sut = new RegisterDoctrineTypesCompilerPass();
$sut = new CustomTypesCompilerPass();

$sut->process($container);

Expand Down
8 changes: 4 additions & 4 deletions tests/HeadsnetDoctrineToolsBundleTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@

namespace Headsnet\DoctrineToolsBundle\Tests;

use Headsnet\DoctrineToolsBundle\CarbonTypes\RegisterCarbonTypesCompilerPass;
use Headsnet\DoctrineToolsBundle\CustomTypes\RegisterDoctrineTypesCompilerPass;
use Headsnet\DoctrineToolsBundle\CarbonTypes\CarbonTypesCompilerPass;
use Headsnet\DoctrineToolsBundle\CustomTypes\CustomTypesCompilerPass;
use Headsnet\DoctrineToolsBundle\HeadsnetDoctrineToolsBundle;
use Nyholm\BundleTest\TestKernel;
use PHPUnit\Framework\Attributes\CoversClass;
Expand All @@ -13,8 +13,8 @@
use Symfony\Component\HttpKernel\KernelInterface;

#[CoversClass(HeadsnetDoctrineToolsBundle::class)]
#[CoversClass(RegisterCarbonTypesCompilerPass::class)]
#[CoversClass(RegisterDoctrineTypesCompilerPass::class)]
#[CoversClass(CarbonTypesCompilerPass::class)]
#[CoversClass(CustomTypesCompilerPass::class)]
class HeadsnetDoctrineToolsBundleTest extends KernelTestCase
{
protected static function getKernelClass(): string
Expand Down

0 comments on commit ebd8e9b

Please sign in to comment.