jonnybarnes.uk/tests/Feature/ContactsTest.php

60 lines
1.5 KiB
PHP
Raw Normal View History

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