From 4d0ec0e72108ff47952906e5d968a7c3eb0a76f9 Mon Sep 17 00:00:00 2001 From: Jeremy Benoist Date: Sun, 27 Mar 2016 20:35:56 +0200 Subject: Fix some Scrutinizer issues --- .../Tests/Controller/PocketControllerTest.php | 23 ++++++++++++++++++++++ .../Tests/Import/WallabagV1ImportTest.php | 8 +++++++- 2 files changed, 30 insertions(+), 1 deletion(-) (limited to 'src/Wallabag/ImportBundle/Tests') diff --git a/src/Wallabag/ImportBundle/Tests/Controller/PocketControllerTest.php b/src/Wallabag/ImportBundle/Tests/Controller/PocketControllerTest.php index 174641fd..403fe9b0 100644 --- a/src/Wallabag/ImportBundle/Tests/Controller/PocketControllerTest.php +++ b/src/Wallabag/ImportBundle/Tests/Controller/PocketControllerTest.php @@ -17,11 +17,34 @@ class PocketControllerTest extends WallabagCoreTestCase $this->assertEquals(1, $crawler->filter('button[type=submit]')->count()); } + public function testImportPocketAuthBadToken() + { + $this->logInAs('admin'); + $client = $this->getClient(); + + $crawler = $client->request('GET', '/import/pocket/auth'); + + $this->assertEquals(302, $client->getResponse()->getStatusCode()); + } + public function testImportPocketAuth() { + $this->markTestSkipped('PocketImport: Find a way to properly mock a service.'); + $this->logInAs('admin'); $client = $this->getClient(); + $pocketImport = $this->getMockBuilder('Wallabag\ImportBundle\Import\PocketImport') + ->disableOriginalConstructor() + ->getMock(); + + $pocketImport + ->expects($this->once()) + ->method('getRequestToken') + ->willReturn('token'); + + $client->getContainer()->set('wallabag_import.pocket.import', $pocketImport); + $crawler = $client->request('GET', '/import/pocket/auth'); $this->assertEquals(301, $client->getResponse()->getStatusCode()); diff --git a/src/Wallabag/ImportBundle/Tests/Import/WallabagV1ImportTest.php b/src/Wallabag/ImportBundle/Tests/Import/WallabagV1ImportTest.php index 496cf2d3..540eb7da 100644 --- a/src/Wallabag/ImportBundle/Tests/Import/WallabagV1ImportTest.php +++ b/src/Wallabag/ImportBundle/Tests/Import/WallabagV1ImportTest.php @@ -3,6 +3,7 @@ namespace Wallabag\ImportBundle\Tests\Import; use Wallabag\UserBundle\Entity\User; +use Wallabag\CoreBundle\Entity\Entry; use Wallabag\ImportBundle\Import\WallabagV1Import; use Monolog\Logger; use Monolog\Handler\TestHandler; @@ -71,7 +72,7 @@ class WallabagV1ImportTest extends \PHPUnit_Framework_TestCase ->getMock(); $this->contentProxy - ->expects($this->once()) + ->expects($this->exactly(3)) ->method('updateEntry') ->willReturn($entry); @@ -99,6 +100,11 @@ class WallabagV1ImportTest extends \PHPUnit_Framework_TestCase ->method('getRepository') ->willReturn($entryRepo); + $this->contentProxy + ->expects($this->exactly(3)) + ->method('updateEntry') + ->willReturn(new Entry($this->user)); + // check that every entry persisted are archived $this->em ->expects($this->any()) -- cgit v1.2.3