mirror of
https://github.com/wallabag/wallabag.git
synced 2026-11-14 03:31:20 +01:00
Looks like a kind of empty `authors` given from the API can lead to an array of an empty value to be saved in the database. Also, the default value for the `authors` field in the API can generate that problem too.
47 lines
1.2 KiB
PHP
47 lines
1.2 KiB
PHP
<?php
|
|
|
|
namespace Wallabag\Tests\Unit\Entity;
|
|
|
|
use PHPUnit\Framework\TestCase;
|
|
use Wallabag\Entity\Entry;
|
|
use Wallabag\Entity\User;
|
|
|
|
class EntryTest extends TestCase
|
|
{
|
|
public function testGetLanguage(): void
|
|
{
|
|
$entry = new Entry(new User());
|
|
$languages = [
|
|
'en_GB' => 'en-GB',
|
|
'en_US' => 'en-US',
|
|
'en-gb' => 'en-GB',
|
|
'en-US' => 'en-US',
|
|
'fr' => 'fr',
|
|
'fr_FR' => 'fr-FR',
|
|
'ja' => 'ja',
|
|
];
|
|
foreach ($languages as $entryLang => $lang) {
|
|
$entry->setLanguage($entryLang);
|
|
$this->assertSame($lang, $entry->getHTMLLanguage());
|
|
}
|
|
}
|
|
|
|
public function testSetPublishedByFiltersEmptyAuthors(): void
|
|
{
|
|
$entry = new Entry(new User());
|
|
|
|
$entry->setPublishedBy(['', ' bob ', ' ', 'helen']);
|
|
|
|
$this->assertSame(['bob', 'helen'], $entry->getPublishedBy());
|
|
}
|
|
|
|
public function testSetPublishedByStoresNullWhenOnlyEmptyAuthorsAreProvided(): void
|
|
{
|
|
$entry = new Entry(new User());
|
|
|
|
$entry->setPublishedBy(['', ' ']);
|
|
|
|
$this->assertNull($entry->getPublishedBy());
|
|
}
|
|
}
|