Skip to content

Commit 02808e1

Browse files
authored
Merge pull request #229: Added tests
2 parents 7ad2df1 + 0e77852 commit 02808e1

File tree

2 files changed

+50
-11
lines changed

2 files changed

+50
-11
lines changed

src/Driver/MySQL/Schema/MySQLColumn.php

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -23,17 +23,17 @@
2323
* Attention! You can use only one timestamp or datetime with DATETIME_NOW setting! Thought, it will
2424
* work on multiple fields with MySQL 5.6.6+ version.
2525
*
26-
* @method $this|AbstractColumn primary(int $size, bool $unsigned = false, $zerofill = false)
27-
* @method $this|AbstractColumn smallPrimary(int $size, bool $unsigned = false, $zerofill = false)
28-
* @method $this|AbstractColumn bigPrimary(int $size, bool $unsigned = false, $zerofill = false)
29-
* @method $this|AbstractColumn integer(int $size, bool $unsigned = false, $zerofill = false)
30-
* @method $this|AbstractColumn tinyInteger(int $size, bool $unsigned = false, $zerofill = false)
31-
* @method $this|AbstractColumn smallInteger(int $size, bool $unsigned = false, $zerofill = false)
32-
* @method $this|AbstractColumn bigInteger(int $size, bool $unsigned = false, $zerofill = false)
33-
* @method $this|AbstractColumn unsigned(bool $value)
34-
* @method $this|AbstractColumn zerofill(bool $value)
35-
* @method $this|AbstractColumn comment(string $value)
36-
* @method $this|AbstractColumn after(string $column)
26+
* @method $this primary(int $size, bool $unsigned = false, $zerofill = false)
27+
* @method $this smallPrimary(int $size, bool $unsigned = false, $zerofill = false)
28+
* @method $this bigPrimary(int $size, bool $unsigned = false, $zerofill = false)
29+
* @method $this integer(int $size, bool $unsigned = false, $zerofill = false)
30+
* @method $this tinyInteger(int $size, bool $unsigned = false, $zerofill = false)
31+
* @method $this smallInteger(int $size, bool $unsigned = false, $zerofill = false)
32+
* @method $this bigInteger(int $size, bool $unsigned = false, $zerofill = false)
33+
* @method $this unsigned(bool $value)
34+
* @method $this zerofill(bool $value)
35+
* @method $this comment(string $value)
36+
* @method $this after(string $column)
3737
*/
3838
class MySQLColumn extends AbstractColumn
3939
{

tests/Database/Functional/Driver/MySQL/Connection/CustomOptionsTest.php

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,45 @@ public function testNamedArgumentsToConfigureInteger(): void
9494
$this->assertTrue($foo->isNullable());
9595
}
9696

97+
public function testNamedArgumentsToConfigureBoolean(): void
98+
{
99+
$schema = $this->schema('foo');
100+
$schema->boolean('bar')->defaultValue(false)->nullable(false)->unsigned(true)->size(1)->zerofill(true);
101+
$schema->boolean('baz', nullable: true, unsigned: true, size: 1, zerofill: true);
102+
$schema->boolean('qux', nullable: false, unsigned: true);
103+
$schema->boolean('quux', nullable: false);
104+
$schema->save();
105+
106+
$this->assertInstanceOf(MySQLColumn::class, $bar = $this->fetchSchema($schema)->column('bar'));
107+
$this->assertInstanceOf(MySQLColumn::class, $baz = $this->fetchSchema($schema)->column('baz'));
108+
$this->assertInstanceOf(MySQLColumn::class, $qux = $this->fetchSchema($schema)->column('qux'));
109+
$this->assertInstanceOf(MySQLColumn::class, $quux = $this->fetchSchema($schema)->column('quux'));
110+
111+
self::assertInstanceOf(MySQLColumn::class, $bar);
112+
self::assertInstanceOf(MySQLColumn::class, $baz);
113+
self::assertInstanceOf(MySQLColumn::class, $qux);
114+
self::assertInstanceOf(MySQLColumn::class, $quux);
115+
$this->assertTrue($bar->isZerofill());
116+
$this->assertTrue($baz->isZerofill());
117+
$this->assertFalse($qux->isZerofill());
118+
$this->assertFalse($quux->isZerofill());
119+
$this->assertTrue($bar->isUnsigned());
120+
$this->assertTrue($baz->isUnsigned());
121+
$this->assertTrue($qux->isUnsigned());
122+
$this->assertFalse($quux->isUnsigned());
123+
124+
$this->assertSame(1, $bar->getSize());
125+
$this->assertSame(1, $baz->getSize());
126+
// In case of zerofill=false and unsigned=true the size value might be resolved to 4
127+
$this->assertTrue(\in_array($qux->getSize(), [1, 4], true));
128+
$this->assertSame(1, $quux->getSize());
129+
130+
$this->assertFalse($bar->isNullable());
131+
$this->assertTrue($baz->isNullable());
132+
$this->assertFalse($qux->isNullable());
133+
$this->assertFalse($quux->isNullable());
134+
}
135+
97136
/**
98137
* The `text` have no the `unsigned` attribute. It will be stored in the additional attributes.
99138
*/

0 commit comments

Comments
 (0)