Taks 4 - belongsToMany pivot

This commit is contained in:
PovilasKorop
2021-11-22 07:47:31 +02:00
parent 0fbdf0c99a
commit 4ec2014369
8 changed files with 128 additions and 0 deletions
+16
View File
@@ -3,9 +3,11 @@
namespace Tests\Feature;
use App\Models\Comment;
use App\Models\Role;
use App\Models\Task;
use App\Models\User;
use Illuminate\Foundation\Testing\RefreshDatabase;
use Illuminate\Support\Facades\DB;
use Tests\TestCase;
class RelationshipsTest extends TestCase
@@ -48,4 +50,18 @@ class RelationshipsTest extends TestCase
$response = $this->get('/users/' . $user->id);
$response->assertStatus(200);
}
// TASK: pivot table name in the list
public function test_show_roles_with_users()
{
$user = User::factory()->create();
$role = Role::create(['name' => 'Admin']);
DB::table('users_roles')->insert([
'role_id' => $role->id,
'user_id' => $user->id
]);
$response = $this->get('/roles');
$response->assertStatus(200);
}
}