mirror of
https://github.com/vitodeploy/vito.git
synced 2025-07-02 14:36:17 +00:00
Add site redirects (#552)
* feat(redirects): add redirects to sites * chore(style): fixed coding style issues * style: fix php-stan docblocks * style: pint cleanup * tests: fixed redirect test suite * feat: vhosts include additional configs * fix: use exact location matching * - add enums - use queues - use vhost rather than separate conf files - vhost formatter - cleanup * generate docs --------- Co-authored-by: Saeed Vaziry <mr.saeedvaziry@gmail.com>
This commit is contained in:
82
tests/Feature/RedirectsTest.php
Normal file
82
tests/Feature/RedirectsTest.php
Normal file
@ -0,0 +1,82 @@
|
||||
<?php
|
||||
|
||||
namespace Tests\Feature;
|
||||
|
||||
use App\Enums\RedirectStatus;
|
||||
use App\Facades\SSH;
|
||||
use App\Models\Redirect;
|
||||
use App\Web\Pages\Servers\Sites\Pages\Redirects\Index;
|
||||
use App\Web\Pages\Servers\Sites\Pages\Redirects\Widgets\RedirectsList;
|
||||
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||
use Livewire\Livewire;
|
||||
use Tests\TestCase;
|
||||
|
||||
class RedirectsTest extends TestCase
|
||||
{
|
||||
use RefreshDatabase;
|
||||
|
||||
public function test_see_redirects(): void
|
||||
{
|
||||
$this->actingAs($this->user);
|
||||
|
||||
$redirect = Redirect::factory()->create([
|
||||
'site_id' => $this->site->id,
|
||||
]);
|
||||
|
||||
$this->get(
|
||||
Index::getUrl([
|
||||
'server' => $this->server,
|
||||
'site' => $this->site,
|
||||
])
|
||||
)
|
||||
->assertSuccessful()
|
||||
->assertSee($redirect->from);
|
||||
}
|
||||
|
||||
public function test_delete_redirect(): void
|
||||
{
|
||||
SSH::fake();
|
||||
|
||||
$this->actingAs($this->user);
|
||||
|
||||
$redirect = Redirect::factory()->create([
|
||||
'site_id' => $this->site->id,
|
||||
]);
|
||||
|
||||
Livewire::test(RedirectsList::class, [
|
||||
'server' => $this->server,
|
||||
'site' => $this->site,
|
||||
])
|
||||
->callTableAction('delete', $redirect->id)
|
||||
->assertSuccessful();
|
||||
|
||||
$this->assertDatabaseMissing('redirects', [
|
||||
'id' => $redirect->id,
|
||||
]);
|
||||
}
|
||||
|
||||
public function test_create_redirect(): void
|
||||
{
|
||||
SSH::fake();
|
||||
|
||||
$this->actingAs($this->user);
|
||||
|
||||
Livewire::test(Index::class, [
|
||||
'server' => $this->server,
|
||||
'site' => $this->site,
|
||||
])
|
||||
->callAction('create', [
|
||||
'from' => 'some-path',
|
||||
'to' => 'https://example.com/redirect',
|
||||
'mode' => 301,
|
||||
])
|
||||
->assertSuccessful();
|
||||
|
||||
$this->assertDatabaseHas('redirects', [
|
||||
'from' => 'some-path',
|
||||
'to' => 'https://example.com/redirect',
|
||||
'mode' => 301,
|
||||
'status' => RedirectStatus::READY,
|
||||
]);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user