Skip to content

Commit 92ac3a6

Browse files
committed
Added test for Watch/Provider and Watch/Providers
1 parent 8ae7a82 commit 92ac3a6

3 files changed

Lines changed: 106 additions & 1 deletion

File tree

lib/Tmdb/Model/Watch/Provider.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ public function setId(?int $id): self
8181
*/
8282
public function getName(): ?string
8383
{
84-
return $this->Name;
84+
return $this->name;
8585
}
8686

8787
/**
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
<?php
2+
3+
/**
4+
* This file is part of the Tmdb PHP API created by Michael Roterman.
5+
*
6+
* For the full copyright and license information, please view the LICENSE
7+
* file that was distributed with this source code.
8+
*
9+
* @package Tmdb
10+
* @author Neil Daniels <neil.here@gmail.com>
11+
* @copyright (c) 2021, Neil Daniels
12+
* @version 4.0.0
13+
*/
14+
15+
namespace Tmdb\Tests\Model\Watch;
16+
17+
use Tmdb\Common\ObjectHydrator;
18+
use Tmdb\Model\Watch\Provider;
19+
use Tmdb\Tests\Model\TestCase;
20+
21+
class ProviderTest extends TestCase
22+
{
23+
/**
24+
* @test
25+
*/
26+
public function shouldBeFunctional()
27+
{
28+
$data = [
29+
'iso_3166_1' => 'US',
30+
'id' => 337,
31+
'name' => 'Disney Plus',
32+
'logo_path' => '/dgPueyEdOwpQ10fjuhL2WYFQwQs.jpg',
33+
'display_priority' => 1,
34+
'type' => 'flatrate',
35+
];
36+
37+
$hydrator = new ObjectHydrator();
38+
39+
/**
40+
* @var Release $object
41+
*/
42+
$object = $hydrator->hydrate(new Provider(), $data);
43+
44+
$this->assertEquals('US', $object->getIso31661());
45+
$this->assertEquals(337, $object->getId());
46+
$this->assertEquals('Disney Plus', $object->getName());
47+
$this->assertEquals('/dgPueyEdOwpQ10fjuhL2WYFQwQs.jpg', $object->getLogoPath());
48+
$this->assertEquals(1, $object->getDisplayPriority());
49+
$this->assertEquals('flatrate', $object->getType());
50+
}
51+
}
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
<?php
2+
3+
/**
4+
* This file is part of the Tmdb PHP API created by Michael Roterman.
5+
*
6+
* For the full copyright and license information, please view the LICENSE
7+
* file that was distributed with this source code.
8+
*
9+
* @package Tmdb
10+
* @author Neil Daniels <neil.here@gmail.com>
11+
* @copyright (c) 2021, Neil Daniels
12+
* @version 4.0.0
13+
*/
14+
15+
namespace Tmdb\Tests\Model\Watch;
16+
17+
use Tmdb\Common\ObjectHydrator;
18+
use Tmdb\Model\Watch\Providers;
19+
use Tmdb\Model\Common\GenericCollection;
20+
use Tmdb\Tests\Model\TestCase;
21+
22+
class ProvidersTest extends TestCase
23+
{
24+
/**
25+
* @test
26+
*/
27+
public function shouldBeFunctional()
28+
{
29+
$flatrateCollection = new GenericCollection();
30+
$rentCollection = new GenericCollection();
31+
$buyCollection = new GenericCollection();
32+
33+
$data = [
34+
'iso_3166_1' => 'US',
35+
'link' => 'https://www.themoviedb.org/movie/12092-alice-in-wonderland/watch?locale=US',
36+
'flatrate' => $flatrateCollection,
37+
'rent' => $rentCollection,
38+
'buy' => $buyCollection,
39+
];
40+
41+
$hydrator = new ObjectHydrator();
42+
43+
/**
44+
* @var Release $object
45+
*/
46+
$object = $hydrator->hydrate(new Providers(), $data);
47+
48+
$this->assertEquals('US', $object->getIso31661());
49+
$this->assertEquals('https://www.themoviedb.org/movie/12092-alice-in-wonderland/watch?locale=US', $object->getLink());
50+
$this->assertEquals($flatrateCollection, $object->getFlatrate());
51+
$this->assertEquals($rentCollection, $object->getRent());
52+
$this->assertEquals($buyCollection, $object->getBuy());
53+
}
54+
}

0 commit comments

Comments
 (0)