From 6cb12b66c3537c861a3998d4c8459b46062dc3de Mon Sep 17 00:00:00 2001 From: Christian Gripp Date: Thu, 28 Mar 2019 23:06:10 +0100 Subject: [PATCH] Prepare major release (#686) --- docs/reference/flash_messages.rst | 2 +- src/CoreBundle/Date/MomentFormatConverter.php | 36 ------ .../Compiler/AdapterCompilerPass.php | 45 ------- .../Compiler/StatusRendererCompilerPass.php | 4 +- .../SonataCoreExtension.php | 21 +--- src/CoreBundle/Model/Adapter/AdapterChain.php | 36 ------ .../Model/Adapter/AdapterInterface.php | 36 ------ .../Model/Adapter/DoctrineORMAdapter.php | 38 ------ .../Model/PageableManagerInterface.php | 33 ----- src/CoreBundle/Resources/config/commands.xml | 8 -- src/CoreBundle/Resources/config/date.xml | 2 +- src/CoreBundle/Resources/config/flash.xml | 12 +- .../Resources/config/form_types.xml | 50 ++++---- .../Resources/config/model_adapter.xml | 16 --- src/CoreBundle/Resources/config/twig.xml | 13 +- src/CoreBundle/Resources/config/validator.xml | 4 +- src/CoreBundle/SonataCoreBundle.php | 2 - .../Test/EntityManagerMockFactory.php | 36 ------ .../BooleanTypeToBooleanTransformer.php | 2 - src/Form/Date/MomentFormatConverter.php | 2 - src/Form/Test/AbstractWidgetTestCase.php | 2 - .../Constraints/InlineConstraint.php | 4 +- src/Form/Validator/ErrorElement.php | 2 - src/Form/Validator/InlineValidator.php | 2 - src/Twig/Extension/TemplateExtension.php | 2 +- .../Date/MomentFormatConverterTest.php | 90 -------------- .../Compiler/AdapterCompilerPassTest.php | 68 ---------- .../StatusRendererCompilerPassTest.php | 6 +- .../SonataCoreExtensionTest.php | 19 +-- .../CoreBundle/Fixtures/Bundle/Entity/Foo.php | 46 ------- .../Bundle/Validator/FooValidatorService.php | 36 ------ .../Form/Type/FormChoiceWidgetTest.php | 117 ------------------ .../Model/Adapter/AdapterChainTest.php | 66 ---------- .../Model/Adapter/DoctrineORMAdapterTest.php | 116 ----------------- .../Constraints/InlineConstraintTest.php | 2 +- .../Serializer/BaseSerializerHandlerTest.php | 2 +- .../Bundle/Serializer/FooSerializer.php | 2 +- .../Twig/Extension/TemplateExtensionTest.php | 3 +- tests/Twig/Node/TemplateBoxNodeTest.php | 2 +- 39 files changed, 60 insertions(+), 925 deletions(-) delete mode 100644 src/CoreBundle/Date/MomentFormatConverter.php delete mode 100644 src/CoreBundle/DependencyInjection/Compiler/AdapterCompilerPass.php delete mode 100644 src/CoreBundle/Model/Adapter/AdapterChain.php delete mode 100644 src/CoreBundle/Model/Adapter/AdapterInterface.php delete mode 100644 src/CoreBundle/Model/Adapter/DoctrineORMAdapter.php delete mode 100644 src/CoreBundle/Model/PageableManagerInterface.php delete mode 100644 src/CoreBundle/Resources/config/commands.xml delete mode 100644 src/CoreBundle/Resources/config/model_adapter.xml delete mode 100644 src/CoreBundle/Test/EntityManagerMockFactory.php delete mode 100644 tests/CoreBundle/Date/MomentFormatConverterTest.php delete mode 100644 tests/CoreBundle/DependencyInjection/Compiler/AdapterCompilerPassTest.php delete mode 100644 tests/CoreBundle/Fixtures/Bundle/Entity/Foo.php delete mode 100644 tests/CoreBundle/Fixtures/Bundle/Validator/FooValidatorService.php delete mode 100644 tests/CoreBundle/Form/Type/FormChoiceWidgetTest.php delete mode 100644 tests/CoreBundle/Model/Adapter/AdapterChainTest.php delete mode 100644 tests/CoreBundle/Model/Adapter/DoctrineORMAdapterTest.php diff --git a/docs/reference/flash_messages.rst b/docs/reference/flash_messages.rst index 20157329..e0e6b34b 100644 --- a/docs/reference/flash_messages.rst +++ b/docs/reference/flash_messages.rst @@ -66,7 +66,7 @@ Usage To use this feature in your PHP classes/controllers:: - $flashManager = $this->get('sonata.core.flashmessage.manager'); + $flashManager = $this->get('sonata.twig.flashmessage.manager'); $messages = $flashManager->get('success'); diff --git a/src/CoreBundle/Date/MomentFormatConverter.php b/src/CoreBundle/Date/MomentFormatConverter.php deleted file mode 100644 index 60b7a972..00000000 --- a/src/CoreBundle/Date/MomentFormatConverter.php +++ /dev/null @@ -1,36 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Sonata\CoreBundle\Date; - -if (!class_exists(\Sonata\Form\Date\MomentFormatConverter::class, false)) { - @trigger_error( - 'The '.__NAMESPACE__.'\MomentFormatConverter class is deprecated since version 3.13.0 and will be removed in 4.0.' - .' Use Sonata\Form\Date\MomentFormatConverter instead.', - E_USER_DEPRECATED - ); -} - -class_alias( - \Sonata\Form\Date\MomentFormatConverter::class, - __NAMESPACE__.'\MomentFormatConverter' -); - -if (false) { - /** - * @deprecated Since version 3.13.0, to be removed in 4.0. - */ - class MomentFormatConverter extends \Sonata\Form\Date\MomentFormatConverter - { - } -} diff --git a/src/CoreBundle/DependencyInjection/Compiler/AdapterCompilerPass.php b/src/CoreBundle/DependencyInjection/Compiler/AdapterCompilerPass.php deleted file mode 100644 index 17040e59..00000000 --- a/src/CoreBundle/DependencyInjection/Compiler/AdapterCompilerPass.php +++ /dev/null @@ -1,45 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Sonata\CoreBundle\DependencyInjection\Compiler; - -use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface; -use Symfony\Component\DependencyInjection\ContainerBuilder; -use Symfony\Component\DependencyInjection\Reference; - -/** - * @author Thomas Rabaix - */ -final class AdapterCompilerPass implements CompilerPassInterface -{ - public function process(ContainerBuilder $container): void - { - if (!$container->has('sonata.core.model.adapter.chain')) { - return; - } - - $definition = $container->findDefinition('sonata.core.model.adapter.chain'); - - if ($container->has('doctrine')) { - $definition->addMethodCall('addAdapter', [new Reference('sonata.core.model.adapter.doctrine_orm')]); - } else { - $container->removeDefinition('sonata.core.model.adapter.doctrine_orm'); - } - - if ($container->has('doctrine_phpcr')) { - $definition->addMethodCall('addAdapter', [new Reference('sonata.core.model.adapter.doctrine_phpcr')]); - } else { - $container->removeDefinition('sonata.core.model.adapter.doctrine_phpcr'); - } - } -} diff --git a/src/CoreBundle/DependencyInjection/Compiler/StatusRendererCompilerPass.php b/src/CoreBundle/DependencyInjection/Compiler/StatusRendererCompilerPass.php index 66939d8a..eb004218 100644 --- a/src/CoreBundle/DependencyInjection/Compiler/StatusRendererCompilerPass.php +++ b/src/CoreBundle/DependencyInjection/Compiler/StatusRendererCompilerPass.php @@ -24,11 +24,11 @@ final class StatusRendererCompilerPass implements CompilerPassInterface { public function process(ContainerBuilder $container): void { - if (!$container->hasDefinition('sonata.core.twig.status_extension')) { + if (!$container->hasDefinition('sonata.twig.status_extension')) { return; } - $definition = $container->getDefinition('sonata.core.twig.status_extension'); + $definition = $container->getDefinition('sonata.twig.status_extension'); foreach ($container->findTaggedServiceIds('sonata.status.renderer') as $id => $attributes) { $definition->addMethodCall('addStatusService', [new Reference($id)]); diff --git a/src/CoreBundle/DependencyInjection/SonataCoreExtension.php b/src/CoreBundle/DependencyInjection/SonataCoreExtension.php index 04167582..6d2f10ff 100644 --- a/src/CoreBundle/DependencyInjection/SonataCoreExtension.php +++ b/src/CoreBundle/DependencyInjection/SonataCoreExtension.php @@ -14,7 +14,6 @@ namespace Sonata\CoreBundle\DependencyInjection; use JMS\Serializer\Handler\SubscribingHandlerInterface; -use Sonata\Doctrine\Bridge\Symfony\Bundle\SonataDoctrineBundle; use Sonata\Serializer\BaseSerializerHandler; use Symfony\Component\Config\Definition\Processor; use Symfony\Component\Config\FileLocator; @@ -49,31 +48,15 @@ public function load(array $configs, ContainerBuilder $container): void $config = $processor->processConfiguration($configuration, $configs); $bundles = $container->getParameter('kernel.bundles'); - $bundles = $container->getParameter('kernel.bundles'); - - if (!isset($bundles['SonataDoctrineBundle'])) { - // NEXT_MAJOR remove the alias, throw an exception - @trigger_error(sprintf( - 'Not registering bundle "%s" is deprecated since 3.12.0, registering it will be mandatory in 4.0', - SonataDoctrineBundle::class - ), E_USER_DEPRECATED); - $container->setAlias( - 'sonata.doctrine.model.adapter.chain', - 'sonata.core.model.adapter.chain' - ); - } - $loader = new XmlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config')); $loader->load('date.xml'); $loader->load('flash.xml'); $loader->load('form_types.xml'); $loader->load('validator.xml'); $loader->load('twig.xml'); - $loader->load('model_adapter.xml'); - $loader->load('commands.xml'); $this->registerFlashTypes($container, $config); - $container->setParameter('sonata.core.form_type', $config['form_type']); + $container->setParameter('sonata.form.form_type', $config['form_type']); if (isset($bundles['JMSSerializerBundle'])) { $this->configureSerializerFormats($config); @@ -110,7 +93,7 @@ public function registerFlashTypes(ContainerBuilder $container, array $config): $cssClasses[$typeKey] = \array_key_exists('css_class', $typeConfig) ? $typeConfig['css_class'] : $typeKey; } - $identifier = 'sonata.core.flashmessage.manager'; + $identifier = 'sonata.twig.flashmessage.manager'; $definition = $container->getDefinition($identifier); $definition->replaceArgument(2, $types); diff --git a/src/CoreBundle/Model/Adapter/AdapterChain.php b/src/CoreBundle/Model/Adapter/AdapterChain.php deleted file mode 100644 index 66b45af7..00000000 --- a/src/CoreBundle/Model/Adapter/AdapterChain.php +++ /dev/null @@ -1,36 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Sonata\CoreBundle\Model\Adapter; - -if (!class_exists(\Sonata\Doctrine\Adapter\AdapterChain::class, false)) { - @trigger_error( - 'The '.__NAMESPACE__.'\AdapterChain class is deprecated since version 3.12.0 and will be removed in 4.0.' - .' Use Sonata\Doctrine\Adapter\AdapterChain instead.', - E_USER_DEPRECATED - ); -} - -class_alias( - \Sonata\Doctrine\Adapter\AdapterChain::class, - __NAMESPACE__.'\AdapterChain' -); - -if (false) { - /** - * @deprecated since 3.12.0, to be removed in 4.0. - */ - class AdapterChain extends \Sonata\Doctrine\Adapter\AdapterChain implements AdapterInterface - { - } -} diff --git a/src/CoreBundle/Model/Adapter/AdapterInterface.php b/src/CoreBundle/Model/Adapter/AdapterInterface.php deleted file mode 100644 index 95ffba0c..00000000 --- a/src/CoreBundle/Model/Adapter/AdapterInterface.php +++ /dev/null @@ -1,36 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Sonata\CoreBundle\Model\Adapter; - -if (!interface_exists(\Sonata\Doctrine\Adapter\AdapterInterface::class, false)) { - @trigger_error( - 'The '.__NAMESPACE__.'\AdapterInterface class is deprecated since version 3.12.0 and will be removed in 4.0.' - .' Use Sonata\Doctrine\Adapter\AdapterInterface instead.', - E_USER_DEPRECATED - ); -} - -class_alias( - \Sonata\Doctrine\Adapter\AdapterInterface::class, - __NAMESPACE__.'\AdapterInterface' -); - -if (false) { - /** - * @deprecated since 3.12.0, to be removed in 4.0. - */ - interface AdapterInterface extends \Sonata\Doctrine\Adapter\AdapterInterface - { - } -} diff --git a/src/CoreBundle/Model/Adapter/DoctrineORMAdapter.php b/src/CoreBundle/Model/Adapter/DoctrineORMAdapter.php deleted file mode 100644 index da55909c..00000000 --- a/src/CoreBundle/Model/Adapter/DoctrineORMAdapter.php +++ /dev/null @@ -1,38 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Sonata\CoreBundle\Model\Adapter; - -if (!class_exists(\Sonata\Doctrine\Adapter\ORM\DoctrineORMAdapter::class, false)) { - @trigger_error( - 'The '.__NAMESPACE__.'\DoctrineORMAdapter class is deprecated since version 3.12.0 and will be removed in 4.0.' - .' Use Sonata\Doctrine\Adapter\ORM\DoctrineORMAdapter instead.', - E_USER_DEPRECATED - ); -} - -class_alias( - \Sonata\Doctrine\Adapter\ORM\DoctrineORMAdapter::class, - __NAMESPACE__.'\DoctrineORMAdapter' -); - -if (false) { - /** - * This is a port of the DoctrineORMAdminBundle / ModelManager class. - * - * @deprecated since 3.12.0, to be removed in 4.0. - */ - class DoctrineORMAdapter extends \Sonata\Doctrine\Adapter\ORM\DoctrineORMAdapter implements AdapterInterface - { - } -} diff --git a/src/CoreBundle/Model/PageableManagerInterface.php b/src/CoreBundle/Model/PageableManagerInterface.php deleted file mode 100644 index 98155bf4..00000000 --- a/src/CoreBundle/Model/PageableManagerInterface.php +++ /dev/null @@ -1,33 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Sonata\CoreBundle\Model; - -if (!interface_exists(\Sonata\Doctrine\Model\PageableManagerInterface::class, false)) { - @trigger_error( - 'The '.__NAMESPACE__.'\PageableManagerInterface class is deprecated since version 3.12.0 and will be removed in 4.0.' - .' Use Sonata\DatagridBundle\Pager\PageableInterface instead.', - E_USER_DEPRECATED - ); -} - -class_alias( - \Sonata\Doctrine\Model\PageableManagerInterface::class, - __NAMESPACE__.'\PageableManagerInterface' -); - -if (false) { - interface PageableManagerInterface extends \Sonata\Doctrine\Model\PageableManagerInterface - { - } -} diff --git a/src/CoreBundle/Resources/config/commands.xml b/src/CoreBundle/Resources/config/commands.xml deleted file mode 100644 index f2e2f897..00000000 --- a/src/CoreBundle/Resources/config/commands.xml +++ /dev/null @@ -1,8 +0,0 @@ - - - - - - - - diff --git a/src/CoreBundle/Resources/config/date.xml b/src/CoreBundle/Resources/config/date.xml index bae41497..c76ae35a 100644 --- a/src/CoreBundle/Resources/config/date.xml +++ b/src/CoreBundle/Resources/config/date.xml @@ -1,6 +1,6 @@ - + diff --git a/src/CoreBundle/Resources/config/flash.xml b/src/CoreBundle/Resources/config/flash.xml index 5470c607..a19ca686 100644 --- a/src/CoreBundle/Resources/config/flash.xml +++ b/src/CoreBundle/Resources/config/flash.xml @@ -1,22 +1,22 @@ - Sonata\Twig\FlashMessage\FlashManager - Sonata\Twig\Extension\FlashMessageExtension + Sonata\Twig\FlashMessage\FlashManager + Sonata\Twig\Extension\FlashMessageExtension - + - + - + - + diff --git a/src/CoreBundle/Resources/config/form_types.xml b/src/CoreBundle/Resources/config/form_types.xml index c00bbcb3..425a7449 100644 --- a/src/CoreBundle/Resources/config/form_types.xml +++ b/src/CoreBundle/Resources/config/form_types.xml @@ -1,84 +1,84 @@ - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + diff --git a/src/CoreBundle/Resources/config/model_adapter.xml b/src/CoreBundle/Resources/config/model_adapter.xml deleted file mode 100644 index 94c7a826..00000000 --- a/src/CoreBundle/Resources/config/model_adapter.xml +++ /dev/null @@ -1,16 +0,0 @@ - - - - - - The "%service_id%" service is deprecated in favor of service "sonata.doctrine.adapter.doctrine_orm" since 3.12.0 and will be removed in 4.0. - - - - The "%service_id%" service is deprecated in favor of service "sonata.doctrine.adapter.doctrine_phpcr" since 3.12.0 and will be removed in 4.0. - - - The "%service_id%" service is deprecated in favor of service "sonata.doctrine.model.adapter.chain" since 3.12.0 and will be removed in 4.0. - - - diff --git a/src/CoreBundle/Resources/config/twig.xml b/src/CoreBundle/Resources/config/twig.xml index 62607b3d..0182e068 100644 --- a/src/CoreBundle/Resources/config/twig.xml +++ b/src/CoreBundle/Resources/config/twig.xml @@ -1,23 +1,22 @@ - + - %sonata.core.form_type% + %sonata.form.form_type% - + - + - + - + %kernel.debug% - diff --git a/src/CoreBundle/Resources/config/validator.xml b/src/CoreBundle/Resources/config/validator.xml index 3000ddc8..2cee884e 100644 --- a/src/CoreBundle/Resources/config/validator.xml +++ b/src/CoreBundle/Resources/config/validator.xml @@ -1,10 +1,10 @@ - + - + diff --git a/src/CoreBundle/SonataCoreBundle.php b/src/CoreBundle/SonataCoreBundle.php index a135b20c..5b8ea177 100644 --- a/src/CoreBundle/SonataCoreBundle.php +++ b/src/CoreBundle/SonataCoreBundle.php @@ -13,7 +13,6 @@ namespace Sonata\CoreBundle; -use Sonata\CoreBundle\DependencyInjection\Compiler\AdapterCompilerPass; use Sonata\CoreBundle\DependencyInjection\Compiler\StatusRendererCompilerPass; use Symfony\Component\DependencyInjection\ContainerBuilder; use Symfony\Component\HttpKernel\Bundle\Bundle; @@ -22,7 +21,6 @@ final class SonataCoreBundle extends Bundle { public function build(ContainerBuilder $container): void { - $container->addCompilerPass(new AdapterCompilerPass()); $container->addCompilerPass(new StatusRendererCompilerPass()); } } diff --git a/src/CoreBundle/Test/EntityManagerMockFactory.php b/src/CoreBundle/Test/EntityManagerMockFactory.php deleted file mode 100644 index e765cbb3..00000000 --- a/src/CoreBundle/Test/EntityManagerMockFactory.php +++ /dev/null @@ -1,36 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Sonata\CoreBundle\Test; - -if (!class_exists(\Sonata\Doctrine\Test\EntityManagerMockFactory::class, false)) { - @trigger_error( - 'The '.__NAMESPACE__.'\EntityManagerMockFactory class is deprecated since version 3.13.0 and will be removed in 4.0.' - .' Use Sonata\Doctrine\Test\EntityManagerMockFactory instead.', - E_USER_DEPRECATED - ); -} - -class_alias( - \Sonata\Doctrine\Test\EntityManagerMockFactory::class, - __NAMESPACE__.'\EntityManagerMockFactory' -); - -if (false) { - /** - * @deprecated since 3.13.0, to be removed in 4.0. - */ - class EntityManagerMockFactory extends \Sonata\Doctrine\Test\EntityManagerMockFactory - { - } -} diff --git a/src/Form/DataTransformer/BooleanTypeToBooleanTransformer.php b/src/Form/DataTransformer/BooleanTypeToBooleanTransformer.php index 203f8793..4e60c580 100644 --- a/src/Form/DataTransformer/BooleanTypeToBooleanTransformer.php +++ b/src/Form/DataTransformer/BooleanTypeToBooleanTransformer.php @@ -40,5 +40,3 @@ public function reverseTransform($value): ?bool return null; } } - -class_exists(\Sonata\CoreBundle\Form\DataTransformer\BooleanTypeToBooleanTransformer::class); diff --git a/src/Form/Date/MomentFormatConverter.php b/src/Form/Date/MomentFormatConverter.php index db4c74ad..e91c02a1 100644 --- a/src/Form/Date/MomentFormatConverter.php +++ b/src/Form/Date/MomentFormatConverter.php @@ -105,5 +105,3 @@ public function convert(string $format): string return $output; } } - -class_exists(\Sonata\CoreBundle\Date\MomentFormatConverter::class); diff --git a/src/Form/Test/AbstractWidgetTestCase.php b/src/Form/Test/AbstractWidgetTestCase.php index 4ed725bb..0700866b 100644 --- a/src/Form/Test/AbstractWidgetTestCase.php +++ b/src/Form/Test/AbstractWidgetTestCase.php @@ -141,5 +141,3 @@ final protected function cleanHtmlAttributeWhitespace(string $html): string }, $html); } } - -class_exists(\Sonata\CoreBundle\Test\AbstractWidgetTestCase::class); diff --git a/src/Form/Validator/Constraints/InlineConstraint.php b/src/Form/Validator/Constraints/InlineConstraint.php index 77eb0e63..8e8c6ab4 100755 --- a/src/Form/Validator/Constraints/InlineConstraint.php +++ b/src/Form/Validator/Constraints/InlineConstraint.php @@ -75,7 +75,7 @@ public function __wakeup(): void public function validatedBy(): string { - return 'sonata.core.validator.inline'; + return 'sonata.form.validator.inline'; } public function isClosure(): bool @@ -128,5 +128,3 @@ public function getSerializingWarning() return $this->serializingWarning; } } - -class_exists(\Sonata\CoreBundle\Validator\Constraints\InlineConstraint::class); diff --git a/src/Form/Validator/ErrorElement.php b/src/Form/Validator/ErrorElement.php index f7096036..f5e64dda 100755 --- a/src/Form/Validator/ErrorElement.php +++ b/src/Form/Validator/ErrorElement.php @@ -218,5 +218,3 @@ private function getCurrentPropertyPath(): ?PropertyPath return $this->propertyPaths[$this->current]; } } - -class_exists(\Sonata\CoreBundle\Validator\ErrorElement::class); diff --git a/src/Form/Validator/InlineValidator.php b/src/Form/Validator/InlineValidator.php index 357c5dfb..d04ad89b 100755 --- a/src/Form/Validator/InlineValidator.php +++ b/src/Form/Validator/InlineValidator.php @@ -68,5 +68,3 @@ protected function getErrorElement($value): ErrorElement ); } } - -class_exists(\Sonata\CoreBundle\Validator\InlineValidator::class); diff --git a/src/Twig/Extension/TemplateExtension.php b/src/Twig/Extension/TemplateExtension.php index 81a5faa7..fd052d36 100644 --- a/src/Twig/Extension/TemplateExtension.php +++ b/src/Twig/Extension/TemplateExtension.php @@ -13,7 +13,7 @@ namespace Sonata\Twig\Extension; -use Sonata\CoreBundle\Model\Adapter\AdapterInterface; +use Sonata\Doctrine\Adapter\AdapterInterface; use Sonata\Twig\TokenParser\TemplateBoxTokenParser; use Twig\Extension\AbstractExtension; use Twig\TwigFilter; diff --git a/tests/CoreBundle/Date/MomentFormatConverterTest.php b/tests/CoreBundle/Date/MomentFormatConverterTest.php deleted file mode 100644 index 7a17b203..00000000 --- a/tests/CoreBundle/Date/MomentFormatConverterTest.php +++ /dev/null @@ -1,90 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Sonata\CoreBundle\Tests\Date; - -use PHPUnit\Framework\TestCase; -use Sonata\CoreBundle\Date\MomentFormatConverter; - -/** - * @author Hugo Briand - * - * @group legacy - */ -class MomentFormatConverterTest extends TestCase -{ - public function testPhpToMoment(): void - { - $mfc = new MomentFormatConverter(); - - $phpFormat = "yyyy-MM-dd'T'HH:mm:ssZZZZZ"; - $this->assertSame('YYYY-MM-DDTHH:mm:ssZ', $mfc->convert($phpFormat)); - - $phpFormat = 'yyyy-MM-dd HH:mm:ss'; - $this->assertSame('YYYY-MM-DD HH:mm:ss', $mfc->convert($phpFormat)); - - $phpFormat = 'yyyy-MM-dd HH:mm'; - $this->assertSame('YYYY-MM-DD HH:mm', $mfc->convert($phpFormat)); - - $phpFormat = 'yyyy-MM-dd'; - $this->assertSame('YYYY-MM-DD', $mfc->convert($phpFormat)); - - $phpFormat = 'dd.MM.yyyy, HH:mm'; - $this->assertSame('DD.MM.YYYY, HH:mm', $mfc->convert($phpFormat)); - - $phpFormat = 'dd.MM.yyyy, HH:mm:ss'; - $this->assertSame('DD.MM.YYYY, HH:mm:ss', $mfc->convert($phpFormat)); - - $phpFormat = 'dd.MM.yyyy'; - $this->assertSame('DD.MM.YYYY', $mfc->convert($phpFormat)); - - $phpFormat = 'd.M.yyyy'; - $this->assertSame('D.M.YYYY', $mfc->convert($phpFormat)); - - $phpFormat = 'd.M.yyyy HH:mm'; - $this->assertSame('D.M.YYYY HH:mm', $mfc->convert($phpFormat)); - - $phpFormat = 'd.M.yyyy HH:mm:ss'; - $this->assertSame('D.M.YYYY HH:mm:ss', $mfc->convert($phpFormat)); - - $phpFormat = 'dd/MM/yyyy'; - $this->assertSame('DD/MM/YYYY', $mfc->convert($phpFormat)); - - $phpFormat = 'dd/MM/yyyy HH:mm'; - $this->assertSame('DD/MM/YYYY HH:mm', $mfc->convert($phpFormat)); - - $phpFormat = 'EE, dd/MM/yyyy HH:mm'; - $this->assertSame('ddd, DD/MM/YYYY HH:mm', $mfc->convert($phpFormat)); - - $phpFormat = 'EEEE d MMMM y HH:mm'; - $this->assertSame('dddd D MMMM YYYY HH:mm', $mfc->convert($phpFormat)); - - $phpFormat = 'dd-MM-yyyy'; - $this->assertSame('DD-MM-YYYY', $mfc->convert($phpFormat)); - - $phpFormat = 'dd-MM-yyyy HH:mm'; - $this->assertSame('DD-MM-YYYY HH:mm', $mfc->convert($phpFormat)); - - $phpFormat = 'dd-MM-yyyy HH:mm:ss'; - $this->assertSame('DD-MM-YYYY HH:mm:ss', $mfc->convert($phpFormat)); - - $phpFormat = 'dd.MM.y HH:mm:ss'; - $this->assertSame('DD.MM.YYYY HH:mm:ss', $mfc->convert($phpFormat)); - - $phpFormat = 'D MMM y'; - $this->assertSame('D MMM YYYY', $mfc->convert($phpFormat)); - - $phpFormat = "dd 'de' MMMM 'de' YYYY"; //Brazilian date format - $this->assertSame('DD [de] MMMM [de] YYYY', $mfc->convert($phpFormat)); - } -} diff --git a/tests/CoreBundle/DependencyInjection/Compiler/AdapterCompilerPassTest.php b/tests/CoreBundle/DependencyInjection/Compiler/AdapterCompilerPassTest.php deleted file mode 100644 index 07915ac4..00000000 --- a/tests/CoreBundle/DependencyInjection/Compiler/AdapterCompilerPassTest.php +++ /dev/null @@ -1,68 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Sonata\CoreBundle\Tests\DependencyInjection\Compiler; - -use Matthias\SymfonyDependencyInjectionTest\PhpUnit\AbstractCompilerPassTestCase; -use Sonata\CoreBundle\DependencyInjection\Compiler\AdapterCompilerPass; -use Symfony\Component\DependencyInjection\ContainerBuilder; -use Symfony\Component\DependencyInjection\Definition; -use Symfony\Component\DependencyInjection\Reference; - -/** - * @author Ahmet Akbana - */ -final class AdapterCompilerPassTest extends AbstractCompilerPassTestCase -{ - public function registerCompilerPass(ContainerBuilder $container): void - { - $container->addCompilerPass(new AdapterCompilerPass()); - } - - public function testDefinitionsAdded(): void - { - $coreModelAdapterChain = new Definition(); - $this->setDefinition('sonata.core.model.adapter.chain', $coreModelAdapterChain); - - $this->registerService('doctrine', 'foo'); - $this->registerService('doctrine_phpcr', 'foo'); - - $this->compile(); - - $this->assertContainerBuilderHasServiceDefinitionWithMethodCall( - 'sonata.core.model.adapter.chain', - 'addAdapter', - [new Reference('sonata.core.model.adapter.doctrine_orm')] - ); - - $this->assertContainerBuilderHasServiceDefinitionWithMethodCall( - 'sonata.core.model.adapter.chain', - 'addAdapter', - [new Reference('sonata.core.model.adapter.doctrine_phpcr')] - ); - } - - public function testDefinitionsRemoved(): void - { - $coreModelAdapterChain = new Definition(); - $this->setDefinition('sonata.core.model.adapter.chain', $coreModelAdapterChain); - - $this->registerService('sonata.core.model.adapter.doctrine_orm', 'foo'); - $this->registerService('sonata.core.model.adapter.doctrine_phpcr', 'foo'); - - $this->compile(); - - $this->assertContainerBuilderNotHasService('sonata.core.model.adapter.doctrine_orm'); - $this->assertContainerBuilderNotHasService('sonata.core.model.adapter.doctrine_phpcr'); - } -} diff --git a/tests/CoreBundle/DependencyInjection/Compiler/StatusRendererCompilerPassTest.php b/tests/CoreBundle/DependencyInjection/Compiler/StatusRendererCompilerPassTest.php index 8983b83c..8c617f49 100644 --- a/tests/CoreBundle/DependencyInjection/Compiler/StatusRendererCompilerPassTest.php +++ b/tests/CoreBundle/DependencyInjection/Compiler/StatusRendererCompilerPassTest.php @@ -36,13 +36,13 @@ public function testProcess(): void $this->setDefinition('sonata.status.renderer', $statusRenderer); $statusExtension = new Definition(); - $this->setDefinition('sonata.core.twig.status_extension', $statusExtension); - $this->setDefinition('sonata.core.twig.status_runtime', $statusExtension); + $this->setDefinition('sonata.twig.status_extension', $statusExtension); + $this->setDefinition('sonata.twig.status_runtime', $statusExtension); $this->compile(); $this->assertContainerBuilderHasServiceDefinitionWithMethodCall( - 'sonata.core.twig.status_runtime', + 'sonata.twig.status_runtime', 'addStatusService', [new Reference('sonata.status.renderer')] ); diff --git a/tests/CoreBundle/DependencyInjection/SonataCoreExtensionTest.php b/tests/CoreBundle/DependencyInjection/SonataCoreExtensionTest.php index 66212a70..4eaf12d6 100644 --- a/tests/CoreBundle/DependencyInjection/SonataCoreExtensionTest.php +++ b/tests/CoreBundle/DependencyInjection/SonataCoreExtensionTest.php @@ -35,12 +35,12 @@ public function testAfterLoadingTheWrappingParameterIsSet(): void 'form' => ['mapping' => ['enabled' => false]], ]); $this->assertContainerBuilderHasParameter( - 'sonata.core.form_type' + 'sonata.form.form_type' ); $this->assertSame( 'standard', $this->container->getParameter( - 'sonata.core.form_type' + 'sonata.form.form_type' ) ); } @@ -52,12 +52,12 @@ public function testHorizontalFormTypeMeansNoWrapping(): void 'form_type' => 'horizontal', ]); $this->assertContainerBuilderHasParameter( - 'sonata.core.form_type' + 'sonata.form.form_type' ); $this->assertSame( 'horizontal', $this->container->getParameter( - 'sonata.core.form_type' + 'sonata.form.form_type' ) ); } @@ -86,17 +86,6 @@ public function testPrepend(): void $extension->prepend($containerBuilder->reveal()); } - /** - * @group legacy - * @expectedDeprecation Not registering bundle "Sonata\Doctrine\Bridge\Symfony\Bundle\SonataDoctrineBundle" is deprecated since 3.12.0, registering it will be mandatory in 4.0 - */ - public function testItLoadsProperlyWithoutDoctrineBundle() - { - $this->container->setParameter('kernel.bundles', []); - $this->load(); - $this->assertContainerBuilderHasService('sonata.doctrine.model.adapter.chain'); - } - protected function getContainerExtensions() { return [ diff --git a/tests/CoreBundle/Fixtures/Bundle/Entity/Foo.php b/tests/CoreBundle/Fixtures/Bundle/Entity/Foo.php deleted file mode 100644 index af80f12b..00000000 --- a/tests/CoreBundle/Fixtures/Bundle/Entity/Foo.php +++ /dev/null @@ -1,46 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Sonata\CoreBundle\Tests\Fixtures\Bundle\Entity; - -class Foo -{ - private $bar; - - private $baz; - - public function __toString() - { - return (string) $this->bar; - } - - public function getBar() - { - return $this->bar; - } - - public function setBar($bar): void - { - $this->bar = $bar; - } - - public function getBaz() - { - return $this->baz; - } - - public function setBaz($baz): void - { - $this->baz = $baz; - } -} diff --git a/tests/CoreBundle/Fixtures/Bundle/Validator/FooValidatorService.php b/tests/CoreBundle/Fixtures/Bundle/Validator/FooValidatorService.php deleted file mode 100644 index 023a92d2..00000000 --- a/tests/CoreBundle/Fixtures/Bundle/Validator/FooValidatorService.php +++ /dev/null @@ -1,36 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Sonata\CoreBundle\Tests\Fixtures\Bundle\Validator; - -use Sonata\Form\Validator\ErrorElement; -use Symfony\Component\Validator\Exception\ValidatorException; - -/** - * Validator service to create exception for test. - * - * @author Ahmet Akbana - */ -final class FooValidatorService -{ - /** - * @param ErrorElement $errorElement - * @param string $value - * - * @throws ValidatorException - */ - public function fooValidatorMethod(ErrorElement $errorElement, $value): void - { - throw new ValidatorException($errorElement->getSubject().' is equal to '.$value); - } -} diff --git a/tests/CoreBundle/Form/Type/FormChoiceWidgetTest.php b/tests/CoreBundle/Form/Type/FormChoiceWidgetTest.php deleted file mode 100644 index 86ed2c7d..00000000 --- a/tests/CoreBundle/Form/Type/FormChoiceWidgetTest.php +++ /dev/null @@ -1,117 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Sonata\CoreBundle\Tests\Form\Type; - -use Sonata\Form\Test\AbstractWidgetTestCase; -use Symfony\Component\Form\Extension\Core\Type\ChoiceType; -use Symfony\Component\Form\FormTypeInterface; - -/** - * @author Christian Gripp - * - * @group legacy - */ -class FormChoiceWidgetTest extends AbstractWidgetTestCase -{ - public function testLabelRendering(): void - { - $choices = ['some', 'choices']; - if (!method_exists(FormTypeInterface::class, 'setDefaultOptions')) { - $choices = array_flip($choices); - } - - $choice = $this->factory->create( - $this->getChoiceClass(), - null, - $this->getDefaultOption() + [ - 'multiple' => true, - 'expanded' => true, - ] + compact('choices') - ); - - $html = $this->renderWidget($choice->createView()); - - $this->assertContains( - '
', - $this->cleanHtmlWhitespace($html) - ); - } - - public function testDefaultValueRendering(): void - { - $choice = $this->factory->create( - $this->getChoiceClass(), - null, - $this->getDefaultOption() - ); - - $html = $this->renderWidget($choice->createView()); - - $this->assertContains( - '', - $this->cleanHtmlWhitespace($html) - ); - } - - public function testRequiredIsDisabledForEmptyPlaceholder(): void - { - $choice = $this->factory->create( - $this->getChoiceClass(), - null, - $this->getRequiredOption() - ); - - $html = $this->renderWidget($choice->createView()); - - $this->assertNotContains( - 'required="required"', - $this->cleanHtmlWhitespace($html) - ); - } - - public function testRequiredIsEnabledIfPlaceholderIsSet(): void - { - $choice = $this->factory->create( - $this->getChoiceClass(), - null, - array_merge($this->getRequiredOption(), $this->getDefaultOption()) - ); - - $html = $this->renderWidget($choice->createView()); - - $this->assertContains( - 'required="required"', - $this->cleanHtmlWhitespace($html) - ); - } - - private function getRequiredOption() - { - return [ - 'required' => true, - ]; - } - - private function getChoiceClass() - { - return ChoiceType::class; - } - - private function getDefaultOption() - { - return [ - 'placeholder' => 'Choose an option', - ]; - } -} diff --git a/tests/CoreBundle/Model/Adapter/AdapterChainTest.php b/tests/CoreBundle/Model/Adapter/AdapterChainTest.php deleted file mode 100644 index 472a2fbb..00000000 --- a/tests/CoreBundle/Model/Adapter/AdapterChainTest.php +++ /dev/null @@ -1,66 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Sonata\CoreBundle\Tests\Model\Adapter; - -use PHPUnit\Framework\TestCase; -use Sonata\CoreBundle\Model\Adapter\AdapterChain; -use Sonata\CoreBundle\Model\Adapter\AdapterInterface; - -class AdapterChainTest extends TestCase -{ - /** - * @group legacy - */ - public function testEmptyAdapter(): void - { - $adapter = new AdapterChain(); - - $this->assertNull($adapter->getNormalizedIdentifier(new \stdClass())); - $this->assertNull($adapter->getUrlsafeIdentifier(new \stdClass())); - } - - /** - * @group legacy - */ - public function testUrlSafeIdentifier(): void - { - $adapter = new AdapterChain(); - - $adapter->addAdapter($fake1 = $this->createMock(AdapterInterface::class)); - $fake1->expects($this->once())->method('getUrlsafeIdentifier')->will($this->returnValue(null)); - - $adapter->addAdapter($fake2 = $this->createMock(AdapterInterface::class)); - - $fake2->expects($this->once())->method('getUrlsafeIdentifier')->will($this->returnValue('voila')); - - $this->assertSame('voila', $adapter->getUrlsafeIdentifier(new \stdClass())); - } - - /** - * @group legacy - */ - public function testNormalizedIdentifier(): void - { - $adapter = new AdapterChain(); - - $adapter->addAdapter($fake1 = $this->createMock(AdapterInterface::class)); - $fake1->expects($this->once())->method('getNormalizedIdentifier')->will($this->returnValue(null)); - - $adapter->addAdapter($fake2 = $this->createMock(AdapterInterface::class)); - - $fake2->expects($this->once())->method('getNormalizedIdentifier')->will($this->returnValue('voila')); - - $this->assertSame('voila', $adapter->getNormalizedIdentifier(new \stdClass())); - } -} diff --git a/tests/CoreBundle/Model/Adapter/DoctrineORMAdapterTest.php b/tests/CoreBundle/Model/Adapter/DoctrineORMAdapterTest.php deleted file mode 100644 index d85ccd26..00000000 --- a/tests/CoreBundle/Model/Adapter/DoctrineORMAdapterTest.php +++ /dev/null @@ -1,116 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Sonata\CoreBundle\Tests\Model\Adapter; - -use Doctrine\Common\Persistence\ManagerRegistry; -use Doctrine\ORM\EntityManagerInterface; -use Doctrine\ORM\UnitOfWork; -use PHPUnit\Framework\TestCase; -use Sonata\CoreBundle\Model\Adapter\DoctrineORMAdapter; - -class DoctrineORMAdapterTest extends TestCase -{ - public function setUp(): void - { - if (!class_exists(UnitOfWork::class)) { - $this->markTestSkipped('Doctrine ORM not installed'); - } - } - - /** - * @group legacy - */ - public function testNormalizedIdentifierWithScalar(): void - { - $this->expectException(\RuntimeException::class); - - $registry = $this->createMock(ManagerRegistry::class); - $adapter = new DoctrineORMAdapter($registry); - - $adapter->getNormalizedIdentifier(1); - } - - /** - * @group legacy - */ - public function testNormalizedIdentifierWithNull(): void - { - $registry = $this->createMock(ManagerRegistry::class); - $adapter = new DoctrineORMAdapter($registry); - - $this->assertNull($adapter->getNormalizedIdentifier(null)); - } - - /** - * @group legacy - */ - public function testNormalizedIdentifierWithNoManager(): void - { - $registry = $this->createMock(ManagerRegistry::class); - $registry->expects($this->once())->method('getManagerForClass')->will($this->returnValue(null)); - - $adapter = new DoctrineORMAdapter($registry); - - $this->assertNull($adapter->getNormalizedIdentifier(new \stdClass())); - } - - /** - * @group legacy - */ - public function testNormalizedIdentifierWithNotManaged(): void - { - $unitOfWork = $this->createMock(UnitOfWork::class); - $unitOfWork->expects($this->once())->method('isInIdentityMap')->will($this->returnValue(false)); - - $manager = $this->createMock(EntityManagerInterface::class); - $manager->expects($this->any())->method('getUnitOfWork')->will($this->returnValue($unitOfWork)); - - $registry = $this->createMock(ManagerRegistry::class); - $registry->expects($this->once())->method('getManagerForClass')->will($this->returnValue($manager)); - - $adapter = new DoctrineORMAdapter($registry); - - $this->assertNull($adapter->getNormalizedIdentifier(new \stdClass())); - } - - /** - * @dataProvider getFixtures - * - * @group legacy - */ - public function testNormalizedIdentifierWithValidObject($data, $expected): void - { - $unitOfWork = $this->createMock(UnitOfWork::class); - $unitOfWork->expects($this->once())->method('isInIdentityMap')->will($this->returnValue(true)); - $unitOfWork->expects($this->once())->method('getEntityIdentifier')->will($this->returnValue($data)); - - $manager = $this->createMock(EntityManagerInterface::class); - $manager->expects($this->any())->method('getUnitOfWork')->will($this->returnValue($unitOfWork)); - - $registry = $this->createMock(ManagerRegistry::class); - $registry->expects($this->once())->method('getManagerForClass')->will($this->returnValue($manager)); - - $adapter = new DoctrineORMAdapter($registry); - - $this->assertSame($expected, $adapter->getNormalizedIdentifier(new \stdClass())); - } - - public static function getFixtures() - { - return [ - [[1], '1'], - [[1, 2], '1~2'], - ]; - } -} diff --git a/tests/Form/Validator/Constraints/InlineConstraintTest.php b/tests/Form/Validator/Constraints/InlineConstraintTest.php index 5e415cdd..7fa0c7ab 100755 --- a/tests/Form/Validator/Constraints/InlineConstraintTest.php +++ b/tests/Form/Validator/Constraints/InlineConstraintTest.php @@ -24,7 +24,7 @@ class InlineConstraintTest extends TestCase public function testValidatedBy(): void { $constraint = new InlineConstraint(['service' => 'foo', 'method' => 'bar']); - $this->assertSame('sonata.core.validator.inline', $constraint->validatedBy()); + $this->assertSame('sonata.form.validator.inline', $constraint->validatedBy()); } public function testIsClosure(): void diff --git a/tests/Serializer/BaseSerializerHandlerTest.php b/tests/Serializer/BaseSerializerHandlerTest.php index e1f01dcf..40b305ca 100644 --- a/tests/Serializer/BaseSerializerHandlerTest.php +++ b/tests/Serializer/BaseSerializerHandlerTest.php @@ -11,7 +11,7 @@ * file that was distributed with this source code. */ -namespace Sonata\CoreBundle\Tests\Serializer; +namespace Sonata\Serializer\Tests; use JMS\Serializer\Context; use JMS\Serializer\GraphNavigator; diff --git a/tests/Serializer/Fixtures/Bundle/Serializer/FooSerializer.php b/tests/Serializer/Fixtures/Bundle/Serializer/FooSerializer.php index d709b2b4..9a5f488e 100644 --- a/tests/Serializer/Fixtures/Bundle/Serializer/FooSerializer.php +++ b/tests/Serializer/Fixtures/Bundle/Serializer/FooSerializer.php @@ -13,7 +13,7 @@ namespace Sonata\Serializer\Tests\Fixtures\Bundle\Serializer; -use Sonata\CoreBundle\Model\ManagerInterface; +use Sonata\Doctrine\Model\ManagerInterface; use Sonata\Serializer\BaseSerializerHandler; /** diff --git a/tests/Twig/Extension/TemplateExtensionTest.php b/tests/Twig/Extension/TemplateExtensionTest.php index 61b455b9..c3c6f4b5 100644 --- a/tests/Twig/Extension/TemplateExtensionTest.php +++ b/tests/Twig/Extension/TemplateExtensionTest.php @@ -14,13 +14,14 @@ namespace Sonata\Twig\Tests\Extension; use PHPUnit\Framework\TestCase; +use Sonata\Doctrine\Adapter\AdapterInterface; use Sonata\Twig\Extension\TemplateExtension; class TemplateExtensionTest extends TestCase { public function testSafeUrl(): void { - $adapter = $this->createMock('Sonata\CoreBundle\Model\Adapter\AdapterInterface'); + $adapter = $this->createMock(AdapterInterface::class); $adapter->expects($this->once())->method('getUrlsafeIdentifier')->will($this->returnValue('safe-parameter')); $extension = new TemplateExtension(true, $adapter); diff --git a/tests/Twig/Node/TemplateBoxNodeTest.php b/tests/Twig/Node/TemplateBoxNodeTest.php index be1ce515..d5071dee 100644 --- a/tests/Twig/Node/TemplateBoxNodeTest.php +++ b/tests/Twig/Node/TemplateBoxNodeTest.php @@ -11,7 +11,7 @@ * file that was distributed with this source code. */ -namespace Sonata\CoreBundle\Tests\Twig\TokenParser; +namespace Sonata\Twig\Tests\Node; use Sonata\Twig\Node\TemplateBoxNode;