HummingBirdAnimeClient/tests/Transformer/AnimeListTransformerTest.php

50 lines
1.3 KiB
PHP
Raw Normal View History

2015-09-25 13:41:12 -04:00
<?php
2016-10-20 22:32:17 -04:00
use Aviat\AnimeClient\Hummingbird\Transformer\AnimeListTransformer;
2015-09-25 13:41:12 -04:00
use Aviat\Ion\Friend;
2016-01-07 13:45:43 -05:00
use Aviat\Ion\Json;
2015-09-25 13:41:12 -04:00
class AnimeListTransformerTest extends AnimeClient_TestCase {
public function setUp()
{
parent::setUp();
2016-08-29 17:09:56 -04:00
$this->start_file = __DIR__ . '/../test_data/anime_list/anime-completed.json';
$this->res_file = __DIR__ . '/../test_data/anime_list/anime-completed-transformed.json';
2015-09-25 13:41:12 -04:00
$this->transformer = new AnimeListTransformer();
$this->transformerFriend = new Friend($this->transformer);
}
public function dataLinearizeGenres()
{
return [
[
'original' => [
['name' => 'Action'],
['name' => 'Comedy'],
['name' => 'Magic'],
['name' => 'Fantasy'],
['name' => 'Mahou Shoujo']
],
'expected' => ['Action', 'Comedy', 'Magic', 'Fantasy', 'Mahou Shoujo']
]
];
}
/**
* @dataProvider dataLinearizeGenres
*/
public function testLinearizeGenres($original, $expected)
{
2016-10-20 22:09:36 -04:00
$actual = $this->transformerFriend->linearizeGenres($original);
2015-09-25 13:41:12 -04:00
$this->assertEquals($expected, $actual);
}
public function testTransform()
{
2016-01-07 13:45:43 -05:00
$json = Json::decodeFile($this->start_file);
$expected = Json::decodeFile($this->res_file);
2016-10-20 22:09:36 -04:00
$actual = $this->transformer->transformCollection($json);
2015-09-25 13:41:12 -04:00
$this->assertEquals($expected, $actual);
}
}