diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index f0fb671d..9808b5ba 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -8,14 +8,14 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - php-version: ['8.1', '8.2', '8.3', '8.4'] + php-version: ['8.2', '8.3', '8.4', '8.5'] steps: - name: Install ODBC driver. run: | sudo curl https://packages.microsoft.com/config/ubuntu/$(lsb_release -rs)/prod.list | sudo tee /etc/apt/sources.list.d/mssql-release.list sudo ACCEPT_EULA=Y apt-get install -y msodbcsql18 - name: Checkout - uses: actions/checkout@v2 + uses: actions/checkout@v5 - name: Setup DB services run: | cd tests diff --git a/.scrutinizer.yml b/.scrutinizer.yml index e6297577..1c9bbcbc 100644 --- a/.scrutinizer.yml +++ b/.scrutinizer.yml @@ -14,7 +14,7 @@ build: nodes: analysis: environment: - php: 8.0 + php: 8.2 tests: override: diff --git a/composer.json b/composer.json index d14de0c4..c7a95572 100644 --- a/composer.json +++ b/composer.json @@ -38,8 +38,8 @@ ], "require": { "php": ">=8.1", - "cycle/database": "^2.15", - "cycle/orm": "^2.9.2", + "cycle/database": "^2.16", + "cycle/orm": "^2.15", "cycle/schema-builder": "^2.11.1", "spiral/attributes": "^2.8|^3.0", "spiral/tokenizer": "^2.8|^3.0", diff --git a/tests/Annotated/Fixtures/Fixtures1/Label.php b/tests/Annotated/Fixtures/Fixtures1/Label.php index e3641016..c3cf57aa 100644 --- a/tests/Annotated/Fixtures/Fixtures1/Label.php +++ b/tests/Annotated/Fixtures/Fixtures1/Label.php @@ -36,4 +36,7 @@ class Label #[Column(type: 'tinyInteger')] private int $simple = 1; + + #[Column(type: 'string', charset: 'ascii', collation: 'ascii_bin')] + private string $charsetColumn = ''; } diff --git a/tests/Annotated/Fixtures/Fixtures16/Beaver.php b/tests/Annotated/Fixtures/Fixtures16/Beaver.php index a0493069..ea115ad2 100644 --- a/tests/Annotated/Fixtures/Fixtures16/Beaver.php +++ b/tests/Annotated/Fixtures/Fixtures16/Beaver.php @@ -7,7 +7,9 @@ use Cycle\Annotated\Annotation\Column; use Cycle\Annotated\Annotation\Entity; -/** @Entity */ +/** + * @Entity + */ #[Entity] class Beaver extends Person { diff --git a/tests/Annotated/Fixtures/Fixtures22/Annotated/LocalManager.php b/tests/Annotated/Fixtures/Fixtures22/Annotated/LocalManager.php index b17d69a4..ca376f83 100644 --- a/tests/Annotated/Fixtures/Fixtures22/Annotated/LocalManager.php +++ b/tests/Annotated/Fixtures/Fixtures22/Annotated/LocalManager.php @@ -6,5 +6,7 @@ use Cycle\Annotated\Annotation\Entity; -/** @Entity*/ +/** + * @Entity + */ class LocalManager extends LocalSupplier {} diff --git a/tests/Annotated/Fixtures/Fixtures22/Annotated/LocalSupplier.php b/tests/Annotated/Fixtures/Fixtures22/Annotated/LocalSupplier.php index 7e33599d..dc37d806 100644 --- a/tests/Annotated/Fixtures/Fixtures22/Annotated/LocalSupplier.php +++ b/tests/Annotated/Fixtures/Fixtures22/Annotated/LocalSupplier.php @@ -6,5 +6,7 @@ use Cycle\Annotated\Annotation\Entity; -/** @Entity */ +/** + * @Entity + */ class LocalSupplier extends Supplier {} diff --git a/tests/Annotated/Fixtures/Fixtures22/Annotated/Person.php b/tests/Annotated/Fixtures/Fixtures22/Annotated/Person.php index a1e7239e..c69ff08a 100644 --- a/tests/Annotated/Fixtures/Fixtures22/Annotated/Person.php +++ b/tests/Annotated/Fixtures/Fixtures22/Annotated/Person.php @@ -6,5 +6,7 @@ use Cycle\Annotated\Annotation\Entity; -/** @Entity */ +/** + * @Entity + */ class Person {} diff --git a/tests/Annotated/Fixtures/Fixtures25/WithGeneratedFields.php b/tests/Annotated/Fixtures/Fixtures25/WithGeneratedFields.php index 27e5d985..0d977575 100644 --- a/tests/Annotated/Fixtures/Fixtures25/WithGeneratedFields.php +++ b/tests/Annotated/Fixtures/Fixtures25/WithGeneratedFields.php @@ -24,29 +24,23 @@ class WithGeneratedFields * @Column(type="datetime", name="created_at") * @GeneratedValue(beforeInsert=true) */ - #[ - Column(type: 'datetime', name: 'created_at'), - GeneratedValue(beforeInsert: true) - ] + #[Column(type: 'datetime', name: 'created_at'), + GeneratedValue(beforeInsert: true)] public \DateTimeImmutable $createdAt; /** * @Column(type="datetime", name="created_at_generated_by_database") * @GeneratedValue(onInsert=true) */ - #[ - Column(type: 'datetime', name: 'created_at_generated_by_database'), - GeneratedValue(onInsert: true) - ] + #[Column(type: 'datetime', name: 'created_at_generated_by_database'), + GeneratedValue(onInsert: true)] public \DateTimeImmutable $createdAtGeneratedByDatabase; /** * @Column(type="datetime", name="created_at") * @GeneratedValue(beforeInsert=true, beforeUpdate=true) */ - #[ - Column(type: 'datetime', name: 'updated_at'), - GeneratedValue(beforeInsert: true, beforeUpdate: true) - ] + #[Column(type: 'datetime', name: 'updated_at'), + GeneratedValue(beforeInsert: true, beforeUpdate: true)] public \DateTimeImmutable $updatedAt; } diff --git a/tests/Annotated/Functional/Driver/Common/InheritanceTestCase.php b/tests/Annotated/Functional/Driver/Common/InheritanceTestCase.php index 83d18030..8c257471 100644 --- a/tests/Annotated/Functional/Driver/Common/InheritanceTestCase.php +++ b/tests/Annotated/Functional/Driver/Common/InheritanceTestCase.php @@ -108,7 +108,7 @@ public function testTableInheritance(ReaderInterface $reader): void $this->assertSame('employee', $schema['executive'][SchemaInterface::PARENT]); $this->assertSame('foo_id', $schema['executive'][SchemaInterface::PARENT_KEY]); $this->assertSame('executives', $schema['executive'][SchemaInterface::TABLE]); - $this->assertSame( + $this->assertEquals( ['bonus' => 'bonus', 'foo_id' => 'id', 'hidden' => 'hidden'], $schema['executive'][SchemaInterface::COLUMNS], ); diff --git a/tests/Annotated/Functional/Driver/MySQL/TableTest.php b/tests/Annotated/Functional/Driver/MySQL/TableTest.php index c902d570..6444b69c 100644 --- a/tests/Annotated/Functional/Driver/MySQL/TableTest.php +++ b/tests/Annotated/Functional/Driver/MySQL/TableTest.php @@ -10,6 +10,7 @@ use Cycle\Annotated\MergeColumns; use Cycle\Annotated\Tests\Functional\Driver\Common\TableTestCase; use Cycle\Schema\Generator\RenderTables; +use Cycle\Schema\Generator\SyncTables; use Cycle\Schema\Registry; use PHPUnit\Framework\Attributes\Group; use Spiral\Attributes\AttributeReader; @@ -57,4 +58,20 @@ public function testZerofill(): void $this->assertTrue($this->dbal->database()->table('labels')->getSchema()->column('zerofill')->isUnsigned()); $this->assertFalse($this->dbal->database()->table('labels')->getSchema()->column('simple')->isUnsigned()); } + + public function testColumnCustomAttributes(): void + { + $reader = new AttributeReader(); + $r = new Registry($this->dbal); + (new Entities(new TokenizerEntityLocator($this->locator, $reader), $reader))->run($r); + (new MergeColumns($reader))->run($r); + (new RenderTables())->run($r); + (new SyncTables())->run($r); + + $dbSchema = $this->dbal->database()->table('labels')->getSchema(); + $attributes = $dbSchema->column('charset_column')->getAttributes(); + + $this->assertSame('ascii', $attributes['charset']); + $this->assertSame('ascii_bin', $attributes['collation']); + } } diff --git a/tests/Annotated/Unit/Attribute/ColumnTest.php b/tests/Annotated/Unit/Attribute/ColumnTest.php index 3cd18048..4860e418 100644 --- a/tests/Annotated/Unit/Attribute/ColumnTest.php +++ b/tests/Annotated/Unit/Attribute/ColumnTest.php @@ -50,6 +50,9 @@ class ColumnTest extends TestCase )] private string $column8 = 'a'; + #[Column(type: 'string', length: 255, charset: 'ascii', collation: 'ascii_bin')] + private string $column9; + public function testOneAttribute(): void { $column = $this->getColumn('column1'); @@ -119,6 +122,18 @@ public function testEnumTypeArrayBackedEnum(): void $this->assertArrayNotHasKey('values', $column->getAttributes()); } + public function testCharsetAndCollationAttributes(): void + { + $column = $this->getColumn('column9'); + + $this->assertSame('string', $column->getType()); + $this->assertSame([ + 'length' => 255, + 'charset' => 'ascii', + 'collation' => 'ascii_bin', + ], $column->getAttributes()); + } + private function getColumn(string $field): Column { $ref = new \ReflectionClass(static::class);