You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
28 lines
869 B
28 lines
869 B
<?php
|
|
|
|
use App\Domains\Identity\Models\Role;
|
|
use App\Domains\Identity\Models\User;
|
|
use App\Domains\Identity\Queries\Dashboard\GetRoleDistributions;
|
|
use Illuminate\Foundation\Testing\RefreshDatabase;
|
|
|
|
uses(Tests\TestCase::class, RefreshDatabase::class);
|
|
|
|
test('it can fetch role distributions', function () {
|
|
$admin = Role::create(['name' => 'admin', 'guard_name' => 'web']);
|
|
$editor = Role::create(['name' => 'editor', 'guard_name' => 'web']);
|
|
|
|
$user1 = User::factory()->create();
|
|
$user1->assignRole($admin);
|
|
|
|
$user2 = User::factory()->create();
|
|
$user2->assignRole($editor);
|
|
|
|
$user3 = User::factory()->create();
|
|
$user3->assignRole($editor);
|
|
|
|
$query = new GetRoleDistributions();
|
|
$results = $query->fetch();
|
|
|
|
expect($results['categories'])->toContain('admin', 'editor')
|
|
->and($results['series'])->toContain(1, 2);
|
|
});
|
|
|