Make sure rating parameter sent to Kitsu is greater than 0

This commit is contained in:
Timothy Warren 2017-04-06 14:53:38 -04:00
parent b444648a3d
commit 5357bfb122
3 changed files with 27 additions and 1 deletions

View File

@ -123,7 +123,7 @@ class AnimeListTransformer extends AbstractTransformer {
]
];
if (is_numeric($item['user_rating']))
if (is_numeric($item['user_rating']) && $item['user_rating'] > 0)
{
$untransformed['data']['rating'] = $item['user_rating'] / 2;
}

View File

@ -68,6 +68,19 @@ class AnimeListTransformerTest extends AnimeClientTestCase {
'private' => 'On',
'rewatching' => 'On'
]
], [
'input' => [
'id' => 14047983,
'mal_id' => '12347',
'watching_status' => 'current',
'user_rating' => 0,
'episodes_watched' => 12,
'rewatched' => 0,
'notes' => '',
'edit' => 'true',
'private' => 'On',
'rewatching' => 'On'
]
]];
}

View File

@ -0,0 +1,13 @@
<?php return array (
'id' => 14047983,
'mal_id' => '12347',
'data' =>
array (
'status' => 'current',
'reconsuming' => true,
'reconsumeCount' => 0,
'notes' => '',
'progress' => 12,
'private' => true,
),
);