1
0
Fork 0

fixed laravel test may last

main
A1Gard 1 year ago
parent e4c9ef8aaf
commit 8a7124b916

@ -34,4 +34,7 @@ jobs:
DB_DATABASE: database/database.sqlite
run: PIC_SEED=0 php artisan migrate --seed
- name: Execute tests (Unit and Feature tests) via PHPUnit
env:
DB_CONNECTION: sqlite
DB_DATABASE: database/database.sqlite
run: php artisan test

@ -379,23 +379,18 @@ class AdminWebPagesTest extends TestCase
private function getValidUser(){
// if (User::where('email','=','admin@example.com')->count() == 0){
//
// if (Role::where('name','=','super-admin')->count() == 0){
// $role = Role::create(['name' => 'super-admin']);
// }else{
// $role = Role::where('name','super-admin')->first();
// }
//
// $user = User::factory()->count(1)->create(['email' => 'admin@example.com']);
// $user->assignRole($role);
// }else{
// $user = User::where('email','admin@example.com')->first();
// }
$role = Role::where('name','super-admin')->first();
$user = User::where('id','>',0)->first();
if (! $user->hasRole('super-admin')){
if (User::where('email','admin@example.com')->count() == 0){
if (Role::where('name','super-admin')->count() == 0){
$role = Role::create(['name' => 'super-admin']);
}else{
$role = Role::where('name','super-admin')->first();
}
$user = User::factory()->count(1)->create(['email' => 'admin@example.com']);
$user->assignRole($role);
}else{
$user = User::where('email','admin@example.com')->first();
}
return $user;
}

Loading…
Cancel
Save