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]
2025-04-06 17:25:06 +01:00
public function contacts_page_loads_without_error(): 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]
2025-04-06 17:25:06 +01:00
public function contact_page_should_fallback_to_default_profile_pic(): 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]
2025-04-06 17:25:06 +01:00
public function contact_page_should_use_specific_profile_pic_if_present(): 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]
2025-04-06 17:25:06 +01:00
public function unknown_contact_returns_not_found_response(): void
{
$response = $this->get('/contacts/unknown');
$response->assertNotFound();
}
2017-02-18 14:16:22 +00:00
}