trove/tests/Feature/Admin/InstancesAdminPageTest.php

57 lines
1.8 KiB
PHP
Raw Normal View History

<?php
declare(strict_types=1);
namespace Tests\Feature\Admin;
use Illuminate\Foundation\Testing\RefreshDatabase;
use Lvl0\FediDiscover\Config\InstanceType;
use Lvl0\FediDiscover\Models\Instance;
use Tests\TestCase;
class InstancesAdminPageTest extends TestCase
{
use RefreshDatabase;
// -------------------------------------------------------------------------
// Test 3 — admin instances page is accessible
// -------------------------------------------------------------------------
public function test_admin_instances_page_is_accessible(): void
{
$response = $this->get('/admin/instances');
$response->assertStatus(200);
}
// -------------------------------------------------------------------------
// Test 4 — admin instances page lists each instance's URL and last_polled_at
// -------------------------------------------------------------------------
public function test_admin_instances_page_shows_each_instance_url_and_last_polled_at(): void
{
$mastodon = Instance::factory()
->type(InstanceType::Mastodon)
->enabled()
->create([
'url' => 'https://mastodon.social',
'last_polled_at' => '2024-06-01 12:00:00',
]);
$lemmy = Instance::factory()
->type(InstanceType::Lemmy)
->enabled()
->create([
'url' => 'https://lemmy.world',
'last_polled_at' => '2024-06-01 13:00:00',
]);
$response = $this->get('/admin/instances');
$response->assertSee($mastodon->url);
$response->assertSee($lemmy->url);
$response->assertSee($mastodon->last_polled_at->toDateString());
$response->assertSee($lemmy->last_polled_at->toDateString());
}
}