mirror of
https://github.com/10h30/Test-Laravel-Migrations.git
synced 2026-06-05 15:07:54 +09:00
Task 2 - column after another column
This commit is contained in:
@@ -2,6 +2,7 @@
|
||||
|
||||
namespace Tests\Feature;
|
||||
|
||||
use App\Models\User;
|
||||
use Illuminate\Support\Facades\Artisan;
|
||||
use Tests\TestCase;
|
||||
|
||||
@@ -20,4 +21,22 @@ class MigrationsTest extends TestCase
|
||||
|
||||
Artisan::call('migrate:fresh', ['--path' => '/database/migrations/task1']);
|
||||
}
|
||||
|
||||
public function test_column_added_to_the_table()
|
||||
{
|
||||
Artisan::call('migrate:fresh', ['--path' => '/database/migrations/task2']);
|
||||
|
||||
User::factory()->create(['surname' => 'Testing']);
|
||||
$this->assertDatabaseHas(User::class, ['surname' => 'Testing']);
|
||||
|
||||
$user = User::first();
|
||||
$fieldNumber = 0;
|
||||
foreach ($user->getAttributes() as $key => $value) {
|
||||
$fieldNumber++;
|
||||
if ($key == "surname") break;
|
||||
}
|
||||
|
||||
$this->assertEquals(3, $fieldNumber);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user