Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added supporting daterange type in Laravel (#67)
* added supporting daterange type * linter fixes * added tests
- Loading branch information
Showing
7 changed files
with
102 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Umbrellio\Postgres\Schema\Types; | ||
|
||
use Doctrine\DBAL\Platforms\AbstractPlatform; | ||
use Doctrine\DBAL\Types\Type; | ||
|
||
class DateRangeType extends Type | ||
{ | ||
public const TYPE_NAME = 'daterange'; | ||
|
||
public function getSQLDeclaration(array $fieldDeclaration, AbstractPlatform $platform) | ||
{ | ||
return static::TYPE_NAME; | ||
} | ||
|
||
public function getName(): string | ||
{ | ||
return self::TYPE_NAME; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Umbrellio\Postgres\Unit\Schema\Types; | ||
|
||
use Doctrine\DBAL\Platforms\AbstractPlatform; | ||
use Umbrellio\Postgres\Schema\Types\DateRangeType; | ||
use Umbrellio\Postgres\Tests\TestCase; | ||
|
||
class DateRangeTypeTest extends TestCase | ||
{ | ||
/** | ||
* @var AbstractPlatform | ||
*/ | ||
private $abstractPlatform; | ||
|
||
/** | ||
* @var DateRangeType | ||
*/ | ||
private $type; | ||
|
||
protected function setUp(): void | ||
{ | ||
parent::setUp(); | ||
|
||
$this->type = $this | ||
->getMockBuilder(DateRangeType::class) | ||
->disableOriginalConstructor() | ||
->getMockForAbstractClass(); | ||
$this->abstractPlatform = $this->getMockForAbstractClass(AbstractPlatform::class); | ||
} | ||
|
||
|
||
/** | ||
* @test | ||
*/ | ||
public function getSQLDeclaration(): void | ||
{ | ||
$this->assertSame(DateRangeType::TYPE_NAME, $this->type->getSQLDeclaration([], $this->abstractPlatform)); | ||
} | ||
|
||
|
||
/** | ||
* @test | ||
*/ | ||
public function getTypeName(): void | ||
{ | ||
$this->assertSame(DateRangeType::TYPE_NAME, $this->type->getName()); | ||
} | ||
} |