API client for Kitsu.io, with optional Anime collection, and optional Anilist syncing.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

AnimeListTransformerTest.php 2.3KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. <?php declare(strict_types=1);
  2. /**
  3. * Hummingbird Anime List Client
  4. *
  5. * An API client for Kitsu and MyAnimeList to manage anime and manga watch lists
  6. *
  7. * PHP version 7
  8. *
  9. * @package HummingbirdAnimeClient
  10. * @author Timothy J. Warren <tim@timshomepage.net>
  11. * @copyright 2015 - 2018 Timothy J. Warren
  12. * @license http://www.opensource.org/licenses/mit-license.html MIT License
  13. * @version 4.0
  14. * @link https://git.timshomepage.net/timw4mail/HummingBirdAnimeClient
  15. */
  16. namespace Aviat\AnimeClient\Tests\API\Kitsu\Transformer;
  17. use Aviat\AnimeClient\API\Kitsu\Transformer\AnimeListTransformer;
  18. use Aviat\AnimeClient\Tests\AnimeClientTestCase;
  19. use Aviat\Ion\Friend;
  20. use Aviat\Ion\Json;
  21. class AnimeListTransformerTest extends AnimeClientTestCase {
  22. protected $dir;
  23. protected $beforeTransform;
  24. protected $afterTransform;
  25. protected $transformer;
  26. public function setUp()
  27. {
  28. parent::setUp();
  29. $this->dir = AnimeClientTestCase::TEST_DATA_DIR . '/Kitsu';
  30. $this->beforeTransform = Json::decodeFile("{$this->dir}/animeListItemBeforeTransform.json");
  31. $this->transformer = new AnimeListTransformer();
  32. }
  33. public function testTransform()
  34. {
  35. $actual = $this->transformer->transform($this->beforeTransform);
  36. $this->assertMatchesSnapshot($actual);
  37. }
  38. public function dataUntransform()
  39. {
  40. return [[
  41. 'input' => [
  42. 'id' => 14047981,
  43. 'watching_status' => 'current',
  44. 'user_rating' => 8,
  45. 'episodes_watched' => 38,
  46. 'rewatched' => 0,
  47. 'notes' => 'Very formulaic.',
  48. 'edit' => true
  49. ]
  50. ], [
  51. 'input' => [
  52. 'id' => 14047981,
  53. 'mal_id' => '12345',
  54. 'watching_status' => 'current',
  55. 'user_rating' => 8,
  56. 'episodes_watched' => 38,
  57. 'rewatched' => 0,
  58. 'notes' => 'Very formulaic.',
  59. 'edit' => 'true',
  60. 'private' => 'On',
  61. 'rewatching' => 'On'
  62. ]
  63. ], [
  64. 'input' => [
  65. 'id' => 14047983,
  66. 'mal_id' => '12347',
  67. 'watching_status' => 'current',
  68. 'user_rating' => 0,
  69. 'episodes_watched' => 12,
  70. 'rewatched' => 0,
  71. 'notes' => '',
  72. 'edit' => 'true',
  73. 'private' => 'On',
  74. 'rewatching' => 'On'
  75. ]
  76. ]];
  77. }
  78. /**
  79. * @dataProvider dataUntransform
  80. */
  81. public function testUntransform($input)
  82. {
  83. $actual = $this->transformer->untransform($input);
  84. $this->assertMatchesSnapshot($actual);
  85. }
  86. }