TableGuesserTest.php 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. <?php
  2. namespace Illuminate\Tests\Database;
  3. use Illuminate\Database\Console\Migrations\TableGuesser;
  4. use PHPUnit\Framework\TestCase;
  5. class TableGuesserTest extends TestCase
  6. {
  7. public function testMigrationIsProperlyParsed()
  8. {
  9. [$table, $create] = TableGuesser::guess('create_users_table');
  10. $this->assertSame('users', $table);
  11. $this->assertTrue($create);
  12. [$table, $create] = TableGuesser::guess('add_status_column_to_users_table');
  13. $this->assertSame('users', $table);
  14. $this->assertFalse($create);
  15. [$table, $create] = TableGuesser::guess('change_status_column_in_users_table');
  16. $this->assertSame('users', $table);
  17. $this->assertFalse($create);
  18. [$table, $create] = TableGuesser::guess('drop_status_column_from_users_table');
  19. $this->assertSame('users', $table);
  20. $this->assertFalse($create);
  21. }
  22. public function testMigrationIsProperlyParsedWithoutTableSuffix()
  23. {
  24. [$table, $create] = TableGuesser::guess('create_users');
  25. $this->assertSame('users', $table);
  26. $this->assertTrue($create);
  27. [$table, $create] = TableGuesser::guess('add_status_column_to_users');
  28. $this->assertSame('users', $table);
  29. $this->assertFalse($create);
  30. [$table, $create] = TableGuesser::guess('change_status_column_in_users');
  31. $this->assertSame('users', $table);
  32. $this->assertFalse($create);
  33. [$table, $create] = TableGuesser::guess('drop_status_column_from_users');
  34. $this->assertSame('users', $table);
  35. $this->assertFalse($create);
  36. }
  37. }