diff options
Diffstat (limited to 'src/Wallabag/ImportBundle/Tests/Controller')
4 files changed, 0 insertions, 318 deletions
diff --git a/src/Wallabag/ImportBundle/Tests/Controller/ImportControllerTest.php b/src/Wallabag/ImportBundle/Tests/Controller/ImportControllerTest.php deleted file mode 100644 index 9f38fa82..00000000 --- a/src/Wallabag/ImportBundle/Tests/Controller/ImportControllerTest.php +++ /dev/null | |||
@@ -1,29 +0,0 @@ | |||
1 | <?php | ||
2 | |||
3 | namespace Wallabag\ImportBundle\Tests\Controller; | ||
4 | |||
5 | use Wallabag\CoreBundle\Tests\WallabagCoreTestCase; | ||
6 | |||
7 | class ImportControllerTest extends WallabagCoreTestCase | ||
8 | { | ||
9 | public function testLogin() | ||
10 | { | ||
11 | $client = $this->getClient(); | ||
12 | |||
13 | $client->request('GET', '/import/'); | ||
14 | |||
15 | $this->assertEquals(302, $client->getResponse()->getStatusCode()); | ||
16 | $this->assertContains('login', $client->getResponse()->headers->get('location')); | ||
17 | } | ||
18 | |||
19 | public function testImportList() | ||
20 | { | ||
21 | $this->logInAs('admin'); | ||
22 | $client = $this->getClient(); | ||
23 | |||
24 | $crawler = $client->request('GET', '/import/'); | ||
25 | |||
26 | $this->assertEquals(200, $client->getResponse()->getStatusCode()); | ||
27 | $this->assertEquals(3, $crawler->filter('blockquote')->count()); | ||
28 | } | ||
29 | } | ||
diff --git a/src/Wallabag/ImportBundle/Tests/Controller/PocketControllerTest.php b/src/Wallabag/ImportBundle/Tests/Controller/PocketControllerTest.php deleted file mode 100644 index 403fe9b0..00000000 --- a/src/Wallabag/ImportBundle/Tests/Controller/PocketControllerTest.php +++ /dev/null | |||
@@ -1,65 +0,0 @@ | |||
1 | <?php | ||
2 | |||
3 | namespace Wallabag\ImportBundle\Tests\Controller; | ||
4 | |||
5 | use Wallabag\CoreBundle\Tests\WallabagCoreTestCase; | ||
6 | |||
7 | class PocketControllerTest extends WallabagCoreTestCase | ||
8 | { | ||
9 | public function testImportPocket() | ||
10 | { | ||
11 | $this->logInAs('admin'); | ||
12 | $client = $this->getClient(); | ||
13 | |||
14 | $crawler = $client->request('GET', '/import/pocket'); | ||
15 | |||
16 | $this->assertEquals(200, $client->getResponse()->getStatusCode()); | ||
17 | $this->assertEquals(1, $crawler->filter('button[type=submit]')->count()); | ||
18 | } | ||
19 | |||
20 | public function testImportPocketAuthBadToken() | ||
21 | { | ||
22 | $this->logInAs('admin'); | ||
23 | $client = $this->getClient(); | ||
24 | |||
25 | $crawler = $client->request('GET', '/import/pocket/auth'); | ||
26 | |||
27 | $this->assertEquals(302, $client->getResponse()->getStatusCode()); | ||
28 | } | ||
29 | |||
30 | public function testImportPocketAuth() | ||
31 | { | ||
32 | $this->markTestSkipped('PocketImport: Find a way to properly mock a service.'); | ||
33 | |||
34 | $this->logInAs('admin'); | ||
35 | $client = $this->getClient(); | ||
36 | |||
37 | $pocketImport = $this->getMockBuilder('Wallabag\ImportBundle\Import\PocketImport') | ||
38 | ->disableOriginalConstructor() | ||
39 | ->getMock(); | ||
40 | |||
41 | $pocketImport | ||
42 | ->expects($this->once()) | ||
43 | ->method('getRequestToken') | ||
44 | ->willReturn('token'); | ||
45 | |||
46 | $client->getContainer()->set('wallabag_import.pocket.import', $pocketImport); | ||
47 | |||
48 | $crawler = $client->request('GET', '/import/pocket/auth'); | ||
49 | |||
50 | $this->assertEquals(301, $client->getResponse()->getStatusCode()); | ||
51 | $this->assertContains('getpocket.com/auth/authorize', $client->getResponse()->headers->get('location')); | ||
52 | } | ||
53 | |||
54 | public function testImportPocketCallbackWithBadToken() | ||
55 | { | ||
56 | $this->logInAs('admin'); | ||
57 | $client = $this->getClient(); | ||
58 | |||
59 | $crawler = $client->request('GET', '/import/pocket/callback'); | ||
60 | |||
61 | $this->assertEquals(302, $client->getResponse()->getStatusCode()); | ||
62 | $this->assertContains('import/pocket', $client->getResponse()->headers->get('location')); | ||
63 | $this->assertEquals('flashes.import.notice.failed', $client->getContainer()->get('session')->getFlashBag()->peek('notice')[0]); | ||
64 | } | ||
65 | } | ||
diff --git a/src/Wallabag/ImportBundle/Tests/Controller/WallabagV1ControllerTest.php b/src/Wallabag/ImportBundle/Tests/Controller/WallabagV1ControllerTest.php deleted file mode 100644 index f7de3fef..00000000 --- a/src/Wallabag/ImportBundle/Tests/Controller/WallabagV1ControllerTest.php +++ /dev/null | |||
@@ -1,129 +0,0 @@ | |||
1 | <?php | ||
2 | |||
3 | namespace Wallabag\ImportBundle\Tests\Controller; | ||
4 | |||
5 | use Wallabag\CoreBundle\Tests\WallabagCoreTestCase; | ||
6 | use Symfony\Component\HttpFoundation\File\UploadedFile; | ||
7 | |||
8 | class WallabagV1ControllerTest extends WallabagCoreTestCase | ||
9 | { | ||
10 | public function testImportWallabag() | ||
11 | { | ||
12 | $this->logInAs('admin'); | ||
13 | $client = $this->getClient(); | ||
14 | |||
15 | $crawler = $client->request('GET', '/import/wallabag-v1'); | ||
16 | |||
17 | $this->assertEquals(200, $client->getResponse()->getStatusCode()); | ||
18 | $this->assertEquals(1, $crawler->filter('form[name=upload_import_file] > button[type=submit]')->count()); | ||
19 | $this->assertEquals(1, $crawler->filter('input[type=file]')->count()); | ||
20 | } | ||
21 | |||
22 | public function testImportWallabagWithFile() | ||
23 | { | ||
24 | $this->logInAs('admin'); | ||
25 | $client = $this->getClient(); | ||
26 | |||
27 | $crawler = $client->request('GET', '/import/wallabag-v1'); | ||
28 | $form = $crawler->filter('form[name=upload_import_file] > button[type=submit]')->form(); | ||
29 | |||
30 | $file = new UploadedFile(__DIR__.'/../fixtures/wallabag-v1.json', 'wallabag-v1.json'); | ||
31 | |||
32 | $data = [ | ||
33 | 'upload_import_file[file]' => $file, | ||
34 | ]; | ||
35 | |||
36 | $client->submit($form, $data); | ||
37 | |||
38 | $this->assertEquals(302, $client->getResponse()->getStatusCode()); | ||
39 | |||
40 | $crawler = $client->followRedirect(); | ||
41 | |||
42 | $content = $client->getContainer() | ||
43 | ->get('doctrine.orm.entity_manager') | ||
44 | ->getRepository('WallabagCoreBundle:Entry') | ||
45 | ->findByUrlAndUserId( | ||
46 | 'http://www.framablog.org/index.php/post/2014/02/05/Framabag-service-libre-gratuit-interview-developpeur', | ||
47 | $this->getLoggedInUserId() | ||
48 | ); | ||
49 | |||
50 | $tag = $client->getContainer() | ||
51 | ->get('doctrine.orm.entity_manager') | ||
52 | ->getRepository('WallabagCoreBundle:Tag') | ||
53 | ->findOneByLabel('Framabag'); | ||
54 | |||
55 | $this->assertTrue($content->getTags()->contains($tag)); | ||
56 | |||
57 | $this->assertGreaterThan(1, $body = $crawler->filter('body')->extract(['_text'])); | ||
58 | $this->assertContains('flashes.import.notice.summary', $body[0]); | ||
59 | } | ||
60 | |||
61 | public function testImportWallabagWithFileAndMarkAllAsRead() | ||
62 | { | ||
63 | $this->logInAs('admin'); | ||
64 | $client = $this->getClient(); | ||
65 | |||
66 | $crawler = $client->request('GET', '/import/wallabag-v1'); | ||
67 | $form = $crawler->filter('form[name=upload_import_file] > button[type=submit]')->form(); | ||
68 | |||
69 | $file = new UploadedFile(__DIR__.'/../fixtures/wallabag-v1-read.json', 'wallabag-v1-read.json'); | ||
70 | |||
71 | $data = [ | ||
72 | 'upload_import_file[file]' => $file, | ||
73 | 'upload_import_file[mark_as_read]' => 1, | ||
74 | ]; | ||
75 | |||
76 | $client->submit($form, $data); | ||
77 | |||
78 | $this->assertEquals(302, $client->getResponse()->getStatusCode()); | ||
79 | |||
80 | $crawler = $client->followRedirect(); | ||
81 | |||
82 | $content1 = $client->getContainer() | ||
83 | ->get('doctrine.orm.entity_manager') | ||
84 | ->getRepository('WallabagCoreBundle:Entry') | ||
85 | ->findByUrlAndUserId( | ||
86 | 'http://gilbert.pellegrom.me/recreating-the-square-slider', | ||
87 | $this->getLoggedInUserId() | ||
88 | ); | ||
89 | |||
90 | $this->assertTrue($content1->isArchived()); | ||
91 | |||
92 | $content2 = $client->getContainer() | ||
93 | ->get('doctrine.orm.entity_manager') | ||
94 | ->getRepository('WallabagCoreBundle:Entry') | ||
95 | ->findByUrlAndUserId( | ||
96 | 'https://www.wallabag.org/features/', | ||
97 | $this->getLoggedInUserId() | ||
98 | ); | ||
99 | |||
100 | $this->assertTrue($content2->isArchived()); | ||
101 | |||
102 | $this->assertGreaterThan(1, $body = $crawler->filter('body')->extract(['_text'])); | ||
103 | $this->assertContains('flashes.import.notice.summary', $body[0]); | ||
104 | } | ||
105 | |||
106 | public function testImportWallabagWithEmptyFile() | ||
107 | { | ||
108 | $this->logInAs('admin'); | ||
109 | $client = $this->getClient(); | ||
110 | |||
111 | $crawler = $client->request('GET', '/import/wallabag-v1'); | ||
112 | $form = $crawler->filter('form[name=upload_import_file] > button[type=submit]')->form(); | ||
113 | |||
114 | $file = new UploadedFile(__DIR__.'/../fixtures/test.txt', 'test.txt'); | ||
115 | |||
116 | $data = [ | ||
117 | 'upload_import_file[file]' => $file, | ||
118 | ]; | ||
119 | |||
120 | $client->submit($form, $data); | ||
121 | |||
122 | $this->assertEquals(302, $client->getResponse()->getStatusCode()); | ||
123 | |||
124 | $crawler = $client->followRedirect(); | ||
125 | |||
126 | $this->assertGreaterThan(1, $body = $crawler->filter('body')->extract(['_text'])); | ||
127 | $this->assertContains('flashes.import.notice.failed', $body[0]); | ||
128 | } | ||
129 | } | ||
diff --git a/src/Wallabag/ImportBundle/Tests/Controller/WallabagV2ControllerTest.php b/src/Wallabag/ImportBundle/Tests/Controller/WallabagV2ControllerTest.php deleted file mode 100644 index 15251ae7..00000000 --- a/src/Wallabag/ImportBundle/Tests/Controller/WallabagV2ControllerTest.php +++ /dev/null | |||
@@ -1,95 +0,0 @@ | |||
1 | <?php | ||
2 | |||
3 | namespace Wallabag\ImportBundle\Tests\Controller; | ||
4 | |||
5 | use Wallabag\CoreBundle\Tests\WallabagCoreTestCase; | ||
6 | use Symfony\Component\HttpFoundation\File\UploadedFile; | ||
7 | |||
8 | class WallabagV2ControllerTest extends WallabagCoreTestCase | ||
9 | { | ||
10 | public function testImportWallabag() | ||
11 | { | ||
12 | $this->logInAs('admin'); | ||
13 | $client = $this->getClient(); | ||
14 | |||
15 | $crawler = $client->request('GET', '/import/wallabag-v2'); | ||
16 | |||
17 | $this->assertEquals(200, $client->getResponse()->getStatusCode()); | ||
18 | $this->assertEquals(1, $crawler->filter('form[name=upload_import_file] > button[type=submit]')->count()); | ||
19 | $this->assertEquals(1, $crawler->filter('input[type=file]')->count()); | ||
20 | } | ||
21 | |||
22 | public function testImportWallabagWithFile() | ||
23 | { | ||
24 | $this->logInAs('admin'); | ||
25 | $client = $this->getClient(); | ||
26 | |||
27 | $crawler = $client->request('GET', '/import/wallabag-v2'); | ||
28 | $form = $crawler->filter('form[name=upload_import_file] > button[type=submit]')->form(); | ||
29 | |||
30 | $file = new UploadedFile(__DIR__.'/../fixtures/wallabag-v2.json', 'wallabag-v2.json'); | ||
31 | |||
32 | $data = [ | ||
33 | 'upload_import_file[file]' => $file, | ||
34 | ]; | ||
35 | |||
36 | $client->submit($form, $data); | ||
37 | |||
38 | $this->assertEquals(302, $client->getResponse()->getStatusCode()); | ||
39 | |||
40 | $crawler = $client->followRedirect(); | ||
41 | |||
42 | $this->assertGreaterThan(1, $body = $crawler->filter('body')->extract(['_text'])); | ||
43 | $this->assertContains('flashes.import.notice.summary', $body[0]); | ||
44 | |||
45 | $content = $client->getContainer() | ||
46 | ->get('doctrine.orm.entity_manager') | ||
47 | ->getRepository('WallabagCoreBundle:Entry') | ||
48 | ->findByUrlAndUserId( | ||
49 | 'http://www.liberation.fr/planete/2015/10/26/refugies-l-ue-va-creer-100-000-places-d-accueil-dans-les-balkans_1408867', | ||
50 | $this->getLoggedInUserId() | ||
51 | ); | ||
52 | |||
53 | $this->assertEmpty($content->getMimetype()); | ||
54 | $this->assertEmpty($content->getPreviewPicture()); | ||
55 | $this->assertEmpty($content->getLanguage()); | ||
56 | $this->assertEquals(0, count($content->getTags())); | ||
57 | |||
58 | $content = $client->getContainer() | ||
59 | ->get('doctrine.orm.entity_manager') | ||
60 | ->getRepository('WallabagCoreBundle:Entry') | ||
61 | ->findByUrlAndUserId( | ||
62 | 'https://www.mediapart.fr/', | ||
63 | $this->getLoggedInUserId() | ||
64 | ); | ||
65 | |||
66 | $this->assertNotEmpty($content->getMimetype()); | ||
67 | $this->assertNotEmpty($content->getPreviewPicture()); | ||
68 | $this->assertNotEmpty($content->getLanguage()); | ||
69 | $this->assertEquals(2, count($content->getTags())); | ||
70 | } | ||
71 | |||
72 | public function testImportWallabagWithEmptyFile() | ||
73 | { | ||
74 | $this->logInAs('admin'); | ||
75 | $client = $this->getClient(); | ||
76 | |||
77 | $crawler = $client->request('GET', '/import/wallabag-v2'); | ||
78 | $form = $crawler->filter('form[name=upload_import_file] > button[type=submit]')->form(); | ||
79 | |||
80 | $file = new UploadedFile(__DIR__.'/../fixtures/test.txt', 'test.txt'); | ||
81 | |||
82 | $data = [ | ||
83 | 'upload_import_file[file]' => $file, | ||
84 | ]; | ||
85 | |||
86 | $client->submit($form, $data); | ||
87 | |||
88 | $this->assertEquals(302, $client->getResponse()->getStatusCode()); | ||
89 | |||
90 | $crawler = $client->followRedirect(); | ||
91 | |||
92 | $this->assertGreaterThan(1, $body = $crawler->filter('body')->extract(['_text'])); | ||
93 | $this->assertContains('flashes.import.notice.failed', $body[0]); | ||
94 | } | ||
95 | } | ||