Files
huginn/tests/Feature/GuestPreviewTest.php
T

46 lines
1.1 KiB
PHP
Raw Normal View History

<?php
namespace Tests\Feature;
use App\Models\Site;
use App\Models\User;
use Illuminate\Foundation\Testing\RefreshDatabase;
use Tests\TestCase;
class GuestPreviewTest extends TestCase
{
use RefreshDatabase;
private function seedSites(int $count): void
{
for ($i = 0; $i < $count; $i++) {
Site::create([
'collection' => 'CC-MAIN-TEST',
'domain' => "example{$i}.com",
'root_domain' => "example{$i}.com",
'url' => "https://example{$i}.com/",
]);
}
}
public function test_guest_sees_only_a_preview_of_sites(): void
{
$this->seedSites(8);
$response = $this->get(route('sites.index'));
$response->assertOk();
$response->assertSeeText('Showing a preview (5 of 8 results)');
}
public function test_authenticated_user_sees_all_sites(): void
{
$this->seedSites(8);
$response = $this->actingAs(User::factory()->create())->get(route('sites.index'));
$response->assertOk();
$response->assertDontSeeText('Showing a preview');
}
}