$label = trim($tag['tag']);
$tagEntity = $this->em
->getRepository('WallabagCoreBundle:Tag')
- ->findOneByLabelAndUserId($label, $this->user->getId());
+ ->findOneByLabel($label);
if (is_object($tagEntity)) {
$entry->addTag($tagEntity);
} else {
- $newTag = new Tag($this->user);
+ $newTag = new Tag();
$newTag->setLabel($label);
+
$entry->addTag($newTag);
}
$this->em->flush();
->getMock();
$tagRepo->expects($this->exactly(2))
- ->method('findOneByLabelAndUserId')
+ // the method `findOneByLabel` doesn't exist, EntityRepository will then call `_call` method
+ // to magically call the `findOneBy` with ['label' => 'foo']
+ ->method('__call')
->will($this->onConsecutiveCalls(false, $tag));
$this->em