Update tests
This commit is contained in:
@@ -0,0 +1,36 @@
|
||||
<?php
|
||||
|
||||
namespace Tests\Feature;
|
||||
|
||||
use Tests\RefreshDatabase;
|
||||
use Tests\Support\AltchaPayload;
|
||||
use Tests\TestCase;
|
||||
|
||||
class ContactFormTest extends TestCase
|
||||
{
|
||||
use RefreshDatabase;
|
||||
|
||||
public function test_contact_requires_fields(): void
|
||||
{
|
||||
$this->post('/contact', [])
|
||||
->assertSessionHasErrors(['name', 'email', 'message', 'subject', 'altcha']);
|
||||
}
|
||||
|
||||
public function test_valid_contact_submission_creates_row(): void
|
||||
{
|
||||
$this->post('/contact', [
|
||||
'name' => 'Jane Doe',
|
||||
'email' => 'jane@example.com',
|
||||
'subject' => 'Bug report',
|
||||
'message' => 'The search page looks broken on mobile.',
|
||||
'altcha' => AltchaPayload::valid(),
|
||||
])->assertRedirect();
|
||||
|
||||
$this->assertDatabaseHas('contacts', [
|
||||
'name' => 'Jane Doe',
|
||||
'email' => 'jane@example.com',
|
||||
'subject' => 'Bug report',
|
||||
'message' => 'The search page looks broken on mobile.',
|
||||
]);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user