HummingBirdAnimeClient/tests/AnimeClient/Hummingbird/Transformer/MangaListTransformerTest.php

114 lines
2.7 KiB
PHP
Raw Normal View History

2015-09-25 13:41:12 -04:00
<?php
2016-01-07 13:45:43 -05:00
use Aviat\Ion\Json;
use Aviat\AnimeClient\Hummingbird\Transformer\MangaListTransformer;
2015-09-25 13:41:12 -04:00
class MangaListTransformerTest extends AnimeClient_TestCase {
public function setUp()
{
parent::setUp();
$this->start_file = __DIR__ . '/../../../test_data/manga_list/manga-zippered.json';
$this->res_file = __DIR__ . '/../../../test_data/manga_list/manga-transformed.json';
$this->transformer = new MangaListTransformer();
}
public function testTransform()
{
2016-01-07 13:45:43 -05:00
$orig_json = Json::decodeFile($this->start_file);
$expected = Json::decodeFile($this->res_file);
2015-09-25 13:41:12 -04:00
$actual = $this->transformer->transform_collection($orig_json);
$this->assertEquals($expected, $actual);
}
public function dataUntransform()
{
return [
'same_rating' => [
'orig' => [
'id' => 401735,
'manga_id' => "love-hina",
'status' => "Plan to Read",
'chapters_read' => 16,
'volumes_read' => 2,
'rereading' => true,
'reread_count' => 1,
'notes' => "Some text notes",
'old_rating' => 7,
'new_rating' => 7,
],
'expected' => [
'id' => 401735,
'manga_id' => "love-hina",
'status' => "Plan to Read",
'chapters_read' => 16,
'volumes_read' => 2,
'rereading' => true,
'reread_count' => 1,
'notes' => "Some text notes",
]
],
'update_rating' => [
'orig' => [
'id' => 401735,
'manga_id' => "love-hina",
'status' => "Plan to Read",
'chapters_read' => 16,
'volumes_read' => 2,
'rereading' => true,
'reread_count' => 1,
'notes' => "Some text notes",
'old_rating' => 7,
'new_rating' => 8,
],
'expected' => [
'id' => 401735,
'manga_id' => "love-hina",
'status' => "Plan to Read",
'chapters_read' => 16,
'volumes_read' => 2,
'rereading' => true,
'reread_count' => 1,
'notes' => "Some text notes",
'rating' => 4,
]
],
'remove_rating' => [
'orig' => [
'id' => 401735,
'manga_id' => "love-hina",
'status' => "Plan to Read",
'chapters_read' => 16,
'volumes_read' => 2,
'rereading' => true,
'reread_count' => 1,
'notes' => "Some text notes",
'old_rating' => 7,
'new_rating' => 0,
],
'expected' => [
'id' => 401735,
'manga_id' => "love-hina",
'status' => "Plan to Read",
'chapters_read' => 16,
'volumes_read' => 2,
'rereading' => true,
'reread_count' => 1,
'notes' => "Some text notes",
'rating' => 3.5,
]
]
];
}
/**
* @dataProvider dataUntransform
*/
public function testUntransform($orig, $expected)
{
$actual = $this->transformer->untransform($orig);
$this->assertEquals($expected, $actual);
}
2015-09-25 13:41:12 -04:00
}