initial commit
Some checks are pending
linter / quality (push) Waiting to run
tests / ci (push) Waiting to run

This commit is contained in:
Edward Tirado Jr 2025-12-12 23:07:04 -06:00
commit 0c42bef077
109 changed files with 16545 additions and 0 deletions

View file

@ -0,0 +1,7 @@
<?php
test('returns a successful response', function () {
$response = $this->get('/');
$response->assertStatus(200);
});

54
tests/Pest.php Normal file
View file

@ -0,0 +1,54 @@
<?php
/*
|--------------------------------------------------------------------------
| Test Case
|--------------------------------------------------------------------------
|
| The closure you provide to your test functions is always bound to a specific PHPUnit test
| case class. By default, that class is "PHPUnit\Framework\TestCase". Of course, you may
| need to change it using the "pest()" function to bind a different classes or traits.
|
*/
use Illuminate\Foundation\Testing\DatabaseTransactions;
use Tests\TestCase;
uses(DatabaseTransactions::class)->in('Feature');
uses(TestCase::class)->in('Feature', 'Unit');
//pest()->extend(Tests\TestCase::class)
// //->use(Illuminate\Foundation\Testing\RefreshDatabase::class)
//
// ->in('Feature');
/*
|--------------------------------------------------------------------------
| Expectations
|--------------------------------------------------------------------------
|
| When you're writing tests, you often need to check that values meet certain conditions. The
| "expect()" function gives you access to a set of "expectations" methods that you can use
| to assert different things. Of course, you may extend the Expectation API at any time.
|
*/
expect()->extend('toBeOne', function () {
return $this->toBe(1);
});
/*
|--------------------------------------------------------------------------
| Functions
|--------------------------------------------------------------------------
|
| While Pest is very powerful out-of-the-box, you may have some testing code specific to your
| project that you don't want to repeat in every file. Here you can also expose helpers as
| global functions to help you to reduce the number of lines of code in your test files.
|
*/
function something()
{
// ..
}

10
tests/TestCase.php Normal file
View file

@ -0,0 +1,10 @@
<?php
namespace Tests;
use Illuminate\Foundation\Testing\TestCase as BaseTestCase;
abstract class TestCase extends BaseTestCase
{
//
}

49
tests/Unit/MoviesTest.php Normal file
View file

@ -0,0 +1,49 @@
<?php
use App\Models\Movie;
use App\Models\User;
use App\Services\OmdbService;
use Illuminate\Support\Facades\Http;
test('that OmdbService returns a movie when searching', function () {
config()->set('services.omdb.api_url', 'https://omdbapi.fake/?apikey=');
config()->set('services.omdb.api_key', 'abcd123');
$movieModel = new Movie();
$service = new OmdbService($movieModel);
User::factory()->create();
Http::fake([
'*' => Http::response([
"Title" => "Batman",
"Year" => "1989",
"Rated" => "PG-13",
"Released" => "23 Jun 1989",
"Runtime" => "126 min",
"Genre" => "Action",
"Adventure", "Director" => "Tim Burton",
"Writer" => "Bob Kane, Sam Hamm, Warren Skaaren",
"Actors" => "Michael Keaton, Jack Nicholson, Kim Basinger",
"Plot" => "The Dark Knight of Gotham City begins his war on crime with his first major enemy being Jack Napier, a criminal who becomes the clownishly homicidal Joker.",
"Language" => "English, French, Spanish",
"Country" => "United States, United Kingdom",
"Awards" => "Won 1 Oscar. 13 wins & 30 nominations total",
"Poster" => "https://m.media-amazon.com/images/M/MV5BYzZmZWViM2EtNzhlMi00NzBlLWE0MWEtZDFjMjk3YjIyNTBhXkEyXkFqcGc@._V1_SX300.jpg",
"Ratings" => '[{"Source" => "Internet Movie Database","Value":"7.5/10"},{"Source":"Rotten Tomatoes","Value":"77%"},{"Source":"Metacritic","Value":"69/100"}]',
"Metascore" => "69",
"imdbRating" => "7.5",
"imdbVotes" => "425,785",
"imdbID" => "tt0096895",
"Type" => "movie",
"DVD" => "N/A",
"BoxOffice" => "$251,409,241",
"Production" => "N/A",
"Website" => "N/A",
"Response" => "True",
])
]);
$movie = $service->search("batman");
expect($movie)->toBeInstanceOf(Movie::class);
expect($movie->imdb_id)->toBe('tt0096895');
});