53 lines
1.3 KiB
PHP
53 lines
1.3 KiB
PHP
<?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' => 'omdb',
|
|
'provider_id' => 'tt1234567',
|
|
]);
|
|
|
|
$res = $this->getJson('/admin/movies/exists?provider_id=tt1234567');
|
|
$res->assertOk()
|
|
->assertJson([
|
|
'exists' => true,
|
|
'movie_id' => $movie->id,
|
|
]);
|
|
}
|
|
}
|