1
0
Fork 0

fixed laravel test

main
A1Gard 1 year ago
parent 206daee778
commit f642fb29c2

@ -32,6 +32,6 @@ jobs:
env: env:
DB_CONNECTION: sqlite DB_CONNECTION: sqlite
DB_DATABASE: database/database.sqlite DB_DATABASE: database/database.sqlite
run: 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: vendor/bin/phpunit

@ -87,8 +87,10 @@ 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']]);
$num = rand(1, 6); if (env('PIC_SEED') != 0){
$p->addMedia(__DIR__ . "/img/$num/$num.jpg")->preservingOriginal()->toMediaCollection(); $num = rand(1, 6);
$p->addMedia(__DIR__ . "/img/$num/$num.jpg")->preservingOriginal()->toMediaCollection();
}
$p->save(); $p->save();
} }
} }

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

Loading…
Cancel
Save