mirror of
https://github.com/wallabag/wallabag.git
synced 2024-11-26 19:11:07 +00:00
Add test on tagAllForUser
And fix multiplication of entries returned by `tagAllForUser`.
This commit is contained in:
parent
fc031e5706
commit
e9fa8c40aa
2 changed files with 26 additions and 1 deletions
|
@ -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 a new issue