Skip to content

Commit

Permalink
fix enums
Browse files Browse the repository at this point in the history
  • Loading branch information
Gummibeer committed Feb 28, 2024
1 parent 8bb97db commit c685020
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 22 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -148,8 +148,8 @@ use Astrotomic\Tmdb\Enums\WatchProviderType;

Movie::findOrFail(335983)->watchProviders();
Movie::findOrFail(335983)->watchProviders('DE');
Movie::findOrFail(335983)->watchProviders(null, WatchProviderType::FLATRATE());
Movie::findOrFail(335983)->watchProviders('DE', WatchProviderType::FLATRATE());
Movie::findOrFail(335983)->watchProviders(null, WatchProviderType::FLATRATE);
Movie::findOrFail(335983)->watchProviders('DE', WatchProviderType::FLATRATE);
```

And there are some helper methods on the movie model to easier work with some attributes.
Expand Down
20 changes: 4 additions & 16 deletions src/Enums/WatchProviderType.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,9 @@

namespace Astrotomic\Tmdb\Enums;

use Spatie\Enum\Laravel\Enum;

/**
* @method static self BUY()
* @method static self RENT()
* @method static self FLATRATE()
*/
class WatchProviderType extends Enum
enum WatchProviderType: string
{
protected static function values(): array
{
return [
'BUY' => 'buy',
'RENT' => 'rent',
'FLATRATE' => 'flatrate',
];
}
case BUY = 'buy';
case RENT = 'rent';
case FLATRATE = 'flatrate';
}
8 changes: 4 additions & 4 deletions tests/Feature/Models/MovieTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -301,31 +301,31 @@
});

it('loads buy watch providers', function (): void {
$providers = Movie::query()->findOrFail(335983)->watchProviders(null, WatchProviderType::BUY());
$providers = Movie::query()->findOrFail(335983)->watchProviders(null, WatchProviderType::BUY);

expect($providers)
->toHaveCount(31)
->each->toBeInstanceOf(WatchProvider::class);
});

it('loads rent watch providers', function (): void {
$providers = Movie::query()->findOrFail(335983)->watchProviders(null, WatchProviderType::RENT());
$providers = Movie::query()->findOrFail(335983)->watchProviders(null, WatchProviderType::RENT);

expect($providers)
->toHaveCount(36)
->each->toBeInstanceOf(WatchProvider::class);
});

it('loads flatrate watch providers', function (): void {
$providers = Movie::query()->findOrFail(335983)->watchProviders(null, WatchProviderType::FLATRATE());
$providers = Movie::query()->findOrFail(335983)->watchProviders(null, WatchProviderType::FLATRATE);

expect($providers)
->toHaveCount(24)
->each->toBeInstanceOf(WatchProvider::class);
});

it('loads german flatrate watch providers', function (): void {
$providers = Movie::query()->findOrFail(335983)->watchProviders('DE', WatchProviderType::FLATRATE());
$providers = Movie::query()->findOrFail(335983)->watchProviders('DE', WatchProviderType::FLATRATE);

expect($providers)
->toHaveCount(1)
Expand Down

0 comments on commit c685020

Please sign in to comment.