From c5c7f90a81d7a2082c7b6dad38c2a6dfdba8d016 Mon Sep 17 00:00:00 2001 From: Jeremy Benoist Date: Sun, 3 Jan 2016 10:32:56 +0100 Subject: Fix tag related test for Pocket --- src/Wallabag/ImportBundle/Import/PocketImport.php | 5 +++-- src/Wallabag/ImportBundle/Tests/Import/PocketImportTest.php | 4 +++- 2 files changed, 6 insertions(+), 3 deletions(-) (limited to 'src/Wallabag') diff --git a/src/Wallabag/ImportBundle/Import/PocketImport.php b/src/Wallabag/ImportBundle/Import/PocketImport.php index b1c5bb00..853ad135 100644 --- a/src/Wallabag/ImportBundle/Import/PocketImport.php +++ b/src/Wallabag/ImportBundle/Import/PocketImport.php @@ -184,13 +184,14 @@ class PocketImport implements ImportInterface $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(); diff --git a/src/Wallabag/ImportBundle/Tests/Import/PocketImportTest.php b/src/Wallabag/ImportBundle/Tests/Import/PocketImportTest.php index 6ee70db0..1fc2dfa6 100644 --- a/src/Wallabag/ImportBundle/Tests/Import/PocketImportTest.php +++ b/src/Wallabag/ImportBundle/Tests/Import/PocketImportTest.php @@ -260,7 +260,9 @@ class PocketImportTest extends \PHPUnit_Framework_TestCase ->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 -- cgit v1.2.3