mirror of
https://github.com/wallabag/wallabag.git
synced 2024-11-26 11:01:04 +00:00
Convert tag label to lowercase in RuleBasedTagger
Fixes #4266 Signed-off-by: Kevin Decherf <kevin@kdecherf.com>
This commit is contained in:
parent
af5e79c425
commit
7acd207054
2 changed files with 32 additions and 0 deletions
|
@ -94,6 +94,7 @@ class RuleBasedTagger
|
|||
*/
|
||||
private function getTag($label)
|
||||
{
|
||||
$label = mb_convert_case($label, \MB_CASE_LOWER);
|
||||
$tag = $this->tagRepository->findOneByLabel($label);
|
||||
|
||||
if (!$tag) {
|
||||
|
|
|
@ -139,6 +139,37 @@ class RuleBasedTaggerTest extends TestCase
|
|||
$this->assertCount(1, $records);
|
||||
}
|
||||
|
||||
public function testWithMixedCaseTag()
|
||||
{
|
||||
$taggingRule = $this->getTaggingRule('rule as string', ['Foo']);
|
||||
$user = $this->getUser([$taggingRule]);
|
||||
$entry = new Entry($user);
|
||||
$tag = new Tag();
|
||||
|
||||
$this->rulerz
|
||||
->expects($this->once())
|
||||
->method('satisfies')
|
||||
->with($entry, 'rule as string')
|
||||
->willReturn(true);
|
||||
|
||||
$this->tagRepository
|
||||
->expects($this->once())
|
||||
// the method `findOneByLabel` doesn't exist, EntityRepository will then call `_call` method
|
||||
// to magically call the `findOneBy` with ['label' => 'foo']
|
||||
->method('__call')
|
||||
->with('findOneByLabel', ['foo'])
|
||||
->willReturn($tag);
|
||||
|
||||
$this->tagger->tag($entry);
|
||||
|
||||
$this->assertFalse($entry->getTags()->isEmpty());
|
||||
|
||||
$tags = $entry->getTags();
|
||||
$this->assertSame($tag, $tags[0]);
|
||||
$records = $this->handler->getRecords();
|
||||
$this->assertCount(1, $records);
|
||||
}
|
||||
|
||||
public function testSameTagWithDifferentfMatchingRules()
|
||||
{
|
||||
$taggingRule = $this->getTaggingRule('bla bla', ['hey']);
|
||||
|
|
Loading…
Reference in a new issue