Skip to content

Commit

Permalink
Remove obsolete version checks (#432)
Browse files Browse the repository at this point in the history
  • Loading branch information
derrabus committed Feb 5, 2024
1 parent c15bd5e commit 249eab8
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 38 deletions.
9 changes: 0 additions & 9 deletions tests/Query/Mysql/DateTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

namespace DoctrineExtensions\Tests\Query\Mysql;

use Doctrine\ORM\Version;
use DoctrineExtensions\Tests\Query\MysqlTestCase;

use function date;
Expand All @@ -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';

Expand Down Expand Up @@ -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_";

Expand Down
37 changes: 8 additions & 29 deletions tests/Query/Mysql/TrigTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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());
Expand All @@ -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());
Expand All @@ -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());
Expand Down Expand Up @@ -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());
Expand Down

0 comments on commit 249eab8

Please sign in to comment.