$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()
$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'));
$user = $this->getUser([$taggingRule]);
$entry = new Entry($user);
- $tag = new Tag($user);
+ $tag = new Tag();
+ $tag->setLabel('foo');
$this->rulerz
->expects($this->once())
$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);
$this->assertFalse($entry->getTags()->isEmpty());
$tags = $entry->getTags();
- $this->assertSame($tag, $tags[0]);
+ $this->assertSame($tag->getLabel(), $tags[0]->getLabel());
}
public function testSameTagWithDifferentfMatchingRules()