Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Remove src\TestSupport\TestColumnSchemaBuilderTrait from yiisoft\db. (#…
…408) * Remove src\TestSupport\TestColumnSchemaBuilderTrait from yiisoft\db.
- Loading branch information
1 parent
27d6e00
commit df027fd
Showing
4 changed files
with
75 additions
and
53 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
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,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()); | ||
} | ||
} |
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,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()')]], | ||
], | ||
]; | ||
} | ||
} |
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,9 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Yiisoft\Db\Tests\Provider; | ||
|
||
final class ColumnSchemaBuilderProvider extends AbstractColumnSchemaBuilderProvider | ||
{ | ||
} |