diff --git a/src/Wallabag/CoreBundle/Helper/RuleBasedTagger.php b/src/Wallabag/CoreBundle/Helper/RuleBasedTagger.php index d48e2469a..0b18beaaa 100644 --- a/src/Wallabag/CoreBundle/Helper/RuleBasedTagger.php +++ b/src/Wallabag/CoreBundle/Helper/RuleBasedTagger.php @@ -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) { diff --git a/tests/Wallabag/CoreBundle/Helper/RuleBasedTaggerTest.php b/tests/Wallabag/CoreBundle/Helper/RuleBasedTaggerTest.php index 9500bff45..44d42a980 100644 --- a/tests/Wallabag/CoreBundle/Helper/RuleBasedTaggerTest.php +++ b/tests/Wallabag/CoreBundle/Helper/RuleBasedTaggerTest.php @@ -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']);