Skip to content

Commit

Permalink
Add test for TEXT type with different sizes (#370)
Browse files Browse the repository at this point in the history
  • Loading branch information
Tigrov authored Dec 23, 2024
1 parent 0b031ba commit 4c2344e
Showing 1 changed file with 29 additions and 0 deletions.
29 changes: 29 additions & 0 deletions tests/ColumnSchemaTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

use Throwable;
use Yiisoft\Db\Exception\Exception;
use Yiisoft\Db\Mysql\Column\ColumnBuilder;
use Yiisoft\Db\Mysql\Tests\Support\TestTrait;
use Yiisoft\Db\Query\Query;
use Yiisoft\Db\Schema\Column\BinaryColumnSchema;
Expand Down Expand Up @@ -111,4 +112,32 @@ public function testColumnSchemaInstance(): void
$this->assertInstanceOf(BooleanColumnSchema::class, $tableSchema->getColumn('bool_col'));
$this->assertInstanceOf(JsonColumnSchema::class, $tableSchema->getColumn('json_col'));
}

public function testLongtextType(): void
{
$db = $this->getConnection();
$command = $db->createCommand();

try {
$command->dropTable('text_type')->execute();
} catch (Exception) {
}

$command->createTable(
'text_type',
[
'tinytext' => ColumnBuilder::text(63),
'text' => ColumnBuilder::text(16_383),
'mediumtext' => ColumnBuilder::text(4_194_303),
'longtext' => ColumnBuilder::text(4_294_967_295),
],
)->execute();

$table = $db->getSchema()->getTableSchema('text_type');

$this->assertSame('tinytext', $table->getColumn('tinytext')->getDbType());
$this->assertSame('text', $table->getColumn('text')->getDbType());
$this->assertSame('mediumtext', $table->getColumn('mediumtext')->getDbType());
$this->assertSame('longtext', $table->getColumn('longtext')->getDbType());
}
}

0 comments on commit 4c2344e

Please sign in to comment.