nimuli/tests/Feature/Redirect/RedirectTest.php

35 lines
862 B
PHP

<?php
use App\Domains\Link\Models\Link;
it('redirects to target url for active link', function () {
$link = Link::factory()->create([
'slug' => 'abc123',
'target_url' => 'https://example.com',
'status' => 'active',
'domain_id' => null,
]);
$response = $this->get('/abc123');
$response->assertRedirect('https://example.com');
$response->assertStatus(302);
});
it('returns 404 for unknown slug', function () {
$response = $this->get('/nonexistent-xyz99');
$response->assertStatus(404);
});
it('returns 410 for disabled link', function () {
Link::factory()->create([
'slug' => 'disabled1',
'target_url' => 'https://example.com',
'status' => 'disabled',
'domain_id' => null,
]);
$response = $this->get('/disabled1');
$response->assertStatus(410);
});