jonnybarnes.uk/tests/Feature/ContactsTest.php
Jonny Barnes 1dfa17abca
Some checks failed
PHP Unit / PHPUnit test suite (pull_request) Has been cancelled
Laravel Pint / Laravel Pint (pull_request) Has been cancelled
Update Laravel to v12
2025-04-01 21:10:30 +01:00

59 lines
1.5 KiB
PHP

<?php
declare(strict_types=1);
namespace Tests\Feature;
use App\Models\Contact;
use Illuminate\Foundation\Testing\RefreshDatabase;
use PHPUnit\Framework\Attributes\Test;
use Tests\TestCase;
class ContactsTest extends TestCase
{
use RefreshDatabase;
/**
* Check the `/contacts` page gives a good response.
*/
#[Test]
public function contactsPageLoadsWithoutError(): void
{
$response = $this->get('/contacts');
$response->assertStatus(200);
}
/**
* Test an individual contact page with default profile image.
*/
#[Test]
public function contactPageShouldFallbackToDefaultProfilePic(): void
{
Contact::factory()->create([
'nick' => 'tantek',
]);
$response = $this->get('/contacts/tantek');
$response->assertViewHas('image', '/assets/profile-images/default-image');
}
/**
* Test an individual contact page with a specific profile image.
*/
#[Test]
public function contactPageShouldUseSpecificProfilePicIfPresent(): void
{
Contact::factory()->create([
'nick' => 'aaron',
'homepage' => 'https://aaronparecki.com',
]);
$response = $this->get('/contacts/aaron');
$response->assertViewHas('image', '/assets/profile-images/aaronparecki.com/image');
}
#[Test]
public function unknownContactReturnsNotFoundResponse(): void
{
$response = $this->get('/contacts/unknown');
$response->assertNotFound();
}
}