From c646b4d63976c056f0f4c8fe2ed77995ccea5b34 Mon Sep 17 00:00:00 2001 From: "Alexander M. Turek" Date: Mon, 5 Feb 2024 15:23:23 +0100 Subject: [PATCH] Remove obsolete version checks --- tests/Query/Mysql/DateTest.php | 9 --------- tests/Query/Mysql/TrigTest.php | 37 ++++++++-------------------------- 2 files changed, 8 insertions(+), 38 deletions(-) diff --git a/tests/Query/Mysql/DateTest.php b/tests/Query/Mysql/DateTest.php index f4fecdcc7..5ea4a7580 100644 --- a/tests/Query/Mysql/DateTest.php +++ b/tests/Query/Mysql/DateTest.php @@ -2,7 +2,6 @@ namespace DoctrineExtensions\Tests\Query\Mysql; -use Doctrine\ORM\Version; use DoctrineExtensions\Tests\Query\MysqlTestCase; use function date; @@ -27,10 +26,6 @@ public function testDateAdd(): void public function testDateAddWithColumnAlias(): void { - if (Version::VERSION < 2.2) { - $this->markTestSkipped('Alias is not supported in Doctrine 2.1 and lower'); - } - $dql = "SELECT p.created as alternative FROM DoctrineExtensions\Tests\Entities\Date p HAVING DATEADD(alternative, 4, 'MONTH') < 7"; $sql = 'SELECT d0_.created AS created_0 FROM Date d0_ HAVING DATE_ADD(created_0, INTERVAL 4 MONTH) < 7'; @@ -71,10 +66,6 @@ public function testFromUnixtime(): void public function testPeriodDiff(): void { - if (Version::VERSION < 2.3) { - $this->markTestSkipped('Doctrine 2.2 moans about something or other'); - } - $dql = "SELECT PERIOD_DIFF(date_format(p.created, '%Y%m'), date_format(p.created, '%Y%m')) FROM DoctrineExtensions\Tests\Entities\Date p"; $sql = "SELECT PERIOD_DIFF(DATE_FORMAT(d0_.created, '%Y%m'), DATE_FORMAT(d0_.created, '%Y%m')) AS sclr_0 FROM Date d0_"; diff --git a/tests/Query/Mysql/TrigTest.php b/tests/Query/Mysql/TrigTest.php index 2256e44ed..b92b82ad7 100644 --- a/tests/Query/Mysql/TrigTest.php +++ b/tests/Query/Mysql/TrigTest.php @@ -3,7 +3,6 @@ namespace DoctrineExtensions\Tests\Query\Mysql; use Doctrine\ORM\Query; -use Doctrine\ORM\Version; use DoctrineExtensions\Tests\Query\MysqlTestCase; use function deg2rad; @@ -42,13 +41,8 @@ public function testSin(): void $sql = 'SELECT SIN(RADIANS(b0_.latitude) * RADIANS(b0_.longitude)) AS sclr_0 FROM BlogPost b0_'; $this->assertEquals($sql, $q->getSql()); - if (Version::compare('2.4.0') <= 0) { - $dql = 'SELECT p FROM ' . $this->entity . ' p WHERE p.longitude = SIN(RADIANS(p.latitude)) * RADIANS(p.longitude)'; - } else { - $dql = 'SELECT p FROM ' . $this->entity . ' p WHERE p.longitude = (SIN(RADIANS(p.latitude)) * RADIANS(p.longitude))'; - } - - $q = $this->entityManager->createQuery($dql); + $dql = 'SELECT p FROM ' . $this->entity . ' p WHERE p.longitude = SIN(RADIANS(p.latitude)) * RADIANS(p.longitude)'; + $q = $this->entityManager->createQuery($dql); $sql = 'SELECT b0_.id AS id_0, b0_.created AS created_1, b0_.longitude AS longitude_2, b0_.latitude AS latitude_3 FROM BlogPost b0_ WHERE b0_.longitude = SIN(RADIANS(b0_.latitude)) * RADIANS(b0_.longitude)'; $this->assertEquals($sql, $q->getSql()); @@ -59,13 +53,8 @@ public function testSin(): void $sql = 'SELECT b0_.id AS id_0, b0_.created AS created_1, b0_.longitude AS longitude_2, b0_.latitude AS latitude_3 FROM BlogPost b0_ WHERE SIN(RADIANS(b0_.latitude)) * SIN(RADIANS(b0_.longitude)) = 1'; $this->assertEquals($sql, $q->getSql()); - if (Version::compare('2.4.0') <= 0) { - $dql = 'SELECT SIN(RADIANS(p.latitude)) * SIN(RADIANS(p.longitude)) FROM ' . $this->entity . ' p '; - } else { - $dql = 'SELECT (SIN(RADIANS(p.latitude)) * SIN(RADIANS(p.longitude))) FROM ' . $this->entity . ' p '; - } - - $q = $this->entityManager->createQuery($dql); + $dql = 'SELECT SIN(RADIANS(p.latitude)) * SIN(RADIANS(p.longitude)) FROM ' . $this->entity . ' p '; + $q = $this->entityManager->createQuery($dql); $sql = 'SELECT SIN(RADIANS(b0_.latitude)) * SIN(RADIANS(b0_.longitude)) AS sclr_0 FROM BlogPost b0_'; $this->assertEquals($sql, $q->getSql()); @@ -82,13 +71,8 @@ public function testAcos(): void $this->assertFirstQuery('ACOS'); $this->assertSecondQuery('ACOS'); - if (Version::compare('2.4.0') <= 0) { - $dql = 'SELECT ACOS(SIN(RADIANS(p.latitude)) + SIN(RADIANS(p.longitude))) * 1 FROM ' . $this->entity . ' p'; - } else { - $dql = 'SELECT (ACOS(SIN(RADIANS(p.latitude)) + SIN(RADIANS(p.longitude))) * 1) FROM ' . $this->entity . ' p'; - } - - $q = $this->entityManager->createQuery($dql); + $dql = 'SELECT ACOS(SIN(RADIANS(p.latitude)) + SIN(RADIANS(p.longitude))) * 1 FROM ' . $this->entity . ' p'; + $q = $this->entityManager->createQuery($dql); $sql = 'SELECT ACOS(SIN(RADIANS(b0_.latitude)) + SIN(RADIANS(b0_.longitude))) * 1 AS sclr_0 FROM BlogPost b0_'; $this->assertEquals($sql, $q->getSql()); @@ -158,13 +142,8 @@ public function testCosineLaw(): void . '* COS(RADIANS(p.longitude) - ' . deg2rad($lng) . ')' . ') * ' . $radiusOfEarth; - if (Version::compare('2.4.0') <= 0) { - $dql = 'SELECT ' . $cosineLaw . ' FROM ' . $this->entity . ' p'; - } else { - $dql = 'SELECT (' . $cosineLaw . ') FROM ' . $this->entity . ' p'; - } - - $q = $this->entityManager->createQuery($dql); + $dql = 'SELECT ' . $cosineLaw . ' FROM ' . $this->entity . ' p'; + $q = $this->entityManager->createQuery($dql); $sql = 'SELECT ACOS(SIN(0) * SIN(RADIANS(b0_.latitude)) + COS(0) * COS(RADIANS(b0_.latitude)) * COS(RADIANS(b0_.longitude) - 0)) * 6371 AS sclr_0 FROM BlogPost b0_'; $this->assertEquals($sql, $q->getSql());