PIMS/tests/Feature/Movies/PublicMoviesBrowseTest.php

37 lines
1,019 B
PHP
Raw Permalink Normal View History

2025-12-07 03:49:26 +00:00
<?php
namespace Tests\Feature\Movies;
use App\Modules\Movies\Models\Movie;
use Illuminate\Foundation\Testing\RefreshDatabase;
use Tests\TestCase;
class PublicMoviesBrowseTest extends TestCase
{
use RefreshDatabase;
public function test_public_index_returns_paginated_json_and_filters_by_q(): void
{
Movie::factory()->count(3)->create(['title' => 'Alpha']);
Movie::factory()->count(2)->create(['title' => 'Beta']);
$res = $this->getJson('/api/movies?q=Alpha');
$res->assertOk();
$json = $res->json();
$this->assertArrayHasKey('data', $json);
$this->assertSame(3, $json['total']);
$this->assertCount(3, $json['data']);
}
public function test_public_show_returns_movie_or_404(): void
{
$movie = Movie::factory()->create();
$this->getJson('/api/movies/'.$movie->id)
->assertOk()
->assertJsonPath('id', $movie->id);
$this->getJson('/api/movies/999999')->assertNotFound();
}
}