2017-01-12 15:41:20 -05:00
|
|
|
<?php declare(strict_types=1);
|
|
|
|
/**
|
2017-02-15 16:13:32 -05:00
|
|
|
* Hummingbird Anime List Client
|
2017-01-12 15:41:20 -05:00
|
|
|
*
|
|
|
|
* An API client for Kitsu and MyAnimeList to manage anime and manga watch lists
|
|
|
|
*
|
|
|
|
* PHP version 7
|
|
|
|
*
|
2017-02-15 16:13:32 -05:00
|
|
|
* @package HummingbirdAnimeClient
|
2017-01-12 15:41:20 -05:00
|
|
|
* @author Timothy J. Warren <tim@timshomepage.net>
|
2018-01-15 14:43:15 -05:00
|
|
|
* @copyright 2015 - 2018 Timothy J. Warren
|
2017-01-12 15:41:20 -05:00
|
|
|
* @license http://www.opensource.org/licenses/mit-license.html MIT License
|
|
|
|
* @version 4.0
|
2017-03-07 20:53:58 -05:00
|
|
|
* @link https://git.timshomepage.net/timw4mail/HummingBirdAnimeClient
|
2017-01-12 15:41:20 -05:00
|
|
|
*/
|
|
|
|
|
|
|
|
namespace Aviat\AnimeClient\Tests\API;
|
|
|
|
|
|
|
|
use Aviat\AnimeClient\API\JsonAPI;
|
|
|
|
use Aviat\Ion\Json;
|
|
|
|
use PHPUnit\Framework\TestCase;
|
|
|
|
|
|
|
|
class JsonAPITest extends TestCase {
|
|
|
|
|
2017-02-22 14:46:35 -05:00
|
|
|
protected $startData;
|
|
|
|
protected $organizedIncludes;
|
|
|
|
protected $inlineIncluded;
|
|
|
|
|
2017-01-12 15:41:20 -05:00
|
|
|
public function setUp()
|
|
|
|
{
|
|
|
|
$dir = __DIR__ . '/../test_data/JsonAPI';
|
|
|
|
$this->startData = Json::decodeFile("{$dir}/jsonApiExample.json");
|
|
|
|
$this->organizedIncludes = Json::decodeFile("{$dir}/organizedIncludes.json");
|
|
|
|
$this->inlineIncluded = Json::decodeFile("{$dir}/inlineIncluded.json");
|
|
|
|
}
|
|
|
|
|
|
|
|
public function testOrganizeIncludes()
|
|
|
|
{
|
|
|
|
$expected = $this->organizedIncludes;
|
|
|
|
$actual = JsonAPI::organizeIncludes($this->startData['included']);
|
|
|
|
|
|
|
|
$this->assertEquals($expected, $actual);
|
|
|
|
}
|
|
|
|
|
|
|
|
public function testInlineIncludedRelationships()
|
|
|
|
{
|
|
|
|
$expected = $this->inlineIncluded;
|
|
|
|
$actual = JsonAPI::inlineIncludedRelationships($this->organizedIncludes, 'anime');
|
|
|
|
|
|
|
|
$this->assertEquals($expected, $actual);
|
|
|
|
}
|
|
|
|
}
|