Skip to content

Commit

Permalink
Improve test coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
Tigrov committed Dec 12, 2024
1 parent 5e06392 commit e91fc67
Showing 1 changed file with 53 additions and 0 deletions.
53 changes: 53 additions & 0 deletions tests/Db/QueryBuilder/ColumnDefinitionBuilderTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
<?php

declare(strict_types=1);

namespace Yiisoft\Db\Tests\Db\QueryBuilder;

use PHPUnit\Framework\TestCase;
use Yiisoft\Db\Exception\Exception;
use Yiisoft\Db\QueryBuilder\AbstractColumnDefinitionBuilder;
use Yiisoft\Db\Schema\Column\ColumnBuilder;
use Yiisoft\Db\Schema\Column\ColumnSchemaInterface;
use Yiisoft\Db\Tests\Support\Stub\ColumnDefinitionBuilder;
use Yiisoft\Db\Tests\Support\TestTrait;

/**
* @group db
*/
final class ColumnDefinitionBuilderTest extends TestCase
{
use TestTrait;

/**
* @throws Exception
*/
public function testBuildAlter(): void
{
$db = $this->getConnection();
$qb = $db->getQueryBuilder();

$cdb = new ColumnDefinitionBuilder($qb);

$column = ColumnBuilder::integer();

$this->assertEquals($cdb->build($column), $cdb->buildAlter($column));
}

public function testBuildEmptyDefaultForUuid(): void
{
$db = $this->getConnection();
$qb = $db->getQueryBuilder();

$cdb = new class ($qb) extends AbstractColumnDefinitionBuilder {
protected function getDbType(ColumnSchemaInterface $column): string
{
return 'uuid';
}
};

$column = ColumnBuilder::uuidPrimaryKey();

$this->assertSame('uuid PRIMARY KEY', $cdb->build($column));
}
}

0 comments on commit e91fc67

Please sign in to comment.