Add tests for title uniqueness check

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

View File

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

View File

@ -122,4 +122,36 @@ class KitsuTest extends TestCase {
$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);
}
}