From 970cb0a928b2e494a0c8a7ff81f351dc6b6adf4d Mon Sep 17 00:00:00 2001 From: Fran Moreno Date: Tue, 5 Nov 2019 22:47:54 +0100 Subject: [PATCH 1/3] Remove deprecated code for doctrine < 2.5 --- tests/Datagrid/OrderByToSelectWalkerTest.php | 15 +++------------ tests/Datagrid/ProxyQueryTest.php | 10 +++++----- tests/Model/ModelManagerTest.php | 6 ------ 3 files changed, 8 insertions(+), 23 deletions(-) diff --git a/tests/Datagrid/OrderByToSelectWalkerTest.php b/tests/Datagrid/OrderByToSelectWalkerTest.php index 87318c9d4..b01c8c5c7 100644 --- a/tests/Datagrid/OrderByToSelectWalkerTest.php +++ b/tests/Datagrid/OrderByToSelectWalkerTest.php @@ -55,10 +55,7 @@ public function testOrderByCompositeId(): void $query->setHint(Query::HINT_CUSTOM_TREE_WALKERS, [OrderByToSelectWalker::class]); $this->assertSame( - // NEXT_MAJOR: Remove this check when dropping support for doctrine/orm < 2.5 - version_compare(Version::VERSION, '2.5') < 0 - ? 'SELECT DISTINCT s0_.store_id AS sclr0, s0_.product_id AS sclr1, s0_.name AS name2 FROM StoreProduct s0_ ORDER BY s0_.name ASC, s0_.product_id DESC' - : 'SELECT DISTINCT s0_.store_id AS sclr_0, s0_.product_id AS sclr_1, s0_.name AS name_2 FROM StoreProduct s0_ ORDER BY s0_.name ASC, s0_.product_id DESC', + 'SELECT DISTINCT s0_.store_id AS sclr_0, s0_.product_id AS sclr_1, s0_.name AS name_2 FROM StoreProduct s0_ ORDER BY s0_.name ASC, s0_.product_id DESC', $query->getSQL() ); } @@ -76,10 +73,7 @@ public function testOrderByCompositeIdWholeObject(): void $query->setHint(Query::HINT_CUSTOM_TREE_WALKERS, [OrderByToSelectWalker::class]); $this->assertSame( - // NEXT_MAJOR: Remove this check when dropping support for doctrine/orm < 2.5 - version_compare(Version::VERSION, '2.5') < 0 - ? 'SELECT DISTINCT s0_.name AS name0, s0_.store_id AS store_id1, s0_.product_id AS product_id2 FROM StoreProduct s0_ ORDER BY s0_.name ASC, s0_.product_id DESC' - : 'SELECT DISTINCT s0_.name AS name_0, s0_.store_id AS store_id_1, s0_.product_id AS product_id_2 FROM StoreProduct s0_ ORDER BY s0_.name ASC, s0_.product_id DESC', + 'SELECT DISTINCT s0_.name AS name_0, s0_.store_id AS store_id_1, s0_.product_id AS product_id_2 FROM StoreProduct s0_ ORDER BY s0_.name ASC, s0_.product_id DESC', $query->getSQL() ); } @@ -96,10 +90,7 @@ public function testOrderByAssociation(): void $query->setHint(Query::HINT_CUSTOM_TREE_WALKERS, [OrderByToSelectWalker::class]); $this->assertSame( - // NEXT_MAJOR: Remove this check when dropping support for doctrine/orm < 2.5 - version_compare(Version::VERSION, '2.5') < 0 - ? 'SELECT DISTINCT m0_.id AS id0, m0_.tree_root AS sclr1, m0_.lft AS lft2 FROM Menu m0_ ORDER BY m0_.tree_root ASC, m0_.lft ASC' - : 'SELECT DISTINCT m0_.id AS id_0, m0_.tree_root AS sclr_1, m0_.lft AS lft_2 FROM Menu m0_ ORDER BY m0_.tree_root ASC, m0_.lft ASC', + 'SELECT DISTINCT m0_.id AS id_0, m0_.tree_root AS sclr_1, m0_.lft AS lft_2 FROM Menu m0_ ORDER BY m0_.tree_root ASC, m0_.lft ASC', $query->getSQL() ); } diff --git a/tests/Datagrid/ProxyQueryTest.php b/tests/Datagrid/ProxyQueryTest.php index db953e4e6..c5ae244ab 100644 --- a/tests/Datagrid/ProxyQueryTest.php +++ b/tests/Datagrid/ProxyQueryTest.php @@ -16,6 +16,7 @@ use Doctrine\DBAL\Connection; use Doctrine\DBAL\Platforms\PostgreSqlPlatform; use Doctrine\DBAL\Types\Type; +use Doctrine\ORM\AbstractQuery; use Doctrine\ORM\EntityManager; use Doctrine\ORM\Mapping\ClassMetadata; use Doctrine\ORM\Mapping\ClassMetadataFactory; @@ -115,11 +116,10 @@ public function testGetFixedQueryBuilder($class, $alias, $id, $expectedId, $valu ->method('getConnection') ->willReturn($conn); - // NEXT MAJOR: Replace this when dropping PHP < 5.6 - // $q = $this->createMock('PDOStatement'); - $q = $this->getMockBuilder('stdClass') - ->setMethods(['execute', 'setHint']) - ->getMock(); + $q = $this->getMockBuilder(AbstractQuery::class) + ->disableOriginalConstructor() + ->setMethods(['setHint', 'execute']) + ->getMockForAbstractClass(); $q->expects($this->once()) ->method('setHint') ->willReturn($q); diff --git a/tests/Model/ModelManagerTest.php b/tests/Model/ModelManagerTest.php index 263a5da6b..7c966c19f 100644 --- a/tests/Model/ModelManagerTest.php +++ b/tests/Model/ModelManagerTest.php @@ -212,12 +212,6 @@ public function testLock($isVersioned, $expectsException): void public function testGetParentMetadataForProperty(): void { - if (version_compare(Version::VERSION, '2.5') < 0) { - $this->markTestSkipped('Test for embeddables needs to run on Doctrine >= 2.5'); - - return; - } - $containerEntityClass = ContainerEntity::class; $associatedEntityClass = AssociatedEntity::class; $embeddedEntityClass = EmbeddedEntity::class; From 2de1e5a3d47b530a93098f6731f993167344745f Mon Sep 17 00:00:00 2001 From: Fran Moreno Date: Sun, 10 Nov 2019 21:03:31 +0100 Subject: [PATCH 2/3] Dropping support for Symfony < 3.4 --- composer.json | 18 +++++++------- docs/reference/filter_field_definition.rst | 4 ++-- docs/reference/form_field_definition.rst | 24 +++++++++++-------- .../reference/form_types_and_transformers.rst | 18 +++++++------- .../defining_admin_class.rst | 8 ++++--- src/Builder/DatagridBuilder.php | 3 +-- src/Builder/FormContractor.php | 23 ++++++------------ .../views/Form/form_admin_fields.html.twig | 2 +- tests/Builder/FormContractorTest.php | 9 +------ tests/Datagrid/OrderByToSelectWalkerTest.php | 1 - tests/Model/ModelManagerTest.php | 1 - 11 files changed, 50 insertions(+), 61 deletions(-) diff --git a/composer.json b/composer.json index 11574ba90..211a85db6 100644 --- a/composer.json +++ b/composer.json @@ -29,15 +29,15 @@ "sonata-project/admin-bundle": "^3.29", "sonata-project/core-bundle": "^3.14", "sonata-project/exporter": "^1.11.0 || ^2.0", - "symfony/config": "^2.8 || ^3.2 || ^4.0", - "symfony/console": "^2.8 || ^3.2 || ^4.0", - "symfony/dependency-injection": "^2.8 || ^3.2 || ^4.0", - "symfony/doctrine-bridge": "^2.8 || ^3.2 || ^4.0", - "symfony/form": "^2.8 || ^3.2 || ^4.0", - "symfony/framework-bundle": "^2.8 || ^3.2 || ^4.0", - "symfony/http-foundation": "^2.8 || ^3.2 || ^4.0", - "symfony/http-kernel": "^2.8 || ^3.2 || ^4.0", - "symfony/options-resolver": "^2.8 || ^3.2 || ^4.0", + "symfony/config": "^3.4 || ^4.2", + "symfony/console": "^3.4 || ^4.2", + "symfony/dependency-injection": "^3.4 || ^4.2", + "symfony/doctrine-bridge": "^3.4 || ^4.2", + "symfony/form": "^3.4 || ^4.2", + "symfony/framework-bundle": "^3.4 || ^4.2", + "symfony/http-foundation": "^3.4 || ^4.2", + "symfony/http-kernel": "^3.4 || ^4.2", + "symfony/options-resolver": "^3.4 || ^4.2", "symfony/security-acl": "^2.8 || ^3.0" }, "conflict": { diff --git a/docs/reference/filter_field_definition.rst b/docs/reference/filter_field_definition.rst index 5714c55c6..261ba458b 100644 --- a/docs/reference/filter_field_definition.rst +++ b/docs/reference/filter_field_definition.rst @@ -69,9 +69,9 @@ Example doctrine_orm_model_autocomplete ------------------------------- -This filter type uses ``sonata_type_model_autocomplete`` form type. It renders an input with select2 autocomplete feature. +This filter type uses ``Sonata\AdminBundle\Form\Type\ModelAutocompleteType`` form type. It renders an input with select2 autocomplete feature. Can be used as replacement of ``doctrine_orm_model`` to handle too many related items that cannot be loaded into memory. -This form type requires ``property`` option. See documentation of ``sonata_type_model_autocomplete`` for all available options for this form type:: +This form type requires ``property`` option. See documentation of ``Sonata\AdminBundle\Form\Type\ModelAutocompleteType`` for all available options for this form type:: protected function configureDatagridFilters(DatagridMapper $datagridMapper) { diff --git a/docs/reference/form_field_definition.rst b/docs/reference/form_field_definition.rst index 2666e5f93..da5eb9e57 100644 --- a/docs/reference/form_field_definition.rst +++ b/docs/reference/form_field_definition.rst @@ -14,6 +14,7 @@ Example use Sonata\AdminBundle\Admin\AbstractAdmin; use Sonata\AdminBundle\Form\FormMapper; + use Sonata\AdminBundle\Form\Type\ModelListType; use Sonata\CoreBundle\Validator\ErrorElement; final class PostAdmin extends AbstractAdmin @@ -21,7 +22,7 @@ Example protected function configureFormFields(FormMapper $formMapper) { $formMapper - ->add('author', 'sonata_type_model_list', []) + ->add('author', ModelListType::class, []) ->add('enabled') ->add('title') ->add('abstract', null, ['required' => false]) @@ -80,6 +81,7 @@ you can use the corresponding option in the form field definition:: use Sonata\AdminBundle\Admin\AbstractAdmin; use Sonata\AdminBundle\Form\FormMapper; + use Sonata\AdminBundle\Form\Type\ModelListType; final class PostAdmin extends AbstractAdmin { @@ -88,7 +90,7 @@ you can use the corresponding option in the form field definition:: $formMapper ->with('General') ->add('enabled', null, ['required' => false]) - ->add('author', 'sonata_type_model_list', [], [ + ->add('author', ModelListType::class, [], [ 'placeholder' => 'No author selected', ]); } @@ -139,8 +141,8 @@ If you have many ``Post`` linked to one ``User``, then the ``Post`` form should The AdminBundle provides 2 options: -* ``sonata_type_model``: the ``User`` list is set in a select widget with an `Add` button to create a new ``User``, -* ``sonata_type_model_list``: the ``User`` list is set in a model where you can search, select and delete a ``User``. +* ``\Sonata\AdminBundle\Form\Type\ModelType``: the ``User`` list is set in a select widget with an `Add` button to create a new ``User``, +* ``\Sonata\AdminBundle\Form\Type\ModelListType``: the ``User`` list is set in a model where you can search, select and delete a ``User``. .. code-block:: php @@ -148,6 +150,8 @@ The AdminBundle provides 2 options: use Sonata\AdminBundle\Admin\AbstractAdmin; use Sonata\AdminBundle\Form\FormMapper; + use Sonata\AdminBundle\Form\Type\ModelListType; + use Sonata\AdminBundle\Form\Type\ModelType; final class PostAdmin extends AbstractAdmin { @@ -156,7 +160,7 @@ The AdminBundle provides 2 options: $formMapper ->with('General') ->add('enabled', null, ['required' => false]) - ->add('author', 'sonata_type_model_list', [ + ->add('author', ModelListType::class, [ 'btn_add' => 'Add author', //Specify a custom label 'btn_list' => 'button.list', //which will be translated 'btn_delete' => false, //or hide the button. @@ -170,7 +174,7 @@ The AdminBundle provides 2 options: ->add('content') ->end() ->with('Tags') - ->add('tags', 'sonata_type_model', ['expanded' => true]) + ->add('tags', ModelType::class, ['expanded' => true]) ->end() ->with('Options', ['collapsed' => true]) ->add('commentsCloseAt') @@ -221,11 +225,11 @@ You can easily add a new ``Media`` row by defining one of these options: ]); } } - -.. note:: + +.. note:: You have to define the ``setMedias`` method into your ``Gallery`` class and manually attach each ``media`` to the current ``gallery`` and define cascading persistence for the relationship from media to gallery. - + By default, position row will be rendered. If you want to hide it, you will need to alter child admin class and add hidden position field. Use code like:: @@ -243,6 +247,6 @@ To render child help messages you must use 'sonata_help' instead of 'help':: { $formMapper ->add('image', 'file', [ - 'sonata_help' => 'help message rendered in parent sonata_type_collection' + 'sonata_help' => 'help message rendered in parent CollectionType' ]); } diff --git a/docs/reference/form_types_and_transformers.rst b/docs/reference/form_types_and_transformers.rst index adbc9f8fa..e1cfdc679 100644 --- a/docs/reference/form_types_and_transformers.rst +++ b/docs/reference/form_types_and_transformers.rst @@ -10,13 +10,13 @@ The `AdminBundle` is shipped with custom form types and data transfomers in orde Form types ---------- -* ``sonata_type_admin``: this type is linked to an `Admin` class and the field construction is delegated to an Admin class, -* ``sonata_type_collection``: this type works like the native ``CollectionType`` but contains two extra features: +* ``\Sonata\AdminBundle\Form\Type\AdminType``: this type is linked to an `Admin` class and the field construction is delegated to an Admin class, +* ``\Sonata\Form\Type\CollectionType``: this type works like the native ``CollectionType`` but contains two extra features: * the data layer is abstracted to work with any implemented layer, * a delete option is added so a collection entry can be deleted. -* ``sonata_type_model``: this type works like the native ``EntityType`` but this internal is abstracted to work with any implemented layer. -* ``sonata_type_immutable_array``: this type allows to edit a fixed array, like a settings array. +* ``\Sonata\AdminBundle\Form\Type\ModelType``: this type works like the native ``EntityType`` but this internal is abstracted to work with any implemented layer. +* ``\Sonata\Form\Type\ImmutableArrayType``: this type allows to edit a fixed array, like a settings array. Let's say, the object has settings properties:: @@ -35,6 +35,7 @@ Now you can edit the settings array with:: use Sonata\AdminBundle\Admin\AbstractAdmin; use Sonata\AdminBundle\Form\FormMapper; + use Sonata\Form\Type\ImmutableArrayType; final class PageAdmin extends AbstractAdmin { @@ -42,7 +43,7 @@ Now you can edit the settings array with:: { $formMapper ->add('enabled') - ->add('settings', 'sonata_type_immutable_array', [ + ->add('settings', ImmutableArrayType::class, [ 'keys' => [ ['content', 'textarea', []], ['public', 'checkbox', []], @@ -63,6 +64,7 @@ Other options:: use Sonata\AdminBundle\Admin\AbstractAdmin; use Sonata\AdminBundle\Form\FormMapper; + use Sonata\AdminBundle\Form\Type\ModelType; use Application\Sonata\NewsBundle\Entity\Comment; @@ -73,13 +75,13 @@ Other options:: $formMapper ->with('General') ->add('enabled', null, ['required' => false]) - ->add('author', 'sonata_type_model', [], ['edit' => 'list']) + ->add('author', ModelType::class, [], ['edit' => 'list']) ->add('title') ->add('abstract') ->add('content') ->end() ->with('Tags') - ->add('tags', 'sonata_type_model', ['expanded' => true]) + ->add('tags', ModelType::class, ['expanded' => true]) ->end() ->with('Options', ['collapsed' => true]) ->add('commentsCloseAt') @@ -97,4 +99,4 @@ DataTransformer * ``ArrayToModelTransformer``: transform an array to an object, * ``ModelsToArrayTransformer``: transform a collection of array into a collection of object, -* ``ModelToIdTransformater``: transform an ``id`` into an object. \ No newline at end of file +* ``ModelToIdTransformater``: transform an ``id`` into an object. diff --git a/docs/tutorial/creating_your_first_admin_class/defining_admin_class.rst b/docs/tutorial/creating_your_first_admin_class/defining_admin_class.rst index 041d983d9..eef4825a6 100644 --- a/docs/tutorial/creating_your_first_admin_class/defining_admin_class.rst +++ b/docs/tutorial/creating_your_first_admin_class/defining_admin_class.rst @@ -22,6 +22,7 @@ First, you need to create an `Admin/PostAdmin.php` file:: use Sonata\AdminBundle\Form\FormMapper; use Sonata\AdminBundle\Datagrid\DatagridMapper; use Sonata\AdminBundle\Datagrid\ListMapper; + use Sonata\AdminBundle\Form\Type\ModelType; use Sonata\AdminBundle\Show\ShowMapper; use Knp\Menu\ItemInterface as MenuItemInterface; @@ -51,10 +52,10 @@ First, you need to create an `Admin/PostAdmin.php` file:: ->add('content') ->end() ->with('Tags') - ->add('tags', 'sonata_type_model', ['expanded' => true, 'multiple' => true]) + ->add('tags', ModelType::class, ['expanded' => true, 'multiple' => true]) ->end() ->with('Comments') - ->add('comments', 'sonata_type_model', ['multiple' => true]) + ->add('comments', ModelType::class, ['multiple' => true]) ->end() ->with('System Information', ['collapsed' => true]) ->add('created_at') @@ -195,6 +196,7 @@ Tweak the CommentAdmin class use Sonata\AdminBundle\Admin\AbstractAdmin; use Sonata\AdminBundle\Form\FormMapper; + use Sonata\AdminBundle\Form\Type\ModelType; use Sonata\AdminBundle\Datagrid\DatagridMapper; use Sonata\AdminBundle\Datagrid\ListMapper; @@ -207,7 +209,7 @@ Tweak the CommentAdmin class protected function configureFormFields(FormMapper $formMapper) { if (!$this->isChild()) { - $formMapper->add('post', 'sonata_type_model', [], ['edit' => 'list']); + $formMapper->add('post', ModelType::class, [], ['edit' => 'list']); } $formMapper diff --git a/src/Builder/DatagridBuilder.php b/src/Builder/DatagridBuilder.php index 9b9d3c6c2..d5f010658 100644 --- a/src/Builder/DatagridBuilder.php +++ b/src/Builder/DatagridBuilder.php @@ -156,8 +156,7 @@ public function addFilter(DatagridInterface $datagrid, $type, FieldDescriptionIn $fieldDescription->mergeOption('field_options', ['required' => false]); - // NEXT_MAJOR: Check only against FQCNs when dropping support for Symfony 2.8 - if ('doctrine_orm_model_autocomplete' === $type || ModelAutocompleteFilter::class === $type) { + if (ModelAutocompleteFilter::class === $type) { $fieldDescription->mergeOption('field_options', [ 'class' => $fieldDescription->getTargetEntity(), 'model_manager' => $fieldDescription->getAdmin()->getModelManager(), diff --git a/src/Builder/FormContractor.php b/src/Builder/FormContractor.php index e83443a47..9592ee55c 100644 --- a/src/Builder/FormContractor.php +++ b/src/Builder/FormContractor.php @@ -99,13 +99,7 @@ public function getDefaultOptions($type, FieldDescriptionInterface $fieldDescrip $options = []; $options['sonata_field_description'] = $fieldDescription; - // NEXT_MAJOR: Check only against FQCNs when dropping support for Symfony 2.8 - if (\in_array($type, [ - 'sonata_type_model', - 'sonata_type_model_list', - 'sonata_type_model_hidden', - 'sonata_type_model_autocomplete', - ], true) || $this->checkFormClass($type, [ + if ($this->checkFormClass($type, [ ModelType::class, ModelTypeList::class, ModelListType::class, @@ -114,7 +108,7 @@ public function getDefaultOptions($type, FieldDescriptionInterface $fieldDescrip ])) { if ('list' === $fieldDescription->getOption('edit')) { throw new \LogicException( - 'The `sonata_type_model` type does not accept an `edit` option anymore,' + 'The `\Sonata\AdminBundle\Form\Type\ModelType` type does not accept an `edit` option anymore,' .' please review the UPGRADE-2.1.md file from the SonataAdminBundle' ); } @@ -122,8 +116,7 @@ public function getDefaultOptions($type, FieldDescriptionInterface $fieldDescrip $options['class'] = $fieldDescription->getTargetEntity(); $options['model_manager'] = $fieldDescription->getAdmin()->getModelManager(); - // NEXT_MAJOR: Check only against FQCNs when dropping support for Symfony 2.8 - if ('sonata_type_model_autocomplete' === $type || $this->checkFormClass($type, [ModelAutocompleteType::class])) { + if ($this->checkFormClass($type, [ModelAutocompleteType::class])) { if (!$fieldDescription->getAssociationAdmin()) { throw new \RuntimeException(sprintf( 'The current field `%s` is not linked to an admin.' @@ -133,8 +126,7 @@ public function getDefaultOptions($type, FieldDescriptionInterface $fieldDescrip )); } } - // NEXT_MAJOR: Check only against FQCNs when dropping support for Symfony 2.8 - } elseif ('sonata_type_admin' === $type || $this->checkFormClass($type, [AdminType::class])) { + } elseif ($this->checkFormClass($type, [AdminType::class])) { if (!$fieldDescription->getAssociationAdmin()) { throw new \RuntimeException(sprintf( 'The current field `%s` is not linked to an admin.' @@ -149,8 +141,8 @@ public function getDefaultOptions($type, FieldDescriptionInterface $fieldDescrip ClassMetadata::MANY_TO_ONE, ], true)) { throw new \RuntimeException(sprintf( - 'You are trying to add `sonata_type_admin` field `%s` which is not One-To-One or Many-To-One.' - .' Maybe you want `sonata_type_collection` instead?', + 'You are trying to add `Sonata\AdminBundle\Form\Type\AdminType` field `%s` which is not One-To-One or Many-To-One.' + .' Maybe you want `Sonata\Form\Type\CollectionType` instead?', $fieldDescription->getName() )); } @@ -164,8 +156,7 @@ public function getDefaultOptions($type, FieldDescriptionInterface $fieldDescrip return $fieldDescription->getAssociationAdmin()->getNewInstance(); }; $fieldDescription->setOption('edit', $fieldDescription->getOption('edit', 'admin')); - // NEXT_MAJOR: Check only against FQCNs when dropping support for Symfony 2.8 - } elseif ('sonata_type_collection' === $type || $this->checkFormClass($type, [CollectionType::class, DeprecatedCollectionType::class])) { + } elseif ($this->checkFormClass($type, [CollectionType::class, DeprecatedCollectionType::class])) { if (!$fieldDescription->getAssociationAdmin()) { throw new \RuntimeException(sprintf( 'The current field `%s` is not linked to an admin.' diff --git a/src/Resources/views/Form/form_admin_fields.html.twig b/src/Resources/views/Form/form_admin_fields.html.twig index 504f65ae8..b8b77301d 100644 --- a/src/Resources/views/Form/form_admin_fields.html.twig +++ b/src/Resources/views/Form/form_admin_fields.html.twig @@ -171,6 +171,6 @@ file that was distributed with this source code. {% elseif sonata_admin.field_description.mappingtype == constant('Doctrine\\ORM\\Mapping\\ClassMetadataInfo::MANY_TO_MANY') %} {{ block('sonata_admin_orm_many_to_many_widget') }} {% else %} - INVALID MODE : {{ id }} - type : sonata_type_collection - mapping : {{ sonata_admin.field_description.mappingtype }} + INVALID MODE : {{ id }} - type : CollectionType - mapping : {{ sonata_admin.field_description.mappingtype }} {% endif %} {% endblock %} diff --git a/tests/Builder/FormContractorTest.php b/tests/Builder/FormContractorTest.php index 77b03640c..642d37802 100644 --- a/tests/Builder/FormContractorTest.php +++ b/tests/Builder/FormContractorTest.php @@ -79,23 +79,16 @@ public function testDefaultOptionsForSonataFormTypes(): void $fieldDescription->method('getAssociationAdmin')->willReturn($admin); $admin->method('getNewInstance')->willReturn($model); - // NEXT_MAJOR: Use only FQCNs when dropping support for Symfony 2.8 $modelTypes = [ - 'sonata_type_model', - 'sonata_type_model_list', - 'sonata_type_model_hidden', - 'sonata_type_model_autocomplete', ModelType::class, ModelListType::class, ModelHiddenType::class, ModelAutocompleteType::class, ]; $adminTypes = [ - 'sonata_type_admin', AdminType::class, ]; $collectionTypes = [ - 'sonata_type_collection', DeprecatedCollectionType::class, ]; @@ -146,7 +139,7 @@ public function testAdminClassAttachForNotMappedField(): void $fieldDescription = $this->createMock(FieldDescriptionInterface::class); $fieldDescription->method('getMappingType')->willReturn('simple'); - $fieldDescription->method('getType')->willReturn('sonata_type_model_list'); + $fieldDescription->method('getType')->willReturn(ModelListType::class); $fieldDescription->method('getOption')->with($this->logicalOr( $this->equalTo('edit'), $this->equalTo('admin_code') diff --git a/tests/Datagrid/OrderByToSelectWalkerTest.php b/tests/Datagrid/OrderByToSelectWalkerTest.php index b01c8c5c7..c2b830868 100644 --- a/tests/Datagrid/OrderByToSelectWalkerTest.php +++ b/tests/Datagrid/OrderByToSelectWalkerTest.php @@ -15,7 +15,6 @@ use Doctrine\ORM\EntityManager; use Doctrine\ORM\Query; -use Doctrine\ORM\Version; use PHPUnit\Framework\TestCase; use Sonata\DoctrineORMAdminBundle\Datagrid\OrderByToSelectWalker; use Sonata\DoctrineORMAdminBundle\Tests\Fixtures\Entity\ORM\Menu; diff --git a/tests/Model/ModelManagerTest.php b/tests/Model/ModelManagerTest.php index 7c966c19f..d79a9c38d 100644 --- a/tests/Model/ModelManagerTest.php +++ b/tests/Model/ModelManagerTest.php @@ -26,7 +26,6 @@ use Doctrine\ORM\OptimisticLockException; use Doctrine\ORM\Query; use Doctrine\ORM\QueryBuilder; -use Doctrine\ORM\Version; use PHPUnit\Framework\TestCase; use Sonata\AdminBundle\Datagrid\Datagrid; use Sonata\AdminBundle\Datagrid\DatagridInterface; From 47bd527f830d181024f42723ad1d4e6217dc6fdd Mon Sep 17 00:00:00 2001 From: Fran Moreno Date: Sun, 10 Nov 2019 21:05:27 +0100 Subject: [PATCH 3/3] Fix typo in function name --- src/Block/AuditBlockService.php | 2 +- tests/Block/AuditBlockServiceTest.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Block/AuditBlockService.php b/src/Block/AuditBlockService.php index 9b7f37a4f..e2fbbcc7a 100644 --- a/src/Block/AuditBlockService.php +++ b/src/Block/AuditBlockService.php @@ -49,7 +49,7 @@ public function execute(BlockContextInterface $blockContext, Response $response foreach ($this->auditReader->findRevisionHistory($blockContext->getSetting('limit'), 0) as $revision) { $revisions[] = [ 'revision' => $revision, - 'entities' => $this->auditReader->findEntitesChangedAtRevision($revision->getRev()), + 'entities' => $this->auditReader->findEntitiesChangedAtRevision($revision->getRev()), ]; } diff --git a/tests/Block/AuditBlockServiceTest.php b/tests/Block/AuditBlockServiceTest.php index 4ad7e91ad..06361723c 100644 --- a/tests/Block/AuditBlockServiceTest.php +++ b/tests/Block/AuditBlockServiceTest.php @@ -55,7 +55,7 @@ public function testExecute(): void ->willReturn([$revision = new Revision('test', '123', 'test')]) ->shouldBeCalledTimes(1); - $this->simpleThingsAuditReader->findEntitesChangedAtRevision(Argument::cetera()) + $this->simpleThingsAuditReader->findEntitiesChangedAtRevision(Argument::cetera()) ->willReturn([]) ->shouldBeCalledTimes(1);