PIMS/tests/Feature/Movies/AdminExistsMovieTest.php

53 lines
1.3 KiB
PHP
Raw Normal View History

2025-12-07 03:49:26 +00:00
<?php
namespace Tests\Feature\Movies;
use App\Models\User;
use App\Modules\Movies\Models\Movie;
use Illuminate\Foundation\Testing\RefreshDatabase;
use Tests\TestCase;
class AdminExistsMovieTest extends TestCase
{
use RefreshDatabase;
protected function signIn(): User
{
$user = User::factory()->create();
$this->actingAs($user);
return $user;
}
public function test_requires_authentication(): void
{
$res = $this->getJson('/admin/movies/exists?provider_id=tt0000001');
$res->assertStatus(401);
}
public function test_reports_false_when_not_found(): void
{
$this->signIn();
$res = $this->getJson('/admin/movies/exists?provider_id=tt0000001');
$res->assertOk()
->assertJson([
'exists' => false,
]);
}
public function test_reports_true_when_found(): void
{
$this->signIn();
$movie = Movie::factory()->create([
'provider' => 'tmdb',
'provider_id' => '1234567',
2025-12-07 03:49:26 +00:00
]);
$res = $this->getJson('/admin/movies/exists?provider_id=1234567');
2025-12-07 03:49:26 +00:00
$res->assertOk()
->assertJson([
'exists' => true,
'movie_id' => $movie->id,
]);
}
}