<?php
declare(strict_types=1);
namespace Tests\Feature;
use App\Models\Article;
use Illuminate\Foundation\Testing\RefreshDatabase;
use Jonnybarnes\IndieWeb\Numbers;
use PHPUnit\Framework\Attributes\Test;
use Tests\TestCase;
class ArticlesTest extends TestCase
{
use RefreshDatabase;
#[Test]
public function articles_page_loads(): void
$response = $this->get('/blog');
$response->assertViewIs('articles.index');
}
public function single_article_page_loads()
$article = Article::factory()->create();
$response = $this->get($article->link);
$response->assertViewIs('articles.show');
public function wrong_date_in_url_redirects_to_correct_date()
$response = $this->get('/blog/1900/01/' . $article->titleurl);
$response->assertRedirect('/blog/' . date('Y') . '/' . date('m') . '/' . $article->titleurl);
public function old_urls_with_id_are_redirected()
$num60Id = resolve(Numbers::class)->numto60($article->id);
$response = $this->get('/blog/s/' . $num60Id);
$response->assertRedirect($article->link);
public function unknown_slug_gets_not_found_response()
$response = $this->get('/blog/' . date('Y') . '/' . date('m') . '/unknown-slug');
$response->assertNotFound();
public function unknown_article_id_gets_not_found_response()
$response = $this->get('/blog/s/22');
public function some_urls_do_not_parse_correctly(): void
$response = $this->get('/blog/feed.js');