1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68
|
<?php
namespace Illuminate\Tests\Integration\Database\MariaDb;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
use PHPUnit\Framework\Attributes\RequiresOperatingSystem;
use PHPUnit\Framework\Attributes\RequiresPhpExtension;
#[RequiresOperatingSystem('Linux|Darwin')]
#[RequiresPhpExtension('pdo_mysql')]
class DatabaseMariaDbSchemaBuilderAlterTableWithEnumTest extends MariaDbTestCase
{
protected function afterRefreshingDatabase()
{
Schema::create('users', function (Blueprint $table) {
$table->integer('id');
$table->string('name');
$table->string('age');
$table->enum('color', ['red', 'blue']);
});
}
protected function destroyDatabaseMigrations()
{
Schema::drop('users');
}
public function testRenameColumnOnTableWithEnum()
{
Schema::table('users', function (Blueprint $table) {
$table->renameColumn('name', 'username');
});
$this->assertTrue(Schema::hasColumn('users', 'username'));
}
public function testChangeColumnOnTableWithEnum()
{
Schema::table('users', function (Blueprint $table) {
$table->unsignedInteger('age')->change();
});
$this->assertSame('int', Schema::getColumnType('users', 'age'));
}
public function testGetTablesAndColumnListing()
{
$tables = Schema::getTables();
$this->assertCount(2, $tables);
$this->assertEquals(['migrations', 'users'], array_column($tables, 'name'));
$columns = Schema::getColumnListing('users');
foreach (['id', 'name', 'age', 'color'] as $column) {
$this->assertContains($column, $columns);
}
Schema::create('posts', function (Blueprint $table) {
$table->integer('id');
$table->string('title');
});
$tables = Schema::getTables();
$this->assertCount(3, $tables);
Schema::drop('posts');
}
}
|