Skip to content

Commit

Permalink
test: add functional
Browse files Browse the repository at this point in the history
  • Loading branch information
vencakrecl committed Jul 8, 2024
1 parent 71709d8 commit 6e4e4ea
Showing 1 changed file with 31 additions and 0 deletions.
31 changes: 31 additions & 0 deletions tests/Functional/Schema/DefaultValueTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@

namespace Doctrine\DBAL\Tests\Functional\Schema;

use Doctrine\DBAL\Platforms\PostgreSQLPlatform;
use Doctrine\DBAL\Platforms\SQLServerPlatform;
use Doctrine\DBAL\Schema\Table;
use Doctrine\DBAL\Tests\FunctionalTestCase;
use Doctrine\DBAL\Types\Types;
Expand Down Expand Up @@ -31,6 +33,35 @@ protected function setUp(): void
$this->connection->insert('default_value', ['id' => 1]);
}

public function testDefaultValueAsFunction(): void
{
$platform = $this->connection->getDatabasePlatform();
$defaultValue = 'uuid()';
if ($platform instanceof PostgreSQLPlatform) {
$defaultValue = 'gen_random_uuid()';
}

if ($platform instanceof SQLServerPlatform) {
$defaultValue = 'newid()';
}

$table = new Table('default_value');
$table->addColumn('id', Types::STRING, ['default' => $defaultValue, 'length' => 36]);

$this->dropAndCreateTable($table);

$sm = $this->connection->createSchemaManager();
$onlineTable = $sm->introspectTable('default_value');

self::assertSame($defaultValue, $onlineTable->getColumn('id')->getDefault());

self::assertTrue(
$sm->createComparator()
->compareTables($table, $onlineTable)
->isEmpty(),
);
}

#[DataProvider('columnProvider')]
public function testEscapedDefaultValueCanBeIntrospected(string $name, ?string $expectedDefault): void
{
Expand Down

0 comments on commit 6e4e4ea

Please sign in to comment.