Task 2 - column after another column

This commit is contained in:
PovilasKorop
2021-11-09 10:08:56 +02:00
parent da6dd14446
commit 40044cbfa4
4 changed files with 97 additions and 0 deletions
+19
View File
@@ -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);
}
}