aboutsummaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
authorJeremy Benoist <jeremy.benoist@gmail.com>2015-12-27 23:48:57 +0100
committerJeremy Benoist <jeremy.benoist@gmail.com>2015-12-28 13:20:48 +0100
commite9fa8c40aaf1c4fc356057bc7b248ce80c0766b0 (patch)
tree1ef927c8180a9f9ff3cb54f774e72d87b166f0b2 /src
parentfc031e5706acf89ff21f22ca8004ddc7f9b43089 (diff)
downloadwallabag-e9fa8c40aaf1c4fc356057bc7b248ce80c0766b0.tar.gz
wallabag-e9fa8c40aaf1c4fc356057bc7b248ce80c0766b0.tar.zst
wallabag-e9fa8c40aaf1c4fc356057bc7b248ce80c0766b0.zip
Add test on tagAllForUser
And fix multiplication of entries returned by `tagAllForUser`.
Diffstat (limited to 'src')
-rw-r--r--src/Wallabag/CoreBundle/Helper/RuleBasedTagger.php1
-rw-r--r--src/Wallabag/CoreBundle/Tests/Helper/RuleBasedTaggerTest.php26
2 files changed, 26 insertions, 1 deletions
diff --git a/src/Wallabag/CoreBundle/Helper/RuleBasedTagger.php b/src/Wallabag/CoreBundle/Helper/RuleBasedTagger.php
index fb2d1f87..41ef25b8 100644
--- a/src/Wallabag/CoreBundle/Helper/RuleBasedTagger.php
+++ b/src/Wallabag/CoreBundle/Helper/RuleBasedTagger.php
@@ -65,7 +65,6 @@ class RuleBasedTagger
65 $tag = $this->getTag($user, $label); 65 $tag = $this->getTag($user, $label);
66 66
67 $entry->addTag($tag); 67 $entry->addTag($tag);
68 $entries[] = $entry;
69 } 68 }
70 } 69 }
71 } 70 }
diff --git a/src/Wallabag/CoreBundle/Tests/Helper/RuleBasedTaggerTest.php b/src/Wallabag/CoreBundle/Tests/Helper/RuleBasedTaggerTest.php
index 70951d46..1de134b8 100644
--- a/src/Wallabag/CoreBundle/Tests/Helper/RuleBasedTaggerTest.php
+++ b/src/Wallabag/CoreBundle/Tests/Helper/RuleBasedTaggerTest.php
@@ -141,6 +141,32 @@ class RuleBasedTaggerTest extends \PHPUnit_Framework_TestCase
141 $this->assertCount(1, $tags); 141 $this->assertCount(1, $tags);
142 } 142 }
143 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
144 private function getUser(array $taggingRules = []) 170 private function getUser(array $taggingRules = [])
145 { 171 {
146 $user = new User(); 172 $user = new User();