diff --git a/CHANGELOG.md b/CHANGELOG.md index 0b3ee76a6..5622db824 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -39,10 +39,10 @@ - Enh #875: Ignore "Packets out of order..." warnings in `AbstractPdoCommand::internalExecute()` method (@Tigrov) - Enh #877: Separate column type constants (@Tigrov) - New #878: Realize `ColumnBuilder` class (@Tigrov) -- New #878, #900, #914: Realize `ColumnDefinitionParser` class (@Tigrov) +- New #878, #900, #914, #922: Implement `ColumnDefinitionParser` class (@Tigrov) - Enh #881: Refactor `ColumnSchemaInterface` and `AbstractColumnSchema` (@Tigrov) - New #882: Move `ArrayColumnSchema` and `StructuredColumnSchema` classes from `db-pgsql` package (@Tigrov) -- New #883, #901: Add `ColumnDefinitionBuilder` class and `QueryBuilderInterface::buildColumnDefinition()` method (@Tigrov) +- New #883, #901, #922: Add `ColumnDefinitionBuilder` class and `QueryBuilderInterface::buildColumnDefinition()` method (@Tigrov) - Enh #885: Refactor `AbstractDsn` class (@Tigrov) - Chg #889: Update `AbstractDMLQueryBuilder::insertBatch()` method (@Tigrov) - Enh #890: Add properties of `AbstractColumnSchema` class to constructor (@Tigrov) diff --git a/src/Syntax/ColumnDefinitionParser.php b/src/Syntax/ColumnDefinitionParser.php index c6280fa04..c165fe294 100644 --- a/src/Syntax/ColumnDefinitionParser.php +++ b/src/Syntax/ColumnDefinitionParser.php @@ -16,7 +16,7 @@ /** * Parses column definition string. For example, `string(255)` or `int unsigned`. */ -final class ColumnDefinitionParser +class ColumnDefinitionParser { /** * Parses column definition string. @@ -62,7 +62,7 @@ public function parse(string $definition): array /** * @psalm-return array{enumValues: list} */ - private function enumInfo(string $values): array + protected function enumInfo(string $values): array { preg_match_all("/'([^']*)'/", $values, $matches); @@ -80,7 +80,7 @@ private function enumInfo(string $values): array * unsigned?: bool * } */ - private function extraInfo(string $extra): array + protected function extraInfo(string $extra): array { if (empty($extra)) { return []; @@ -137,7 +137,7 @@ private function extraInfo(string $extra): array /** * @psalm-return array{size: int, scale?: int} */ - private function sizeInfo(string $size): array + protected function sizeInfo(string $size): array { $values = explode(',', $size); diff --git a/tests/AbstractColumnDefinitionParserTest.php b/tests/AbstractColumnDefinitionParserTest.php new file mode 100644 index 000000000..f3d5e50d4 --- /dev/null +++ b/tests/AbstractColumnDefinitionParserTest.php @@ -0,0 +1,32 @@ +createColumnDefinitionParser(); + + $this->assertSame($expected, $parser->parse($definition)); + } +} diff --git a/tests/Db/Syntax/ColumnDefinitionParserTest.php b/tests/Db/Syntax/ColumnDefinitionParserTest.php index 543e0391a..46a4deff8 100644 --- a/tests/Db/Syntax/ColumnDefinitionParserTest.php +++ b/tests/Db/Syntax/ColumnDefinitionParserTest.php @@ -4,24 +4,11 @@ namespace Yiisoft\Db\Tests\Db\Syntax; -use PHPUnit\Framework\TestCase; -use Yiisoft\Db\Syntax\ColumnDefinitionParser; -use Yiisoft\Db\Tests\Support\TestTrait; +use Yiisoft\Db\Tests\AbstractColumnDefinitionParserTest; /** * @group db */ -final class ColumnDefinitionParserTest extends TestCase +final class ColumnDefinitionParserTest extends AbstractColumnDefinitionParserTest { - use TestTrait; - - /** - * @dataProvider \Yiisoft\Db\Tests\Provider\ColumnDefinitionParserProvider::parse - */ - public function testParse(string $definition, array $expected): void - { - $parser = new ColumnDefinitionParser(); - - $this->assertSame($expected, $parser->parse($definition)); - } }