Task 5 - pivot with extra fields

This commit is contained in:
PovilasKorop
2021-11-22 08:05:15 +02:00
parent 4ec2014369
commit 4707c593a0
8 changed files with 144 additions and 0 deletions
+20
View File
@@ -5,6 +5,7 @@ namespace Tests\Feature;
use App\Models\Comment;
use App\Models\Role;
use App\Models\Task;
use App\Models\Team;
use App\Models\User;
use Illuminate\Foundation\Testing\RefreshDatabase;
use Illuminate\Support\Facades\DB;
@@ -64,4 +65,23 @@ class RelationshipsTest extends TestCase
$response = $this->get('/roles');
$response->assertStatus(200);
}
// TASK: pivot table with extra fields
public function test_teams_with_users()
{
$user = User::factory()->create();
$team = Team::create(['name' => 'Team 1']);
$createdAt = now()->toDateTimeString();
$position = 'Manager';
DB::table('team_user')->insert([
'team_id' => $team->id,
'user_id' => $user->id,
'position' => $position,
'created_at' => $createdAt
]);
$response = $this->get('/teams');
$response->assertSee($createdAt);
$response->assertSee($position);
}
}