Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion .scrutinizer.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ build:
nodes:
analysis:
environment:
php: 8.0
php: 8.2

tests:
override:
Expand Down
4 changes: 2 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
3 changes: 3 additions & 0 deletions tests/Annotated/Fixtures/Fixtures1/Label.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,4 +36,7 @@ class Label

#[Column(type: 'tinyInteger')]
private int $simple = 1;

#[Column(type: 'string', charset: 'ascii', collation: 'ascii_bin')]
private string $charsetColumn = '';
}
4 changes: 3 additions & 1 deletion tests/Annotated/Fixtures/Fixtures16/Beaver.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@
use Cycle\Annotated\Annotation\Column;
use Cycle\Annotated\Annotation\Entity;

/** @Entity */
/**
* @Entity
*/
#[Entity]
class Beaver extends Person
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,7 @@

use Cycle\Annotated\Annotation\Entity;

/** @Entity*/
/**
* @Entity
*/
class LocalManager extends LocalSupplier {}
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,7 @@

use Cycle\Annotated\Annotation\Entity;

/** @Entity */
/**
* @Entity
*/
class LocalSupplier extends Supplier {}
4 changes: 3 additions & 1 deletion tests/Annotated/Fixtures/Fixtures22/Annotated/Person.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,7 @@

use Cycle\Annotated\Annotation\Entity;

/** @Entity */
/**
* @Entity
*/
class Person {}
18 changes: 6 additions & 12 deletions tests/Annotated/Fixtures/Fixtures25/WithGeneratedFields.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Original file line number Diff line number Diff line change
Expand Up @@ -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],
);
Expand Down
17 changes: 17 additions & 0 deletions tests/Annotated/Functional/Driver/MySQL/TableTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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']);
}
}
15 changes: 15 additions & 0 deletions tests/Annotated/Unit/Attribute/ColumnTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down Expand Up @@ -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);
Expand Down
Loading