mirror of
https://github.com/wallabag/wallabag.git
synced 2025-09-15 18:57:05 +00:00
Tag: render tags case-insensitive by storing them in lowercase
Fixes #2502 Signed-off-by: Kevin Decherf <kevin@kdecherf.com>
This commit is contained in:
parent
2490f61dca
commit
7036d91fe7
4 changed files with 7 additions and 5 deletions
|
@ -78,7 +78,7 @@ class Tag
|
||||||
*/
|
*/
|
||||||
public function setLabel($label)
|
public function setLabel($label)
|
||||||
{
|
{
|
||||||
$this->label = $label;
|
$this->label = mb_convert_case($label, MB_CASE_LOWER);
|
||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
|
@ -45,7 +45,7 @@ class TagsAssigner
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach ($tags as $label) {
|
foreach ($tags as $label) {
|
||||||
$label = trim($label);
|
$label = trim(mb_convert_case($label, MB_CASE_LOWER));
|
||||||
|
|
||||||
// avoid empty tag
|
// avoid empty tag
|
||||||
if (0 === strlen($label)) {
|
if (0 === strlen($label)) {
|
||||||
|
|
|
@ -9,6 +9,7 @@ use Wallabag\CoreBundle\Entity\Tag;
|
||||||
class TagControllerTest extends WallabagCoreTestCase
|
class TagControllerTest extends WallabagCoreTestCase
|
||||||
{
|
{
|
||||||
public $tagName = 'opensource';
|
public $tagName = 'opensource';
|
||||||
|
public $caseTagName = 'OpenSource';
|
||||||
|
|
||||||
public function testList()
|
public function testList()
|
||||||
{
|
{
|
||||||
|
@ -36,7 +37,7 @@ class TagControllerTest extends WallabagCoreTestCase
|
||||||
$form = $crawler->filter('form[name=tag]')->form();
|
$form = $crawler->filter('form[name=tag]')->form();
|
||||||
|
|
||||||
$data = [
|
$data = [
|
||||||
'tag[label]' => $this->tagName,
|
'tag[label]' => $this->caseTagName,
|
||||||
];
|
];
|
||||||
|
|
||||||
$client->submit($form, $data);
|
$client->submit($form, $data);
|
||||||
|
@ -45,6 +46,7 @@ class TagControllerTest extends WallabagCoreTestCase
|
||||||
// be sure to reload the entry
|
// be sure to reload the entry
|
||||||
$entry = $this->getEntityManager()->getRepository(Entry::class)->find($entry->getId());
|
$entry = $this->getEntityManager()->getRepository(Entry::class)->find($entry->getId());
|
||||||
$this->assertCount(1, $entry->getTags());
|
$this->assertCount(1, $entry->getTags());
|
||||||
|
$this->assertContains($this->tagName, $entry->getTags());
|
||||||
|
|
||||||
// tag already exists and already assigned
|
// tag already exists and already assigned
|
||||||
$client->submit($form, $data);
|
$client->submit($form, $data);
|
||||||
|
@ -80,7 +82,7 @@ class TagControllerTest extends WallabagCoreTestCase
|
||||||
$form = $crawler->filter('form[name=tag]')->form();
|
$form = $crawler->filter('form[name=tag]')->form();
|
||||||
|
|
||||||
$data = [
|
$data = [
|
||||||
'tag[label]' => 'foo2, bar2',
|
'tag[label]' => 'foo2, Bar2',
|
||||||
];
|
];
|
||||||
|
|
||||||
$client->submit($form, $data);
|
$client->submit($form, $data);
|
||||||
|
|
|
@ -125,7 +125,7 @@ class WallabagV1ControllerTest extends WallabagCoreTestCase
|
||||||
|
|
||||||
$tags = $content->getTags();
|
$tags = $content->getTags();
|
||||||
$this->assertContains('foot', $tags, 'It includes the "foot" tag');
|
$this->assertContains('foot', $tags, 'It includes the "foot" tag');
|
||||||
$this->assertContains('Framabag', $tags, 'It includes the "Framabag" tag');
|
$this->assertContains('framabag', $tags, 'It includes the "framabag" tag');
|
||||||
$this->assertSame(2, count($tags));
|
$this->assertSame(2, count($tags));
|
||||||
|
|
||||||
$this->assertInstanceOf(\DateTime::class, $content->getCreatedAt());
|
$this->assertInstanceOf(\DateTime::class, $content->getCreatedAt());
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue