Skip to content

Commit f206dd8

Browse files
authored
Merge pull request #6 from blue-goheimochi/fix/if-condition-for-check-db
Fix if condition for check db
2 parents c4175eb + bc387a9 commit f206dd8

File tree

2 files changed

+22
-1
lines changed

2 files changed

+22
-1
lines changed

src/TsTzRangeType.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ class TsTzRangeType extends Type
1515
*/
1616
public function getSQLDeclaration(array $column, AbstractPlatform $platform)
1717
{
18-
if ($platform instanceof PostgreSQLPlatform) {
18+
if (!$platform instanceof PostgreSQLPlatform) {
1919
throw new \LogicException('TsTzRangeType only supports postgresql.');
2020
}
2121

tests/TsTzRangeTypeTest.php

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,34 @@
44

55
namespace Linkage\DoctrinePostgreSqlTsTzRange\Tests;
66

7+
use Doctrine\DBAL\Platforms\MySQLPlatform;
78
use Doctrine\DBAL\Platforms\PostgreSQLPlatform;
89
use Linkage\DoctrinePostgreSqlTsTzRange\Period;
910
use Linkage\DoctrinePostgreSqlTsTzRange\TsTzRangeType;
1011
use PHPUnit\Framework\TestCase;
1112

1213
class TsTzRangeTypeTest extends TestCase
1314
{
15+
public function testGetSQLDeclaration(): void
16+
{
17+
$platformMock = $this->createMock(PostgreSQLPlatform::class);
18+
$SUT = new TsTzRangeType();
19+
$column = [];
20+
$actual = $SUT->getSQLDeclaration($column, $platformMock);
21+
$this->assertEquals('tstzrange', $actual);
22+
}
23+
24+
public function testGetSQLDeclarationWithNotPostgres(): void
25+
{
26+
$this->expectException(\LogicException::class);
27+
$this->expectExceptionMessage("TsTzRangeType only supports postgresql.");
28+
29+
$platformMock = $this->createMock(MySQLPlatform::class);
30+
$SUT = new TsTzRangeType();
31+
$column = [];
32+
$SUT->getSQLDeclaration($column, $platformMock);
33+
}
34+
1435
public function testConvertToPHPValue(): void
1536
{
1637
$platformMock = $this->createMock(PostgreSQLPlatform::class);

0 commit comments

Comments
 (0)