Skip to content

Commit

Permalink
Remove src\TestSupport\TestColumnSchemaBuilderTrait from yiisoft\db. (#…
Browse files Browse the repository at this point in the history
…408)

* Remove src\TestSupport\TestColumnSchemaBuilderTrait from yiisoft\db.
  • Loading branch information
terabytesoftw committed Dec 7, 2022
1 parent 27d6e00 commit df027fd
Show file tree
Hide file tree
Showing 4 changed files with 75 additions and 53 deletions.
53 changes: 0 additions & 53 deletions src/TestSupport/TestColumnSchemaBuilderTrait.php

This file was deleted.

39 changes: 39 additions & 0 deletions tests/Common/CommonColumnSchemaBuilderTest.php
@@ -0,0 +1,39 @@
<?php

declare(strict_types=1);

namespace Yiisoft\Db\Tests\Common;

use PHPUnit\Framework\TestCase;
use Yiisoft\Db\Tests\Support\TestTrait;

use function array_shift;
use function call_user_func_array;

abstract class CommonColumnSchemaBuilderTest extends TestCase
{
use TestTrait;

/**
* @dataProvider \Yiisoft\Db\Tests\Provider\ColumnSchemaBuilderProvider::types();
*/
public function testCustomTypes(string $expected, string $type, int|null $length, array $calls): void
{
$this->checkBuildString($expected, $type, $length, $calls);
}

protected function checkBuildString(string $expected, string $type, int|null $length, array $calls): void
{
$db = $this->getConnection();

$schema = $db->getSchema();
$builder = $schema->createColumnSchemaBuilder($type, $length);

foreach ($calls as $call) {
$method = array_shift($call);
call_user_func_array([$builder, $method], $call);
}

$this->assertSame($expected, $builder->__toString());
}
}
27 changes: 27 additions & 0 deletions tests/Provider/AbstractColumnSchemaBuilderProvider.php
@@ -0,0 +1,27 @@
<?php

declare(strict_types=1);

namespace Yiisoft\Db\Tests\Provider;

use Yiisoft\Db\Schema\Schema;
use Yiisoft\Db\Expression\Expression;

abstract class AbstractColumnSchemaBuilderProvider
{
public function types(): array
{
return [
['integer NULL DEFAULT NULL', Schema::TYPE_INTEGER, null, [['unsigned'], ['null']]],
['integer(10)', Schema::TYPE_INTEGER, 10, [['unsigned']]],
['integer(10)', Schema::TYPE_INTEGER, 10, [['comment', 'test']]],
['timestamp() WITH TIME ZONE NOT NULL', 'timestamp() WITH TIME ZONE', null, [['notNull']]],
[
'timestamp() WITH TIME ZONE DEFAULT NOW()',
'timestamp() WITH TIME ZONE',
null,
[['defaultValue', new Expression('NOW()')]],
],
];
}
}
9 changes: 9 additions & 0 deletions tests/Provider/ColumnSchemaBuilderProvider.php
@@ -0,0 +1,9 @@
<?php

declare(strict_types=1);

namespace Yiisoft\Db\Tests\Provider;

final class ColumnSchemaBuilderProvider extends AbstractColumnSchemaBuilderProvider
{
}

0 comments on commit df027fd

Please sign in to comment.