Add tests for title uniqueness check
This commit is contained in:
parent
cb7a4c28e5
commit
b7a2eafc0d
@ -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))
|
||||
{
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user