From 74feb9bfd0b49d234e87d9949b923f3dd32f7f5c Mon Sep 17 00:00:00 2001 From: Fran Moreno Date: Tue, 5 Nov 2019 22:47:54 +0100 Subject: [PATCH] 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 d668912c5..e718cc245 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 fede2e081..03b0d3ba0 100644 --- a/tests/Model/ModelManagerTest.php +++ b/tests/Model/ModelManagerTest.php @@ -228,12 +228,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;