/
PostgreSqlSchemaManagerTest.php
48 lines (36 loc) · 1.43 KB
/
PostgreSqlSchemaManagerTest.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
<?php
namespace Doctrine\Tests\DBAL\Functional\Schema;
use Doctrine\DBAL\Schema;
use Doctrine\DBAL\Types\Type;
use Doctrine\DBAL\Platforms\AbstractPlatform;
require_once __DIR__ . '/../../../TestInit.php';
class PostgreSqlSchemaManagerTest extends SchemaManagerFunctionalTestCase
{
/**
* @group DBAL-21
*/
public function testSupportDomainTypeFallback()
{
$createDomainTypeSQL = "CREATE DOMAIN MyMoney AS DECIMAL(18,2)";
$this->_conn->exec($createDomainTypeSQL);
$createTableSQL = "CREATE TABLE domain_type_test (id INT PRIMARY KEY, value MyMoney)";
$this->_conn->exec($createTableSQL);
$table = $this->_conn->getSchemaManager()->listTableDetails('domain_type_test');
$this->assertType('Doctrine\DBAL\Types\DecimalType', $table->getColumn('value')->getType());
Type::addType('MyMoney', 'Doctrine\Tests\DBAL\Functional\Schema\MoneyType');
$this->_conn->getDatabasePlatform()->registerDoctrineTypeMapping('MyMoney', 'MyMoney');
$table = $this->_conn->getSchemaManager()->listTableDetails('domain_type_test');
$this->assertType('Doctrine\Tests\DBAL\Functional\Schema\MoneyType', $table->getColumn('value')->getType());
}
}
class MoneyType extends Type
{
public function getName()
{
return "MyMoney";
}
public function getSqlDeclaration(array $fieldDeclaration, AbstractPlatform $platform)
{
return 'MyMoney';
}
}