HummingBirdAnimeClient/tests/AnimeClient/API/JsonAPITest.php

55 lines
1.6 KiB
PHP
Raw Normal View History

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
*
2018-08-22 13:48:27 -04:00
* An API client for Kitsu to manage anime and manga watch lists
2017-01-12 15:41:20 -05:00
*
* PHP version 7.4
2017-01-12 15:41:20 -05:00
*
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>
2020-01-08 15:39:49 -05:00
* @copyright 2015 - 2020 Timothy J. Warren
2017-01-12 15:41:20 -05:00
* @license http://www.opensource.org/licenses/mit-license.html MIT License
2020-08-04 09:30:21 -04:00
* @version 5.1
* @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 {
2018-10-29 10:07:20 -04:00
2017-02-22 14:46:35 -05:00
protected $startData;
protected $organizedIncludes;
protected $inlineIncluded;
2018-10-29 10:07:20 -04:00
2019-12-06 09:15:49 -05:00
public function setUp(): void {
2017-01-12 15:41:20 -05:00
$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");
}
2018-10-29 10:07:20 -04:00
2017-01-12 15:41:20 -05:00
public function testOrganizeIncludes()
{
$expected = $this->organizedIncludes;
$actual = JsonAPI::organizeIncludes($this->startData['included']);
2018-10-29 10:07:20 -04:00
// file_put_contents(__DIR__ . '/../test_data/JsonAPI/organizedIncludes.json', json_Encode($actual));
2017-01-12 15:41:20 -05:00
$this->assertEquals($expected, $actual);
}
2018-10-29 10:07:20 -04:00
2017-01-12 15:41:20 -05:00
public function testInlineIncludedRelationships()
{
$expected = $this->inlineIncluded;
$actual = JsonAPI::inlineIncludedRelationships($this->organizedIncludes, 'anime');
2018-10-29 10:07:20 -04:00
// file_put_contents(__DIR__ . '/../test_data/JsonAPI/inlineIncluded.json', json_Encode($actual));
2017-01-12 15:41:20 -05:00
$this->assertEquals($expected, $actual);
}
}