aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/Wallabag/CoreBundle/Tests
diff options
context:
space:
mode:
authorJeremy Benoist <jeremy.benoist@gmail.com>2015-12-27 22:26:49 +0100
committerJeremy Benoist <jeremy.benoist@gmail.com>2015-12-28 13:20:48 +0100
commitfc031e5706acf89ff21f22ca8004ddc7f9b43089 (patch)
tree845fd4f69308dc11ca6c54cc9ed4be62cb4f471c /src/Wallabag/CoreBundle/Tests
parent82899c040258896bff540080602e93aa49a71ae8 (diff)
downloadwallabag-fc031e5706acf89ff21f22ca8004ddc7f9b43089.tar.gz
wallabag-fc031e5706acf89ff21f22ca8004ddc7f9b43089.tar.zst
wallabag-fc031e5706acf89ff21f22ca8004ddc7f9b43089.zip
Avoid multiple tag creation
When a new tag is created but not yet persisted, it can be duplicated. It could happen when multiple rules match the content and at least 2 of them should attach same new tag. Fix #1528
Diffstat (limited to 'src/Wallabag/CoreBundle/Tests')
-rw-r--r--src/Wallabag/CoreBundle/Tests/Helper/RuleBasedTaggerTest.php20
1 files changed, 20 insertions, 0 deletions
diff --git a/src/Wallabag/CoreBundle/Tests/Helper/RuleBasedTaggerTest.php b/src/Wallabag/CoreBundle/Tests/Helper/RuleBasedTaggerTest.php
index 37e137bf..70951d46 100644
--- a/src/Wallabag/CoreBundle/Tests/Helper/RuleBasedTaggerTest.php
+++ b/src/Wallabag/CoreBundle/Tests/Helper/RuleBasedTaggerTest.php
@@ -121,6 +121,26 @@ class RuleBasedTaggerTest extends \PHPUnit_Framework_TestCase
121 $this->assertSame($tag, $tags[0]); 121 $this->assertSame($tag, $tags[0]);
122 } 122 }
123 123
124 public function testSameTagWithDifferentfMatchingRules()
125 {
126 $taggingRule = $this->getTaggingRule('bla bla', array('hey'));
127 $otherTaggingRule = $this->getTaggingRule('rule as string', array('hey'));
128
129 $user = $this->getUser([$taggingRule, $otherTaggingRule]);
130 $entry = new Entry($user);
131
132 $this->rulerz
133 ->method('satisfies')
134 ->willReturn(true);
135
136 $this->tagger->tag($entry);
137
138 $this->assertFalse($entry->getTags()->isEmpty());
139
140 $tags = $entry->getTags();
141 $this->assertCount(1, $tags);
142 }
143
124 private function getUser(array $taggingRules = []) 144 private function getUser(array $taggingRules = [])
125 { 145 {
126 $user = new User(); 146 $user = new User();