vito/tests/Feature/ProjectsTest.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

82 lines
1.8 KiB
PHP

<?php
namespace Tests\Feature;
use App\Models\Project;
use Illuminate\Foundation\Testing\RefreshDatabase;
use JsonException;
use Tests\TestCase;
class ProjectsTest extends TestCase
{
use RefreshDatabase;
/**
* @throws JsonException
*/
public function test_create_project(): void
{
$this->actingAs($this->user);
$this->post(route('projects.create'), [
'name' => 'test',
])->assertSessionHasNoErrors();
$this->assertDatabaseHas('projects', [
'name' => 'test',
]);
}
public function test_see_projects_list(): void
{
$this->actingAs($this->user);
$project = Project::factory()->create([
'user_id' => $this->user->id,
]);
$this->get(route('projects'))
->assertSee($project->name);
}
/**
* @throws JsonException
*/
public function test_delete_project(): void
{
$this->actingAs($this->user);
$project = Project::factory()->create([
'user_id' => $this->user->id,
]);
$this->delete(route('projects.delete', $project))
->assertSessionHasNoErrors();
$this->assertDatabaseMissing('projects', [
'id' => $project->id,
]);
}
/**
* @throws JsonException
*/
public function test_edit_project(): void
{
$this->actingAs($this->user);
$project = Project::factory()->create([
'user_id' => $this->user->id,
]);
$this->post(route('projects.update', $project), [
'name' => 'new-name',
])->assertSessionHasNoErrors();
$this->assertDatabaseHas('projects', [
'id' => $project->id,
'name' => 'new-name',
]);
}
}