diff options
author | Nicolas Lœuillet <nicolas@loeuillet.org> | 2015-12-28 13:37:13 +0100 |
---|---|---|
committer | Nicolas Lœuillet <nicolas@loeuillet.org> | 2015-12-28 13:37:13 +0100 |
commit | d25b8288216a09fa5cf7f40e614c133a6edd8a67 (patch) | |
tree | 1ef927c8180a9f9ff3cb54f774e72d87b166f0b2 /src/Wallabag/CoreBundle/Tests | |
parent | 82899c040258896bff540080602e93aa49a71ae8 (diff) | |
parent | e9fa8c40aaf1c4fc356057bc7b248ce80c0766b0 (diff) | |
download | wallabag-d25b8288216a09fa5cf7f40e614c133a6edd8a67.tar.gz wallabag-d25b8288216a09fa5cf7f40e614c133a6edd8a67.tar.zst wallabag-d25b8288216a09fa5cf7f40e614c133a6edd8a67.zip |
Merge pull request #1542 from wallabag/v2-avoid-duplicate-tag
v2 – Avoid multiple tag creation
Diffstat (limited to 'src/Wallabag/CoreBundle/Tests')
-rw-r--r-- | src/Wallabag/CoreBundle/Tests/Helper/RuleBasedTaggerTest.php | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/src/Wallabag/CoreBundle/Tests/Helper/RuleBasedTaggerTest.php b/src/Wallabag/CoreBundle/Tests/Helper/RuleBasedTaggerTest.php index 37e137bf..1de134b8 100644 --- a/src/Wallabag/CoreBundle/Tests/Helper/RuleBasedTaggerTest.php +++ b/src/Wallabag/CoreBundle/Tests/Helper/RuleBasedTaggerTest.php | |||
@@ -121,6 +121,52 @@ 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 | |||
144 | public function testTagAllEntriesForAUser() | ||
145 | { | ||
146 | $taggingRule = $this->getTaggingRule('bla bla', array('hey')); | ||
147 | |||
148 | $user = $this->getUser([$taggingRule]); | ||
149 | |||
150 | $this->rulerz | ||
151 | ->method('satisfies') | ||
152 | ->willReturn(true); | ||
153 | |||
154 | $this->rulerz | ||
155 | ->method('filter') | ||
156 | ->willReturn(array(new Entry($user), new Entry($user))); | ||
157 | |||
158 | $entries = $this->tagger->tagAllForUser($user); | ||
159 | |||
160 | $this->assertCount(2, $entries); | ||
161 | |||
162 | foreach ($entries as $entry) { | ||
163 | $tags = $entry->getTags(); | ||
164 | |||
165 | $this->assertCount(1, $tags); | ||
166 | $this->assertEquals('hey', $tags[0]->getLabel()); | ||
167 | } | ||
168 | } | ||
169 | |||
124 | private function getUser(array $taggingRules = []) | 170 | private function getUser(array $taggingRules = []) |
125 | { | 171 | { |
126 | $user = new User(); | 172 | $user = new User(); |