diff options
author | Thomas Citharel <tcit@tcit.fr> | 2016-09-21 17:47:47 +0200 |
---|---|---|
committer | Jeremy Benoist <jeremy.benoist@gmail.com> | 2016-09-25 12:29:18 +0200 |
commit | 59201088b4fc13fd361238396f630dabd9bd1990 (patch) | |
tree | 2d4d5c2fbe7f007214c41f0c4ccba2f8d3d7ec8b /tests/Wallabag/ImportBundle/Controller | |
parent | f7c55b38122cc593c2b58bb6425fca9d243b055e (diff) | |
download | wallabag-59201088b4fc13fd361238396f630dabd9bd1990.tar.gz wallabag-59201088b4fc13fd361238396f630dabd9bd1990.tar.zst wallabag-59201088b4fc13fd361238396f630dabd9bd1990.zip |
bring chrome and firefox as separate imports
Diffstat (limited to 'tests/Wallabag/ImportBundle/Controller')
-rw-r--r-- | tests/Wallabag/ImportBundle/Controller/ChromeControllerTest.php | 149 | ||||
-rw-r--r-- | tests/Wallabag/ImportBundle/Controller/FirefoxControllerTest.php (renamed from tests/Wallabag/ImportBundle/Controller/BrowserControllerTest.php) | 96 | ||||
-rw-r--r-- | tests/Wallabag/ImportBundle/Controller/ImportControllerTest.php | 2 | ||||
-rw-r--r-- | tests/Wallabag/ImportBundle/Controller/ReadabilityControllerTest.php | 1 |
4 files changed, 213 insertions, 35 deletions
diff --git a/tests/Wallabag/ImportBundle/Controller/ChromeControllerTest.php b/tests/Wallabag/ImportBundle/Controller/ChromeControllerTest.php new file mode 100644 index 00000000..448e559f --- /dev/null +++ b/tests/Wallabag/ImportBundle/Controller/ChromeControllerTest.php | |||
@@ -0,0 +1,149 @@ | |||
1 | <?php | ||
2 | |||
3 | namespace Tests\Wallabag\ImportBundle\Controller; | ||
4 | |||
5 | use Tests\Wallabag\CoreBundle\WallabagCoreTestCase; | ||
6 | use Symfony\Component\HttpFoundation\File\UploadedFile; | ||
7 | |||
8 | class ChromeControllerTest extends WallabagCoreTestCase | ||
9 | { | ||
10 | public function testImportChrome() | ||
11 | { | ||
12 | $this->logInAs('admin'); | ||
13 | $client = $this->getClient(); | ||
14 | |||
15 | $crawler = $client->request('GET', '/import/chrome'); | ||
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 testImportChromeWithRabbitEnabled() | ||
23 | { | ||
24 | $this->logInAs('admin'); | ||
25 | $client = $this->getClient(); | ||
26 | |||
27 | $client->getContainer()->get('craue_config')->set('import_with_rabbitmq', 1); | ||
28 | |||
29 | $crawler = $client->request('GET', '/import/chrome'); | ||
30 | |||
31 | $this->assertEquals(200, $client->getResponse()->getStatusCode()); | ||
32 | $this->assertEquals(1, $crawler->filter('form[name=upload_import_file] > button[type=submit]')->count()); | ||
33 | $this->assertEquals(1, $crawler->filter('input[type=file]')->count()); | ||
34 | |||
35 | $client->getContainer()->get('craue_config')->set('import_with_rabbitmq', 0); | ||
36 | } | ||
37 | |||
38 | public function testImportChromeBadFile() | ||
39 | { | ||
40 | $this->logInAs('admin'); | ||
41 | $client = $this->getClient(); | ||
42 | |||
43 | $crawler = $client->request('GET', '/import/chrome'); | ||
44 | $form = $crawler->filter('form[name=upload_import_file] > button[type=submit]')->form(); | ||
45 | |||
46 | $data = [ | ||
47 | 'upload_import_file[file]' => '', | ||
48 | ]; | ||
49 | |||
50 | $client->submit($form, $data); | ||
51 | |||
52 | $this->assertEquals(200, $client->getResponse()->getStatusCode()); | ||
53 | } | ||
54 | |||
55 | public function testImportChromeWithRedisEnabled() | ||
56 | { | ||
57 | $this->logInAs('admin'); | ||
58 | $client = $this->getClient(); | ||
59 | $client->getContainer()->get('craue_config')->set('import_with_redis', 1); | ||
60 | |||
61 | $crawler = $client->request('GET', '/import/chrome'); | ||
62 | |||
63 | $this->assertEquals(200, $client->getResponse()->getStatusCode()); | ||
64 | $this->assertEquals(1, $crawler->filter('form[name=upload_import_file] > button[type=submit]')->count()); | ||
65 | $this->assertEquals(1, $crawler->filter('input[type=file]')->count()); | ||
66 | |||
67 | $form = $crawler->filter('form[name=upload_import_file] > button[type=submit]')->form(); | ||
68 | |||
69 | $file = new UploadedFile(__DIR__.'/../fixtures/chrome-bookmarks', 'Bookmarks'); | ||
70 | |||
71 | $data = [ | ||
72 | 'upload_import_file[file]' => $file, | ||
73 | ]; | ||
74 | |||
75 | $client->submit($form, $data); | ||
76 | |||
77 | $this->assertEquals(302, $client->getResponse()->getStatusCode()); | ||
78 | |||
79 | $crawler = $client->followRedirect(); | ||
80 | |||
81 | $this->assertGreaterThan(1, $body = $crawler->filter('body')->extract(['_text'])); | ||
82 | $this->assertContains('flashes.import.notice.summary', $body[0]); | ||
83 | |||
84 | $this->assertNotEmpty($client->getContainer()->get('wallabag_core.redis.client')->lpop('wallabag.import.chrome')); | ||
85 | |||
86 | $client->getContainer()->get('craue_config')->set('import_with_redis', 0); | ||
87 | } | ||
88 | |||
89 | public function testImportWallabagWithChromeFile() | ||
90 | { | ||
91 | $this->logInAs('admin'); | ||
92 | $client = $this->getClient(); | ||
93 | |||
94 | $crawler = $client->request('GET', '/import/chrome'); | ||
95 | $form = $crawler->filter('form[name=upload_import_file] > button[type=submit]')->form(); | ||
96 | |||
97 | $file = new UploadedFile(__DIR__.'/../fixtures/chrome-bookmarks', 'Bookmarks'); | ||
98 | |||
99 | $data = [ | ||
100 | 'upload_import_file[file]' => $file, | ||
101 | ]; | ||
102 | |||
103 | $client->submit($form, $data); | ||
104 | |||
105 | $this->assertEquals(302, $client->getResponse()->getStatusCode()); | ||
106 | |||
107 | $crawler = $client->followRedirect(); | ||
108 | |||
109 | $this->assertGreaterThan(1, $body = $crawler->filter('body')->extract(['_text'])); | ||
110 | $this->assertContains('flashes.import.notice.summary', $body[0]); | ||
111 | |||
112 | $content = $client->getContainer() | ||
113 | ->get('doctrine.orm.entity_manager') | ||
114 | ->getRepository('WallabagCoreBundle:Entry') | ||
115 | ->findByUrlAndUserId( | ||
116 | 'http://www.usinenouvelle.com/article/la-multiplication-des-chefs-de-projet-est-une-catastrophe-manageriale-majeure-affirme-le-sociologue-francois-dupuy.N307730', | ||
117 | $this->getLoggedInUserId() | ||
118 | ); | ||
119 | |||
120 | $this->assertEmpty($content->getMimetype()); | ||
121 | $this->assertNotEmpty($content->getPreviewPicture()); | ||
122 | $this->assertNotEmpty($content->getLanguage()); | ||
123 | $this->assertEquals(0, count($content->getTags())); | ||
124 | } | ||
125 | |||
126 | public function testImportWallabagWithEmptyFile() | ||
127 | { | ||
128 | $this->logInAs('admin'); | ||
129 | $client = $this->getClient(); | ||
130 | |||
131 | $crawler = $client->request('GET', '/import/chrome'); | ||
132 | $form = $crawler->filter('form[name=upload_import_file] > button[type=submit]')->form(); | ||
133 | |||
134 | $file = new UploadedFile(__DIR__.'/../fixtures/test.txt', 'test.txt'); | ||
135 | |||
136 | $data = [ | ||
137 | 'upload_import_file[file]' => $file, | ||
138 | ]; | ||
139 | |||
140 | $client->submit($form, $data); | ||
141 | |||
142 | $this->assertEquals(302, $client->getResponse()->getStatusCode()); | ||
143 | |||
144 | $crawler = $client->followRedirect(); | ||
145 | |||
146 | $this->assertGreaterThan(1, $body = $crawler->filter('body')->extract(['_text'])); | ||
147 | $this->assertContains('flashes.import.notice.failed', $body[0]); | ||
148 | } | ||
149 | } | ||
diff --git a/tests/Wallabag/ImportBundle/Controller/BrowserControllerTest.php b/tests/Wallabag/ImportBundle/Controller/FirefoxControllerTest.php index b686fcd9..2de0aa09 100644 --- a/tests/Wallabag/ImportBundle/Controller/BrowserControllerTest.php +++ b/tests/Wallabag/ImportBundle/Controller/FirefoxControllerTest.php | |||
@@ -5,26 +5,65 @@ namespace Tests\Wallabag\ImportBundle\Controller; | |||
5 | use Tests\Wallabag\CoreBundle\WallabagCoreTestCase; | 5 | use Tests\Wallabag\CoreBundle\WallabagCoreTestCase; |
6 | use Symfony\Component\HttpFoundation\File\UploadedFile; | 6 | use Symfony\Component\HttpFoundation\File\UploadedFile; |
7 | 7 | ||
8 | class BrowserControllerTest extends WallabagCoreTestCase | 8 | class FirefoxControllerTest extends WallabagCoreTestCase |
9 | { | 9 | { |
10 | public function testImportWallabag() | 10 | public function testImportFirefox() |
11 | { | 11 | { |
12 | $this->logInAs('admin'); | 12 | $this->logInAs('admin'); |
13 | $client = $this->getClient(); | 13 | $client = $this->getClient(); |
14 | 14 | ||
15 | $crawler = $client->request('GET', '/import/browser'); | 15 | $crawler = $client->request('GET', '/import/firefox'); |
16 | 16 | ||
17 | $this->assertEquals(200, $client->getResponse()->getStatusCode()); | 17 | $this->assertEquals(200, $client->getResponse()->getStatusCode()); |
18 | $this->assertEquals(1, $crawler->filter('form[name=upload_import_file] > button[type=submit]')->count()); | 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()); | 19 | $this->assertEquals(1, $crawler->filter('input[type=file]')->count()); |
20 | } | 20 | } |
21 | 21 | ||
22 | public function testImportWallabagWithFirefoxFile() | 22 | public function testImportFirefoxWithRabbitEnabled() |
23 | { | ||
24 | $this->logInAs('admin'); | ||
25 | $client = $this->getClient(); | ||
26 | |||
27 | $client->getContainer()->get('craue_config')->set('import_with_rabbitmq', 1); | ||
28 | |||
29 | $crawler = $client->request('GET', '/import/firefox'); | ||
30 | |||
31 | $this->assertEquals(200, $client->getResponse()->getStatusCode()); | ||
32 | $this->assertEquals(1, $crawler->filter('form[name=upload_import_file] > button[type=submit]')->count()); | ||
33 | $this->assertEquals(1, $crawler->filter('input[type=file]')->count()); | ||
34 | |||
35 | $client->getContainer()->get('craue_config')->set('import_with_rabbitmq', 0); | ||
36 | } | ||
37 | |||
38 | public function testImportFirefoxBadFile() | ||
23 | { | 39 | { |
24 | $this->logInAs('admin'); | 40 | $this->logInAs('admin'); |
25 | $client = $this->getClient(); | 41 | $client = $this->getClient(); |
26 | 42 | ||
27 | $crawler = $client->request('GET', '/import/browser'); | 43 | $crawler = $client->request('GET', '/import/firefox'); |
44 | $form = $crawler->filter('form[name=upload_import_file] > button[type=submit]')->form(); | ||
45 | |||
46 | $data = [ | ||
47 | 'upload_import_file[file]' => '', | ||
48 | ]; | ||
49 | |||
50 | $client->submit($form, $data); | ||
51 | |||
52 | $this->assertEquals(200, $client->getResponse()->getStatusCode()); | ||
53 | } | ||
54 | |||
55 | public function testImportFirefoxWithRedisEnabled() | ||
56 | { | ||
57 | $this->logInAs('admin'); | ||
58 | $client = $this->getClient(); | ||
59 | $client->getContainer()->get('craue_config')->set('import_with_redis', 1); | ||
60 | |||
61 | $crawler = $client->request('GET', '/import/firefox'); | ||
62 | |||
63 | $this->assertEquals(200, $client->getResponse()->getStatusCode()); | ||
64 | $this->assertEquals(1, $crawler->filter('form[name=upload_import_file] > button[type=submit]')->count()); | ||
65 | $this->assertEquals(1, $crawler->filter('input[type=file]')->count()); | ||
66 | |||
28 | $form = $crawler->filter('form[name=upload_import_file] > button[type=submit]')->form(); | 67 | $form = $crawler->filter('form[name=upload_import_file] > button[type=submit]')->form(); |
29 | 68 | ||
30 | $file = new UploadedFile(__DIR__.'/../fixtures/firefox-bookmarks.json', 'Bookmarks'); | 69 | $file = new UploadedFile(__DIR__.'/../fixtures/firefox-bookmarks.json', 'Bookmarks'); |
@@ -42,41 +81,20 @@ class BrowserControllerTest extends WallabagCoreTestCase | |||
42 | $this->assertGreaterThan(1, $body = $crawler->filter('body')->extract(['_text'])); | 81 | $this->assertGreaterThan(1, $body = $crawler->filter('body')->extract(['_text'])); |
43 | $this->assertContains('flashes.import.notice.summary', $body[0]); | 82 | $this->assertContains('flashes.import.notice.summary', $body[0]); |
44 | 83 | ||
45 | $content = $client->getContainer() | 84 | $this->assertNotEmpty($client->getContainer()->get('wallabag_core.redis.client')->lpop('wallabag.import.firefox')); |
46 | ->get('doctrine.orm.entity_manager') | ||
47 | ->getRepository('WallabagCoreBundle:Entry') | ||
48 | ->findByUrlAndUserId( | ||
49 | 'http://lexpansion.lexpress.fr/high-tech/orange-offre-un-meilleur-reseau-mobile-que-bouygues-et-sfr-free-derriere_1811554.html', | ||
50 | $this->getLoggedInUserId() | ||
51 | ); | ||
52 | |||
53 | $this->assertNotEmpty($content->getMimetype()); | ||
54 | $this->assertNotEmpty($content->getPreviewPicture()); | ||
55 | $this->assertNotEmpty($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 | 'http://stackoverflow.com/questions/15017163/parser-for-exported-bookmarks-html-file-of-google-chrome-and-mozilla-in-java', | ||
63 | $this->getLoggedInUserId() | ||
64 | ); | ||
65 | 85 | ||
66 | $this->assertNotEmpty($content->getMimetype()); | 86 | $client->getContainer()->get('craue_config')->set('import_with_redis', 0); |
67 | $this->assertNotEmpty($content->getPreviewPicture()); | ||
68 | $this->assertEmpty($content->getLanguage()); | ||
69 | } | 87 | } |
70 | 88 | ||
71 | public function testImportWallabagWithChromeFile() | 89 | public function testImportWallabagWithFirefoxFile() |
72 | { | 90 | { |
73 | $this->logInAs('admin'); | 91 | $this->logInAs('admin'); |
74 | $client = $this->getClient(); | 92 | $client = $this->getClient(); |
75 | 93 | ||
76 | $crawler = $client->request('GET', '/import/browser'); | 94 | $crawler = $client->request('GET', '/import/firefox'); |
77 | $form = $crawler->filter('form[name=upload_import_file] > button[type=submit]')->form(); | 95 | $form = $crawler->filter('form[name=upload_import_file] > button[type=submit]')->form(); |
78 | 96 | ||
79 | $file = new UploadedFile(__DIR__.'/../fixtures/chrome-bookmarks', 'Bookmarks'); | 97 | $file = new UploadedFile(__DIR__.'/../fixtures/firefox-bookmarks.json', 'Bookmarks'); |
80 | 98 | ||
81 | $data = [ | 99 | $data = [ |
82 | 'upload_import_file[file]' => $file, | 100 | 'upload_import_file[file]' => $file, |
@@ -95,7 +113,7 @@ class BrowserControllerTest extends WallabagCoreTestCase | |||
95 | ->get('doctrine.orm.entity_manager') | 113 | ->get('doctrine.orm.entity_manager') |
96 | ->getRepository('WallabagCoreBundle:Entry') | 114 | ->getRepository('WallabagCoreBundle:Entry') |
97 | ->findByUrlAndUserId( | 115 | ->findByUrlAndUserId( |
98 | 'http://www.usinenouvelle.com/article/la-multiplication-des-chefs-de-projet-est-une-catastrophe-manageriale-majeure-affirme-le-sociologue-francois-dupuy.N307730', | 116 | 'http://lexpansion.lexpress.fr/high-tech/orange-offre-un-meilleur-reseau-mobile-que-bouygues-et-sfr-free-derriere_1811554.html', |
99 | $this->getLoggedInUserId() | 117 | $this->getLoggedInUserId() |
100 | ); | 118 | ); |
101 | 119 | ||
@@ -103,6 +121,18 @@ class BrowserControllerTest extends WallabagCoreTestCase | |||
103 | $this->assertNotEmpty($content->getPreviewPicture()); | 121 | $this->assertNotEmpty($content->getPreviewPicture()); |
104 | $this->assertNotEmpty($content->getLanguage()); | 122 | $this->assertNotEmpty($content->getLanguage()); |
105 | $this->assertEquals(0, count($content->getTags())); | 123 | $this->assertEquals(0, count($content->getTags())); |
124 | |||
125 | $content = $client->getContainer() | ||
126 | ->get('doctrine.orm.entity_manager') | ||
127 | ->getRepository('WallabagCoreBundle:Entry') | ||
128 | ->findByUrlAndUserId( | ||
129 | 'http://stackoverflow.com/questions/15017163/parser-for-exported-bookmarks-html-file-of-google-chrome-and-mozilla-in-java', | ||
130 | $this->getLoggedInUserId() | ||
131 | ); | ||
132 | |||
133 | $this->assertNotEmpty($content->getMimetype()); | ||
134 | $this->assertNotEmpty($content->getPreviewPicture()); | ||
135 | $this->assertEmpty($content->getLanguage()); | ||
106 | } | 136 | } |
107 | 137 | ||
108 | public function testImportWallabagWithEmptyFile() | 138 | public function testImportWallabagWithEmptyFile() |
@@ -110,7 +140,7 @@ class BrowserControllerTest extends WallabagCoreTestCase | |||
110 | $this->logInAs('admin'); | 140 | $this->logInAs('admin'); |
111 | $client = $this->getClient(); | 141 | $client = $this->getClient(); |
112 | 142 | ||
113 | $crawler = $client->request('GET', '/import/browser'); | 143 | $crawler = $client->request('GET', '/import/firefox'); |
114 | $form = $crawler->filter('form[name=upload_import_file] > button[type=submit]')->form(); | 144 | $form = $crawler->filter('form[name=upload_import_file] > button[type=submit]')->form(); |
115 | 145 | ||
116 | $file = new UploadedFile(__DIR__.'/../fixtures/test.txt', 'test.txt'); | 146 | $file = new UploadedFile(__DIR__.'/../fixtures/test.txt', 'test.txt'); |
diff --git a/tests/Wallabag/ImportBundle/Controller/ImportControllerTest.php b/tests/Wallabag/ImportBundle/Controller/ImportControllerTest.php index 23a7c877..b6783a56 100644 --- a/tests/Wallabag/ImportBundle/Controller/ImportControllerTest.php +++ b/tests/Wallabag/ImportBundle/Controller/ImportControllerTest.php | |||
@@ -24,6 +24,6 @@ class ImportControllerTest extends WallabagCoreTestCase | |||
24 | $crawler = $client->request('GET', '/import/'); | 24 | $crawler = $client->request('GET', '/import/'); |
25 | 25 | ||
26 | $this->assertEquals(200, $client->getResponse()->getStatusCode()); | 26 | $this->assertEquals(200, $client->getResponse()->getStatusCode()); |
27 | $this->assertEquals(5, $crawler->filter('blockquote')->count()); | 27 | $this->assertEquals(6, $crawler->filter('blockquote')->count()); |
28 | } | 28 | } |
29 | } | 29 | } |
diff --git a/tests/Wallabag/ImportBundle/Controller/ReadabilityControllerTest.php b/tests/Wallabag/ImportBundle/Controller/ReadabilityControllerTest.php index 87ecb9d3..916dd297 100644 --- a/tests/Wallabag/ImportBundle/Controller/ReadabilityControllerTest.php +++ b/tests/Wallabag/ImportBundle/Controller/ReadabilityControllerTest.php | |||
@@ -57,7 +57,6 @@ class ReadabilityControllerTest extends WallabagCoreTestCase | |||
57 | $this->checkRedis(); | 57 | $this->checkRedis(); |
58 | $this->logInAs('admin'); | 58 | $this->logInAs('admin'); |
59 | $client = $this->getClient(); | 59 | $client = $this->getClient(); |
60 | |||
61 | $client->getContainer()->get('craue_config')->set('import_with_redis', 1); | 60 | $client->getContainer()->get('craue_config')->set('import_with_redis', 1); |
62 | 61 | ||
63 | $crawler = $client->request('GET', '/import/readability'); | 62 | $crawler = $client->request('GET', '/import/readability'); |