Skip to content

Commit e06567f

Browse files
committed
Min PHP version to >=8.1; add MySQL tests with charset and collation
1 parent 7564927 commit e06567f

7 files changed

Lines changed: 41 additions & 6 deletions

File tree

.github/workflows/main.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,14 @@ jobs:
88
runs-on: ubuntu-latest
99
strategy:
1010
matrix:
11-
php-version: ['8.1', '8.2', '8.3', '8.4']
11+
php-version: ['8.2', '8.3', '8.4', '8.5']
1212
steps:
1313
- name: Install ODBC driver.
1414
run: |
1515
sudo curl https://packages.microsoft.com/config/ubuntu/$(lsb_release -rs)/prod.list | sudo tee /etc/apt/sources.list.d/mssql-release.list
1616
sudo ACCEPT_EULA=Y apt-get install -y msodbcsql18
1717
- name: Checkout
18-
uses: actions/checkout@v2
18+
uses: actions/checkout@v5
1919
- name: Setup DB services
2020
run: |
2121
cd tests

.scrutinizer.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ build:
1414
nodes:
1515
analysis:
1616
environment:
17-
php: 8.0
17+
php: 8.2
1818

1919
tests:
2020
override:

composer.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,8 @@
3838
],
3939
"require": {
4040
"php": ">=8.1",
41-
"cycle/database": "^2.15",
42-
"cycle/orm": "^2.9.2",
41+
"cycle/database": "^2.16",
42+
"cycle/orm": "^2.15",
4343
"cycle/schema-builder": "^2.11.1",
4444
"spiral/attributes": "^2.8|^3.0",
4545
"spiral/tokenizer": "^2.8|^3.0",

tests/Annotated/Fixtures/Fixtures1/Label.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,4 +36,7 @@ class Label
3636

3737
#[Column(type: 'tinyInteger')]
3838
private int $simple = 1;
39+
40+
#[Column(type: 'string', charset: 'ascii', collation: 'ascii_bin')]
41+
private string $charsetColumn = '';
3942
}

tests/Annotated/Functional/Driver/Common/InheritanceTestCase.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ public function testTableInheritance(ReaderInterface $reader): void
109109
$this->assertSame('foo_id', $schema['executive'][SchemaInterface::PARENT_KEY]);
110110
$this->assertSame('executives', $schema['executive'][SchemaInterface::TABLE]);
111111
$this->assertSame(
112-
['bonus' => 'bonus', 'foo_id' => 'id', 'hidden' => 'hidden'],
112+
['bonus' => 'bonus', 'hidden' => 'hidden', 'foo_id' => 'id'],
113113
$schema['executive'][SchemaInterface::COLUMNS],
114114
);
115115

tests/Annotated/Functional/Driver/MySQL/TableTest.php

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
use Cycle\Annotated\MergeColumns;
1111
use Cycle\Annotated\Tests\Functional\Driver\Common\TableTestCase;
1212
use Cycle\Schema\Generator\RenderTables;
13+
use Cycle\Schema\Generator\SyncTables;
1314
use Cycle\Schema\Registry;
1415
use PHPUnit\Framework\Attributes\Group;
1516
use Spiral\Attributes\AttributeReader;
@@ -57,4 +58,20 @@ public function testZerofill(): void
5758
$this->assertTrue($this->dbal->database()->table('labels')->getSchema()->column('zerofill')->isUnsigned());
5859
$this->assertFalse($this->dbal->database()->table('labels')->getSchema()->column('simple')->isUnsigned());
5960
}
61+
62+
public function testColumnCustomAttributes(): void
63+
{
64+
$reader = new AttributeReader();
65+
$r = new Registry($this->dbal);
66+
(new Entities(new TokenizerEntityLocator($this->locator, $reader), $reader))->run($r);
67+
(new MergeColumns($reader))->run($r);
68+
(new RenderTables())->run($r);
69+
(new SyncTables())->run($r);
70+
71+
$dbSchema = $this->dbal->database()->table('labels')->getSchema();
72+
$attributes = $dbSchema->column('charset_column')->getAttributes();
73+
74+
$this->assertSame('ascii', $attributes['charset']);
75+
$this->assertSame('ascii_bin', $attributes['collation']);
76+
}
6077
}

tests/Annotated/Unit/Attribute/ColumnTest.php

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,9 @@ class ColumnTest extends TestCase
5050
)]
5151
private string $column8 = 'a';
5252

53+
#[Column(type: 'string', length: 255, charset: 'ascii', collation: 'ascii_bin')]
54+
private string $column9;
55+
5356
public function testOneAttribute(): void
5457
{
5558
$column = $this->getColumn('column1');
@@ -119,6 +122,18 @@ public function testEnumTypeArrayBackedEnum(): void
119122
$this->assertArrayNotHasKey('values', $column->getAttributes());
120123
}
121124

125+
public function testCharsetAndCollationAttributes(): void
126+
{
127+
$column = $this->getColumn('column9');
128+
129+
$this->assertSame('string', $column->getType());
130+
$this->assertSame([
131+
'length' => 255,
132+
'charset' => 'ascii',
133+
'collation' => 'ascii_bin',
134+
], $column->getAttributes());
135+
}
136+
122137
private function getColumn(string $field): Column
123138
{
124139
$ref = new \ReflectionClass(static::class);

0 commit comments

Comments
 (0)