ldc-cocotte/tests/Pest.php

60 lines
1.5 KiB
PHP

<?php
declare(strict_types=1);
use Carbon\Carbon;
use Carbon\CarbonImmutable;
use DG\BypassFinals;
use Illuminate\Foundation\Testing\RefreshDatabase;
use Illuminate\Support\Facades\Date;
use Illuminate\Support\Facades\Http;
use PHPUnit\Framework\TestCase as BasePHPUnitTestCase;
use Tests\TestCase as LaravelTestCase;
BypassFinals::enable(bypassReadOnly: false, bypassFinal: true);
BypassFinals::denyPaths([
'*/app/Cqs/Actions/*',
'*/app/Dto/*',
'*/app/Cqs/Queries/*',
'*/domain/Models/*',
'*/shared/DDD/*',
]);
pest()
->extend(LaravelTestCase::class)
->use(RefreshDatabase::class)
->beforeEach(function (): void {
Http::preventStrayRequests();
})
->afterEach(function (): void {
Carbon::setTestNow();
CarbonImmutable::setTestNow();
Date::setTestNow();
})
->in('Feature');
pest()
->extend(LaravelTestCase::class)
->use(RefreshDatabase::class)
->afterEach(function (): void {
Carbon::setTestNow();
CarbonImmutable::setTestNow();
Date::setTestNow();
})
->in('Integration/WithApp');
pest()
->extend(BasePHPUnitTestCase::class)
->afterEach(function (): void {
Carbon::setTestNow();
CarbonImmutable::setTestNow();
})
->in('Integration/Standalones');
pest()
->extend(BasePHPUnitTestCase::class)
->afterEach(function (): void {
Carbon::setTestNow();
CarbonImmutable::setTestNow();
})
->in('Unit');