aboutsummaryrefslogtreecommitdiffhomepage
path: root/tests/Wallabag/ImportBundle/Controller/InstapaperControllerTest.php
diff options
context:
space:
mode:
Diffstat (limited to 'tests/Wallabag/ImportBundle/Controller/InstapaperControllerTest.php')
-rw-r--r--tests/Wallabag/ImportBundle/Controller/InstapaperControllerTest.php60
1 files changed, 37 insertions, 23 deletions
diff --git a/tests/Wallabag/ImportBundle/Controller/InstapaperControllerTest.php b/tests/Wallabag/ImportBundle/Controller/InstapaperControllerTest.php
index 3f6f2b9f..067cf3dc 100644
--- a/tests/Wallabag/ImportBundle/Controller/InstapaperControllerTest.php
+++ b/tests/Wallabag/ImportBundle/Controller/InstapaperControllerTest.php
@@ -2,8 +2,8 @@
2 2
3namespace Tests\Wallabag\ImportBundle\Controller; 3namespace Tests\Wallabag\ImportBundle\Controller;
4 4
5use Tests\Wallabag\CoreBundle\WallabagCoreTestCase;
6use Symfony\Component\HttpFoundation\File\UploadedFile; 5use Symfony\Component\HttpFoundation\File\UploadedFile;
6use Tests\Wallabag\CoreBundle\WallabagCoreTestCase;
7 7
8class InstapaperControllerTest extends WallabagCoreTestCase 8class InstapaperControllerTest extends WallabagCoreTestCase
9{ 9{
@@ -14,9 +14,9 @@ class InstapaperControllerTest extends WallabagCoreTestCase
14 14
15 $crawler = $client->request('GET', '/import/instapaper'); 15 $crawler = $client->request('GET', '/import/instapaper');
16 16
17 $this->assertEquals(200, $client->getResponse()->getStatusCode()); 17 $this->assertSame(200, $client->getResponse()->getStatusCode());
18 $this->assertEquals(1, $crawler->filter('form[name=upload_import_file] > button[type=submit]')->count()); 18 $this->assertSame(1, $crawler->filter('form[name=upload_import_file] > button[type=submit]')->count());
19 $this->assertEquals(1, $crawler->filter('input[type=file]')->count()); 19 $this->assertSame(1, $crawler->filter('input[type=file]')->count());
20 } 20 }
21 21
22 public function testImportInstapaperWithRabbitEnabled() 22 public function testImportInstapaperWithRabbitEnabled()
@@ -28,9 +28,9 @@ class InstapaperControllerTest extends WallabagCoreTestCase
28 28
29 $crawler = $client->request('GET', '/import/instapaper'); 29 $crawler = $client->request('GET', '/import/instapaper');
30 30
31 $this->assertEquals(200, $client->getResponse()->getStatusCode()); 31 $this->assertSame(200, $client->getResponse()->getStatusCode());
32 $this->assertEquals(1, $crawler->filter('form[name=upload_import_file] > button[type=submit]')->count()); 32 $this->assertSame(1, $crawler->filter('form[name=upload_import_file] > button[type=submit]')->count());
33 $this->assertEquals(1, $crawler->filter('input[type=file]')->count()); 33 $this->assertSame(1, $crawler->filter('input[type=file]')->count());
34 34
35 $client->getContainer()->get('craue_config')->set('import_with_rabbitmq', 0); 35 $client->getContainer()->get('craue_config')->set('import_with_rabbitmq', 0);
36 } 36 }
@@ -49,7 +49,7 @@ class InstapaperControllerTest extends WallabagCoreTestCase
49 49
50 $client->submit($form, $data); 50 $client->submit($form, $data);
51 51
52 $this->assertEquals(200, $client->getResponse()->getStatusCode()); 52 $this->assertSame(200, $client->getResponse()->getStatusCode());
53 } 53 }
54 54
55 public function testImportInstapaperWithRedisEnabled() 55 public function testImportInstapaperWithRedisEnabled()
@@ -61,13 +61,13 @@ class InstapaperControllerTest extends WallabagCoreTestCase
61 61
62 $crawler = $client->request('GET', '/import/instapaper'); 62 $crawler = $client->request('GET', '/import/instapaper');
63 63
64 $this->assertEquals(200, $client->getResponse()->getStatusCode()); 64 $this->assertSame(200, $client->getResponse()->getStatusCode());
65 $this->assertEquals(1, $crawler->filter('form[name=upload_import_file] > button[type=submit]')->count()); 65 $this->assertSame(1, $crawler->filter('form[name=upload_import_file] > button[type=submit]')->count());
66 $this->assertEquals(1, $crawler->filter('input[type=file]')->count()); 66 $this->assertSame(1, $crawler->filter('input[type=file]')->count());
67 67
68 $form = $crawler->filter('form[name=upload_import_file] > button[type=submit]')->form(); 68 $form = $crawler->filter('form[name=upload_import_file] > button[type=submit]')->form();
69 69
70 $file = new UploadedFile(__DIR__.'/../fixtures/instapaper-export.csv', 'instapaper.csv'); 70 $file = new UploadedFile(__DIR__ . '/../fixtures/instapaper-export.csv', 'instapaper.csv');
71 71
72 $data = [ 72 $data = [
73 'upload_import_file[file]' => $file, 73 'upload_import_file[file]' => $file,
@@ -75,7 +75,7 @@ class InstapaperControllerTest extends WallabagCoreTestCase
75 75
76 $client->submit($form, $data); 76 $client->submit($form, $data);
77 77
78 $this->assertEquals(302, $client->getResponse()->getStatusCode()); 78 $this->assertSame(302, $client->getResponse()->getStatusCode());
79 79
80 $crawler = $client->followRedirect(); 80 $crawler = $client->followRedirect();
81 81
@@ -95,7 +95,7 @@ class InstapaperControllerTest extends WallabagCoreTestCase
95 $crawler = $client->request('GET', '/import/instapaper'); 95 $crawler = $client->request('GET', '/import/instapaper');
96 $form = $crawler->filter('form[name=upload_import_file] > button[type=submit]')->form(); 96 $form = $crawler->filter('form[name=upload_import_file] > button[type=submit]')->form();
97 97
98 $file = new UploadedFile(__DIR__.'/../fixtures/instapaper-export.csv', 'instapaper.csv'); 98 $file = new UploadedFile(__DIR__ . '/../fixtures/instapaper-export.csv', 'instapaper.csv');
99 99
100 $data = [ 100 $data = [
101 'upload_import_file[file]' => $file, 101 'upload_import_file[file]' => $file,
@@ -103,10 +103,13 @@ class InstapaperControllerTest extends WallabagCoreTestCase
103 103
104 $client->submit($form, $data); 104 $client->submit($form, $data);
105 105
106 $this->assertEquals(302, $client->getResponse()->getStatusCode()); 106 $this->assertSame(302, $client->getResponse()->getStatusCode());
107 107
108 $crawler = $client->followRedirect(); 108 $crawler = $client->followRedirect();
109 109
110 $this->assertGreaterThan(1, $body = $crawler->filter('body')->extract(['_text']));
111 $this->assertContains('flashes.import.notice.summary', $body[0]);
112
110 $content = $client->getContainer() 113 $content = $client->getContainer()
111 ->get('doctrine.orm.entity_manager') 114 ->get('doctrine.orm.entity_manager')
112 ->getRepository('WallabagCoreBundle:Entry') 115 ->getRepository('WallabagCoreBundle:Entry')
@@ -115,14 +118,25 @@ class InstapaperControllerTest extends WallabagCoreTestCase
115 $this->getLoggedInUserId() 118 $this->getLoggedInUserId()
116 ); 119 );
117 120
118 $this->assertGreaterThan(1, $body = $crawler->filter('body')->extract(['_text']));
119 $this->assertContains('flashes.import.notice.summary', $body[0]);
120
121 $this->assertNotEmpty($content->getMimetype(), 'Mimetype for http://www.liberation.fr is ok'); 121 $this->assertNotEmpty($content->getMimetype(), 'Mimetype for http://www.liberation.fr is ok');
122 $this->assertNotEmpty($content->getPreviewPicture(), 'Preview picture for http://www.liberation.fr is ok'); 122 $this->assertNotEmpty($content->getPreviewPicture(), 'Preview picture for http://www.liberation.fr is ok');
123 $this->assertNotEmpty($content->getLanguage(), 'Language for http://www.liberation.fr is ok'); 123 $this->assertNotEmpty($content->getLanguage(), 'Language for http://www.liberation.fr is ok');
124 $this->assertEquals(0, count($content->getTags())); 124 $this->assertContains('foot', $content->getTags(), 'It includes the "foot" tag');
125 $this->assertSame(1, count($content->getTags()));
125 $this->assertInstanceOf(\DateTime::class, $content->getCreatedAt()); 126 $this->assertInstanceOf(\DateTime::class, $content->getCreatedAt());
127
128 $content = $client->getContainer()
129 ->get('doctrine.orm.entity_manager')
130 ->getRepository('WallabagCoreBundle:Entry')
131 ->findByUrlAndUserId(
132 'http://www.20minutes.fr/high-tech/2077615-20170531-dis-donc-donald-trump-quoi-exactement-covfefe',
133 $this->getLoggedInUserId()
134 );
135
136 $this->assertContains('foot', $content->getTags());
137 $this->assertContains('test_tag', $content->getTags());
138
139 $this->assertSame(2, count($content->getTags()));
126 } 140 }
127 141
128 public function testImportInstapaperWithFileAndMarkAllAsRead() 142 public function testImportInstapaperWithFileAndMarkAllAsRead()
@@ -133,7 +147,7 @@ class InstapaperControllerTest extends WallabagCoreTestCase
133 $crawler = $client->request('GET', '/import/instapaper'); 147 $crawler = $client->request('GET', '/import/instapaper');
134 $form = $crawler->filter('form[name=upload_import_file] > button[type=submit]')->form(); 148 $form = $crawler->filter('form[name=upload_import_file] > button[type=submit]')->form();
135 149
136 $file = new UploadedFile(__DIR__.'/../fixtures/instapaper-export.csv', 'instapaper-read.csv'); 150 $file = new UploadedFile(__DIR__ . '/../fixtures/instapaper-export.csv', 'instapaper-read.csv');
137 151
138 $data = [ 152 $data = [
139 'upload_import_file[file]' => $file, 153 'upload_import_file[file]' => $file,
@@ -142,7 +156,7 @@ class InstapaperControllerTest extends WallabagCoreTestCase
142 156
143 $client->submit($form, $data); 157 $client->submit($form, $data);
144 158
145 $this->assertEquals(302, $client->getResponse()->getStatusCode()); 159 $this->assertSame(302, $client->getResponse()->getStatusCode());
146 160
147 $crawler = $client->followRedirect(); 161 $crawler = $client->followRedirect();
148 162
@@ -178,7 +192,7 @@ class InstapaperControllerTest extends WallabagCoreTestCase
178 $crawler = $client->request('GET', '/import/instapaper'); 192 $crawler = $client->request('GET', '/import/instapaper');
179 $form = $crawler->filter('form[name=upload_import_file] > button[type=submit]')->form(); 193 $form = $crawler->filter('form[name=upload_import_file] > button[type=submit]')->form();
180 194
181 $file = new UploadedFile(__DIR__.'/../fixtures/test.txt', 'test.txt'); 195 $file = new UploadedFile(__DIR__ . '/../fixtures/test.txt', 'test.txt');
182 196
183 $data = [ 197 $data = [
184 'upload_import_file[file]' => $file, 198 'upload_import_file[file]' => $file,
@@ -186,7 +200,7 @@ class InstapaperControllerTest extends WallabagCoreTestCase
186 200
187 $client->submit($form, $data); 201 $client->submit($form, $data);
188 202
189 $this->assertEquals(302, $client->getResponse()->getStatusCode()); 203 $this->assertSame(302, $client->getResponse()->getStatusCode());
190 204
191 $crawler = $client->followRedirect(); 205 $crawler = $client->followRedirect();
192 206