Add tests for title uniqueness check

This commit is contained in:
Timothy Warren 2021-02-10 10:59:15 -05:00
parent a18c0bd7b5
commit 2f789cc4cf
2 changed files with 33 additions and 1 deletions

View File

@ -416,7 +416,7 @@ final class Kitsu {
* @param array $existingTitles * @param array $existingTitles
* @return bool * @return bool
*/ */
private static function titleIsUnique(?string $title = '', array $existingTitles = []): bool protected static function titleIsUnique(?string $title = '', array $existingTitles = []): bool
{ {
if (empty($title)) if (empty($title))
{ {

View File

@ -122,4 +122,36 @@ class KitsuTest extends TestCase {
$this->assertEquals($expected, $actual); $this->assertEquals($expected, $actual);
} }
public function testFilterLocalizedTitles()
{
$input = [
'canonical' => 'foo',
'localized' => [
'en' => 'Foo the Movie',
'fr' => '',
'jp' => NULL,
],
'alternatives' => [],
];
$actual = Kitsu::filterLocalizedTitles($input);
$this->assertEquals(['Foo the Movie'], $actual);
}
public function testGetFilteredTitles()
{
$input = [
'canonical' => 'foo',
'localized' => [
'en' => 'Foo the Movie'
],
'alternatives' => [],
];
$actual = Kitsu::getFilteredTitles($input);
$this->assertEquals(['Foo the Movie'], $actual);
}
} }