vito/tests/Feature/ServerProvidersTest.php
Saeed Vaziry b2083fc6b2
Migrate to HTMX (#114)
Dropped Livewire
Added HTMX
Added Blade code lint
Drop Mysql and Redis
Migrate to SQLite
2024-03-06 17:02:59 +01:00

67 lines
1.6 KiB
PHP

<?php
namespace Tests\Feature;
use App\Enums\ServerProvider;
use Illuminate\Foundation\Testing\RefreshDatabase;
use Illuminate\Support\Facades\Http;
use JsonException;
use Tests\TestCase;
class ServerProvidersTest extends TestCase
{
use RefreshDatabase;
/**
* @throws JsonException
*/
public function test_connect_hetzner(): void
{
$this->actingAs($this->user);
Http::fake();
$this->post(route('server-providers.connect'), [
'provider' => ServerProvider::HETZNER,
'name' => 'profile',
'token' => 'token',
])->assertSessionHasNoErrors();
$this->assertDatabaseHas('server_providers', [
'provider' => ServerProvider::HETZNER,
'profile' => 'profile',
]);
}
public function test_see_providers_list(): void
{
$this->actingAs($this->user);
$provider = \App\Models\ServerProvider::factory()->create([
'user_id' => $this->user->id,
]);
$this->get(route('server-providers'))
->assertSee($provider->profile);
}
/**
* @throws JsonException
*/
public function test_delete_provider(): void
{
$this->actingAs($this->user);
$provider = \App\Models\ServerProvider::factory()->create([
'user_id' => $this->user->id,
]);
$this->delete(route('server-providers.delete', $provider->id))
->assertSessionHasNoErrors();
$this->assertDatabaseMissing('server_providers', [
'id' => $provider->id,
]);
}
}