95 lines
3.2 KiB
PHP
95 lines
3.2 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
use App\Models\Page;
|
|
use App\Models\Product;
|
|
use App\Models\Range;
|
|
use App\Models\Slide;
|
|
use Database\Seeders\ContentSeeder;
|
|
use Domain\Enums\ProductBrand;
|
|
use Domain\Enums\SellUnit;
|
|
use Domain\Enums\TaxRate;
|
|
use Domain\Enums\Units\InvoicingUnit;
|
|
use Illuminate\Support\Carbon;
|
|
use Illuminate\Support\Facades\View;
|
|
use Money\Money;
|
|
use Ramsey\Uuid\Uuid;
|
|
|
|
describe('HomeController', function () {
|
|
it('can access home page', function () {
|
|
/** @var \Tests\TestCase $this */
|
|
// GIVEN
|
|
$this->seed(ContentSeeder::class);
|
|
View::share('PageList', Page::getCached()
|
|
->mapWithKeys(fn ($page) => [
|
|
$page->slug->value() => $page,
|
|
]));
|
|
|
|
// WHEN
|
|
$response = $this->get('/');
|
|
|
|
// THEN
|
|
$response->assertOk();
|
|
});
|
|
|
|
it('displays star products, slides and ranges', function () {
|
|
/** @var \Tests\TestCase $this */
|
|
// GIVEN
|
|
$this->seed(ContentSeeder::class);
|
|
View::share('PageList', Page::getCached()
|
|
->mapWithKeys(fn ($page) => [
|
|
$page->slug->value() => $page,
|
|
]));
|
|
|
|
$range = new Range();
|
|
$range->name = 'Boucherie';
|
|
$range->slug = 'boucherie';
|
|
$range->picture = 'ranges/boucherie.jpg';
|
|
$range->picture_alt = 'Boucherie';
|
|
$range->picture_title = 'Boucherie';
|
|
$range->status = true;
|
|
$range->order = 1;
|
|
$range->save();
|
|
|
|
$slide = new Slide();
|
|
$slide->title = 'Super Promo';
|
|
$slide->status = true;
|
|
$slide->order = 1;
|
|
$slide->connected = false;
|
|
$slide->link = 'https://example.com';
|
|
$slide->date_start = Carbon::yesterday();
|
|
$slide->date_end = Carbon::tomorrow();
|
|
$slide->save();
|
|
|
|
$product = new Product();
|
|
$product->id = (string) Uuid::uuid7();
|
|
$product->name = 'Poulet Fermier';
|
|
$product->brand = ProductBrand::loue;
|
|
$product->slug = 'poulet-fermier';
|
|
$product->description = 'Délicieux poulet fermier';
|
|
$product->picture_alt = 'Poulet Fermier';
|
|
$product->picture_title = 'Poulet Fermier';
|
|
$product->picture_large_alt = 'Poulet Fermier';
|
|
$product->picture_large_title = 'Poulet Fermier';
|
|
$product->price = Money::EUR(1500);
|
|
$product->invoicing_unit = InvoicingUnit::KGM;
|
|
$product->sell_unit = SellUnit::KGM;
|
|
$product->tax_rate = TaxRate::TVA_5_5;
|
|
$product->stock = 10;
|
|
$product->range_id = $range->id;
|
|
$product->order = 1;
|
|
$product->star = true;
|
|
$product->status = true;
|
|
$product->save();
|
|
|
|
// WHEN
|
|
$response = $this->get('/');
|
|
|
|
// THEN
|
|
$response->assertOk();
|
|
$response->assertSee('Poulet Fermier');
|
|
$response->assertSee('Super Promo');
|
|
$response->assertSee('Boucherie');
|
|
});
|
|
});
|