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
|
<?php
namespace Illuminate\Tests\Database;
use Illuminate\Database\Console\Migrations\TableGuesser;
use PHPUnit\Framework\TestCase;
class TableGuesserTest extends TestCase
{
public function testMigrationIsProperlyParsed()
{
[$table, $create] = TableGuesser::guess('create_users_table');
$this->assertSame('users', $table);
$this->assertTrue($create);
[$table, $create] = TableGuesser::guess('add_status_column_to_users_table');
$this->assertSame('users', $table);
$this->assertFalse($create);
[$table, $create] = TableGuesser::guess('add_is_sent_to_crm_column_to_users_table');
$this->assertSame('users', $table);
$this->assertFalse($create);
[$table, $create] = TableGuesser::guess('change_status_column_in_users_table');
$this->assertSame('users', $table);
$this->assertFalse($create);
[$table, $create] = TableGuesser::guess('drop_status_column_from_users_table');
$this->assertSame('users', $table);
$this->assertFalse($create);
}
public function testMigrationIsProperlyParsedWithoutTableSuffix()
{
[$table, $create] = TableGuesser::guess('create_users');
$this->assertSame('users', $table);
$this->assertTrue($create);
[$table, $create] = TableGuesser::guess('add_status_column_to_users');
$this->assertSame('users', $table);
$this->assertFalse($create);
[$table, $create] = TableGuesser::guess('add_is_sent_to_crm_column_column_to_users');
$this->assertSame('users', $table);
$this->assertFalse($create);
[$table, $create] = TableGuesser::guess('change_status_column_in_users');
$this->assertSame('users', $table);
$this->assertFalse($create);
[$table, $create] = TableGuesser::guess('drop_status_column_from_users');
$this->assertSame('users', $table);
$this->assertFalse($create);
}
}
|