mirror of
https://github.com/wallabag/wallabag.git
synced 2024-12-17 02:39:24 +01:00
Add test on tagAllForUser
And fix multiplication of entries returned by `tagAllForUser`.
This commit is contained in:
parent
fc031e5706
commit
e9fa8c40aa
@ -65,7 +65,6 @@ class RuleBasedTagger
|
||||
$tag = $this->getTag($user, $label);
|
||||
|
||||
$entry->addTag($tag);
|
||||
$entries[] = $entry;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -141,6 +141,32 @@ class RuleBasedTaggerTest extends \PHPUnit_Framework_TestCase
|
||||
$this->assertCount(1, $tags);
|
||||
}
|
||||
|
||||
public function testTagAllEntriesForAUser()
|
||||
{
|
||||
$taggingRule = $this->getTaggingRule('bla bla', array('hey'));
|
||||
|
||||
$user = $this->getUser([$taggingRule]);
|
||||
|
||||
$this->rulerz
|
||||
->method('satisfies')
|
||||
->willReturn(true);
|
||||
|
||||
$this->rulerz
|
||||
->method('filter')
|
||||
->willReturn(array(new Entry($user), new Entry($user)));
|
||||
|
||||
$entries = $this->tagger->tagAllForUser($user);
|
||||
|
||||
$this->assertCount(2, $entries);
|
||||
|
||||
foreach ($entries as $entry) {
|
||||
$tags = $entry->getTags();
|
||||
|
||||
$this->assertCount(1, $tags);
|
||||
$this->assertEquals('hey', $tags[0]->getLabel());
|
||||
}
|
||||
}
|
||||
|
||||
private function getUser(array $taggingRules = [])
|
||||
{
|
||||
$user = new User();
|
||||
|
Loading…
Reference in New Issue
Block a user