fixed laravel test may last

pull/22/head
A1Gard 1 year ago
parent e4c9ef8aaf
commit 8a7124b916

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

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

Loading…
Cancel
Save