aboutsummaryrefslogtreecommitdiffhomepage
path: root/tests/Wallabag/ImportBundle
diff options
context:
space:
mode:
Diffstat (limited to 'tests/Wallabag/ImportBundle')
-rw-r--r--tests/Wallabag/ImportBundle/Controller/PocketControllerTest.php57
-rw-r--r--tests/Wallabag/ImportBundle/fixtures/unnamed.pngbin0 -> 3688 bytes
2 files changed, 50 insertions, 7 deletions
diff --git a/tests/Wallabag/ImportBundle/Controller/PocketControllerTest.php b/tests/Wallabag/ImportBundle/Controller/PocketControllerTest.php
index 6aaf1b57..e0e61df8 100644
--- a/tests/Wallabag/ImportBundle/Controller/PocketControllerTest.php
+++ b/tests/Wallabag/ImportBundle/Controller/PocketControllerTest.php
@@ -22,15 +22,13 @@ class PocketControllerTest extends WallabagCoreTestCase
22 $this->logInAs('admin'); 22 $this->logInAs('admin');
23 $client = $this->getClient(); 23 $client = $this->getClient();
24 24
25 $crawler = $client->request('GET', '/import/pocket/auth'); 25 $client->request('GET', '/import/pocket/auth');
26 26
27 $this->assertEquals(302, $client->getResponse()->getStatusCode()); 27 $this->assertEquals(302, $client->getResponse()->getStatusCode());
28 } 28 }
29 29
30 public function testImportPocketAuth() 30 public function testImportPocketAuth()
31 { 31 {
32 $this->markTestSkipped('PocketImport: Find a way to properly mock a service.');
33
34 $this->logInAs('admin'); 32 $this->logInAs('admin');
35 $client = $this->getClient(); 33 $client = $this->getClient();
36 34
@@ -43,9 +41,9 @@ class PocketControllerTest extends WallabagCoreTestCase
43 ->method('getRequestToken') 41 ->method('getRequestToken')
44 ->willReturn('token'); 42 ->willReturn('token');
45 43
46 $client->getContainer()->set('wallabag_import.pocket.import', $pocketImport); 44 static::$kernel->getContainer()->set('wallabag_import.pocket.import', $pocketImport);
47 45
48 $crawler = $client->request('GET', '/import/pocket/auth'); 46 $client->request('GET', '/import/pocket/auth');
49 47
50 $this->assertEquals(301, $client->getResponse()->getStatusCode()); 48 $this->assertEquals(301, $client->getResponse()->getStatusCode());
51 $this->assertContains('getpocket.com/auth/authorize', $client->getResponse()->headers->get('location')); 49 $this->assertContains('getpocket.com/auth/authorize', $client->getResponse()->headers->get('location'));
@@ -56,10 +54,55 @@ class PocketControllerTest extends WallabagCoreTestCase
56 $this->logInAs('admin'); 54 $this->logInAs('admin');
57 $client = $this->getClient(); 55 $client = $this->getClient();
58 56
59 $crawler = $client->request('GET', '/import/pocket/callback'); 57 $pocketImport = $this->getMockBuilder('Wallabag\ImportBundle\Import\PocketImport')
58 ->disableOriginalConstructor()
59 ->getMock();
60
61 $pocketImport
62 ->expects($this->once())
63 ->method('authorize')
64 ->willReturn(false);
65
66 static::$kernel->getContainer()->set('wallabag_import.pocket.import', $pocketImport);
67
68 $client->request('GET', '/import/pocket/callback');
60 69
61 $this->assertEquals(302, $client->getResponse()->getStatusCode()); 70 $this->assertEquals(302, $client->getResponse()->getStatusCode());
62 $this->assertContains('import/pocket', $client->getResponse()->headers->get('location')); 71 $this->assertContains('/', $client->getResponse()->headers->get('location'), 'Import is ok, redirect to homepage');
63 $this->assertEquals('flashes.import.notice.failed', $client->getContainer()->get('session')->getFlashBag()->peek('notice')[0]); 72 $this->assertEquals('flashes.import.notice.failed', $client->getContainer()->get('session')->getFlashBag()->peek('notice')[0]);
64 } 73 }
74
75 public function testImportPocketCallback()
76 {
77 $this->logInAs('admin');
78 $client = $this->getClient();
79
80 $pocketImport = $this->getMockBuilder('Wallabag\ImportBundle\Import\PocketImport')
81 ->disableOriginalConstructor()
82 ->getMock();
83
84 $pocketImport
85 ->expects($this->once())
86 ->method('authorize')
87 ->willReturn(true);
88
89 $pocketImport
90 ->expects($this->once())
91 ->method('setMarkAsRead')
92 ->with(false)
93 ->willReturn($pocketImport);
94
95 $pocketImport
96 ->expects($this->once())
97 ->method('import')
98 ->willReturn(true);
99
100 static::$kernel->getContainer()->set('wallabag_import.pocket.import', $pocketImport);
101
102 $client->request('GET', '/import/pocket/callback');
103
104 $this->assertEquals(302, $client->getResponse()->getStatusCode());
105 $this->assertContains('/', $client->getResponse()->headers->get('location'), 'Import is ok, redirect to homepage');
106 $this->assertEquals('flashes.import.notice.summary', $client->getContainer()->get('session')->getFlashBag()->peek('notice')[0]);
107 }
65} 108}
diff --git a/tests/Wallabag/ImportBundle/fixtures/unnamed.png b/tests/Wallabag/ImportBundle/fixtures/unnamed.png
new file mode 100644
index 00000000..e6dd9caa
--- /dev/null
+++ b/tests/Wallabag/ImportBundle/fixtures/unnamed.png
Binary files differ