adrema/tests/Feature/Form/FormTestCase.php

37 lines
902 B
PHP
Raw Normal View History

2024-02-19 01:07:54 +01:00
<?php
namespace Tests\Feature\Form;
use App\Form\FormSettings;
use Illuminate\Support\Facades\Http;
use Illuminate\Support\Facades\Storage;
2024-02-19 01:07:54 +01:00
use Tests\TestCase;
2024-02-20 02:02:42 +01:00
use Tests\Lib\CreatesFormFields;
2024-02-19 01:07:54 +01:00
class FormTestCase extends TestCase
{
2024-02-20 02:02:42 +01:00
use CreatesFormFields;
private string $clearCacheUrl = 'http://event.com/clear-cache';
public function setUp(): void
{
parent::setUp();
app(FormSettings::class)->fill(['clearCacheUrl' => 'http://event.com/clear-cache'])->save();
Http::fake(function ($request) {
if ($request->url() === $this->clearCacheUrl) {
return Http::response('', 200);
}
});
Storage::fake('temp');
}
protected function assertFrontendCacheCleared(): void
{
Http::assertSent(fn ($request) => $request->url() === $this->clearCacheUrl && $request->method() === 'GET');
}
2024-02-19 01:07:54 +01:00
}