From c5c7f90a81d7a2082c7b6dad38c2a6dfdba8d016 Mon Sep 17 00:00:00 2001 From: Jeremy Benoist Date: Sun, 3 Jan 2016 10:32:56 +0100 Subject: [PATCH] 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(-) diff --git a/src/Wallabag/ImportBundle/Import/PocketImport.php b/src/Wallabag/ImportBundle/Import/PocketImport.php index b1c5bb001..853ad135a 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 6ee70db04..1fc2dfa6c 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