1
0
Fork 0

fixed laravel test

main
A1Gard 1 year ago
parent f642fb29c2
commit e4c9ef8aaf

@ -34,4 +34,4 @@ 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
run: vendor/bin/phpunit run: php artisan test

@ -87,7 +87,7 @@ class PostSeeder extends Seeder
$p->hash = date('Ym') . str_pad(dechex(crc32($p->slug)), 8, '0', STR_PAD_LEFT); $p->hash = date('Ym') . str_pad(dechex(crc32($p->slug)), 8, '0', STR_PAD_LEFT);
$p->save(); $p->save();
$p->categories()->sync([$item['category_id']]); $p->categories()->sync([$item['category_id']]);
if (env('PIC_SEED') != 0){ if (env('PIC_SEED') !== '0'){
$num = rand(1, 6); $num = rand(1, 6);
$p->addMedia(__DIR__ . "/img/$num/$num.jpg")->preservingOriginal()->toMediaCollection(); $p->addMedia(__DIR__ . "/img/$num/$num.jpg")->preservingOriginal()->toMediaCollection();
} }

@ -74,7 +74,7 @@ class ProductSeeder extends Seeder
$plan = 6; $plan = 6;
} }
$product->categories()->sync($plans[$plan]['cats']); $product->categories()->sync($plans[$plan]['cats']);
if (env('PIC_SEED') != 0){ if (env('PIC_SEED') !== '0'){
$num = rand(1, $plans[$plan]['max']); $num = rand(1, $plans[$plan]['max']);
$product->addMedia($plans[$plan]['dir'] . "$num.jpg")->preservingOriginal()->toMediaCollection(); $product->addMedia($plans[$plan]['dir'] . "$num.jpg")->preservingOriginal()->toMediaCollection();
$num = rand(1, $plans[$plan]['max']); $num = rand(1, $plans[$plan]['max']);

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

Loading…
Cancel
Save