Files
rootandClaude Sonnet 5 0a36afbfdc Add feature test coverage for the core domain
Only Breeze's default auth/profile tests existed - nothing covered
Workouts, Sessions, Exercises, Yoga, Favorites, Blog, or the Admin
panel, which is the actual product. Adds factories for the domain
models and 45 new feature tests covering the main flows plus
authorization boundaries (owner-only access on workouts/sessions,
admin-only access on /admin, drafts hidden from the public blog).

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
2026-08-10 11:47:51 +03:00

59 lines
1.6 KiB
PHP

<?php
namespace Tests\Feature;
use App\Models\YogaCategory;
use App\Models\YogaPose;
use Illuminate\Foundation\Testing\RefreshDatabase;
use Tests\TestCase;
class YogaPoseTest extends TestCase
{
use RefreshDatabase;
public function test_index_lists_poses(): void
{
YogaPose::factory()->count(3)->create();
$response = $this->get(route('yoga.index'));
$response->assertOk();
$response->assertViewHas('poses', function ($poses) {
return $poses->total() === 3;
});
}
public function test_index_can_filter_by_category(): void
{
$core = YogaCategory::factory()->create(['name' => 'Core Yoga']);
$balance = YogaCategory::factory()->create(['name' => 'Balance Yoga']);
$corePose = YogaPose::factory()->create(['category_id' => $core->id]);
YogaPose::factory()->create(['category_id' => $balance->id]);
$response = $this->get(route('yoga.index', ['category' => $core->id]));
$response->assertOk();
$response->assertViewHas('poses', function ($poses) use ($corePose) {
return $poses->total() === 1 && $poses->first()->id === $corePose->id;
});
}
public function test_show_displays_pose(): void
{
$pose = YogaPose::factory()->create(['english_name' => 'Downward Dog']);
$response = $this->get(route('yoga.show', $pose->slug));
$response->assertOk();
$response->assertSee('Downward Dog');
}
public function test_show_returns_404_for_unknown_slug(): void
{
$response = $this->get('/yoga/does-not-exist');
$response->assertNotFound();
}
}