X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;ds=sidebyside;f=src%2FWallabag%2FCoreBundle%2FTests%2FHelper%2FRuleBasedTaggerTest.php;h=e9025b450df58b16b1cf97010ae561e0ef96cdce;hb=f2e5fdc3666a2a6525b4202ab48df05efeebaf5c;hp=1de134b8a4bee5d0dc05101c54ae83acdda95d71;hpb=d25b8288216a09fa5cf7f40e614c133a6edd8a67;p=github%2Fwallabag%2Fwallabag.git diff --git a/src/Wallabag/CoreBundle/Tests/Helper/RuleBasedTaggerTest.php b/src/Wallabag/CoreBundle/Tests/Helper/RuleBasedTaggerTest.php index 1de134b8..e9025b45 100644 --- a/src/Wallabag/CoreBundle/Tests/Helper/RuleBasedTaggerTest.php +++ b/src/Wallabag/CoreBundle/Tests/Helper/RuleBasedTaggerTest.php @@ -6,8 +6,8 @@ use Wallabag\CoreBundle\Entity\Config; use Wallabag\CoreBundle\Entity\Entry; use Wallabag\CoreBundle\Entity\Tag; use Wallabag\CoreBundle\Entity\TaggingRule; -use Wallabag\UserBundle\Entity\User; use Wallabag\CoreBundle\Helper\RuleBasedTagger; +use Wallabag\UserBundle\Entity\User; class RuleBasedTaggerTest extends \PHPUnit_Framework_TestCase { @@ -36,7 +36,7 @@ class RuleBasedTaggerTest extends \PHPUnit_Framework_TestCase public function testTagWithNoMatchingRule() { - $taggingRule = $this->getTaggingRule('rule as string', array('foo', 'bar')); + $taggingRule = $this->getTaggingRule('rule as string', ['foo', 'bar']); $user = $this->getUser([$taggingRule]); $entry = new Entry($user); @@ -53,7 +53,7 @@ class RuleBasedTaggerTest extends \PHPUnit_Framework_TestCase public function testTagWithAMatchingRule() { - $taggingRule = $this->getTaggingRule('rule as string', array('foo', 'bar')); + $taggingRule = $this->getTaggingRule('rule as string', ['foo', 'bar']); $user = $this->getUser([$taggingRule]); $entry = new Entry($user); @@ -69,15 +69,13 @@ class RuleBasedTaggerTest extends \PHPUnit_Framework_TestCase $tags = $entry->getTags(); $this->assertSame('foo', $tags[0]->getLabel()); - $this->assertSame($user, $tags[0]->getUser()); $this->assertSame('bar', $tags[1]->getLabel()); - $this->assertSame($user, $tags[1]->getUser()); } public function testTagWithAMixOfMatchingRules() { - $taggingRule = $this->getTaggingRule('bla bla', array('hey')); - $otherTaggingRule = $this->getTaggingRule('rule as string', array('foo')); + $taggingRule = $this->getTaggingRule('bla bla', ['hey']); + $otherTaggingRule = $this->getTaggingRule('rule as string', ['foo']); $user = $this->getUser([$taggingRule, $otherTaggingRule]); $entry = new Entry($user); @@ -92,15 +90,14 @@ class RuleBasedTaggerTest extends \PHPUnit_Framework_TestCase $tags = $entry->getTags(); $this->assertSame('foo', $tags[0]->getLabel()); - $this->assertSame($user, $tags[0]->getUser()); } public function testWhenTheTagExists() { - $taggingRule = $this->getTaggingRule('rule as string', array('foo')); + $taggingRule = $this->getTaggingRule('rule as string', ['foo']); $user = $this->getUser([$taggingRule]); $entry = new Entry($user); - $tag = new Tag($user); + $tag = new Tag(); $this->rulerz ->expects($this->once()) @@ -110,7 +107,9 @@ class RuleBasedTaggerTest extends \PHPUnit_Framework_TestCase $this->tagRepository ->expects($this->once()) - ->method('findOneByLabelAndUserId') + // the method `findOneByLabel` doesn't exist, EntityRepository will then call `_call` method + // to magically call the `findOneBy` with ['label' => 'foo'] + ->method('__call') ->willReturn($tag); $this->tagger->tag($entry); @@ -123,8 +122,8 @@ class RuleBasedTaggerTest extends \PHPUnit_Framework_TestCase public function testSameTagWithDifferentfMatchingRules() { - $taggingRule = $this->getTaggingRule('bla bla', array('hey')); - $otherTaggingRule = $this->getTaggingRule('rule as string', array('hey')); + $taggingRule = $this->getTaggingRule('bla bla', ['hey']); + $otherTaggingRule = $this->getTaggingRule('rule as string', ['hey']); $user = $this->getUser([$taggingRule, $otherTaggingRule]); $entry = new Entry($user); @@ -143,7 +142,7 @@ class RuleBasedTaggerTest extends \PHPUnit_Framework_TestCase public function testTagAllEntriesForAUser() { - $taggingRule = $this->getTaggingRule('bla bla', array('hey')); + $taggingRule = $this->getTaggingRule('bla bla', ['hey']); $user = $this->getUser([$taggingRule]); @@ -153,7 +152,7 @@ class RuleBasedTaggerTest extends \PHPUnit_Framework_TestCase $this->rulerz ->method('filter') - ->willReturn(array(new Entry($user), new Entry($user))); + ->willReturn([new Entry($user), new Entry($user)]); $entries = $this->tagger->tagAllForUser($user);