diff options
author | Jérémy Benoist <j0k3r@users.noreply.github.com> | 2017-10-23 11:09:17 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-10-23 11:09:17 +0200 |
commit | 1953a872932a63792293b4aec087880265ba89f7 (patch) | |
tree | fd16599e737fcdaf193c933ef3ec4a4ee248b117 /tests/Wallabag/ImportBundle/Controller/ReadabilityControllerTest.php | |
parent | d83d25dadec2c38460a32d96f5d2903426fec9d3 (diff) | |
parent | 702f2d67d60ca963492b90dad74cb5f8dcc84e51 (diff) | |
download | wallabag-1953a872932a63792293b4aec087880265ba89f7.tar.gz wallabag-1953a872932a63792293b4aec087880265ba89f7.tar.zst wallabag-1953a872932a63792293b4aec087880265ba89f7.zip |
Merge pull request #3011 from wallabag/2.3
wallabag 2.3.0
Diffstat (limited to 'tests/Wallabag/ImportBundle/Controller/ReadabilityControllerTest.php')
-rw-r--r-- | tests/Wallabag/ImportBundle/Controller/ReadabilityControllerTest.php | 53 |
1 files changed, 30 insertions, 23 deletions
diff --git a/tests/Wallabag/ImportBundle/Controller/ReadabilityControllerTest.php b/tests/Wallabag/ImportBundle/Controller/ReadabilityControllerTest.php index acb61ca1..fcb9dfab 100644 --- a/tests/Wallabag/ImportBundle/Controller/ReadabilityControllerTest.php +++ b/tests/Wallabag/ImportBundle/Controller/ReadabilityControllerTest.php | |||
@@ -2,8 +2,8 @@ | |||
2 | 2 | ||
3 | namespace Tests\Wallabag\ImportBundle\Controller; | 3 | namespace Tests\Wallabag\ImportBundle\Controller; |
4 | 4 | ||
5 | use Tests\Wallabag\CoreBundle\WallabagCoreTestCase; | ||
6 | use Symfony\Component\HttpFoundation\File\UploadedFile; | 5 | use Symfony\Component\HttpFoundation\File\UploadedFile; |
6 | use Tests\Wallabag\CoreBundle\WallabagCoreTestCase; | ||
7 | 7 | ||
8 | class ReadabilityControllerTest extends WallabagCoreTestCase | 8 | class ReadabilityControllerTest extends WallabagCoreTestCase |
9 | { | 9 | { |
@@ -14,9 +14,9 @@ class ReadabilityControllerTest extends WallabagCoreTestCase | |||
14 | 14 | ||
15 | $crawler = $client->request('GET', '/import/readability'); | 15 | $crawler = $client->request('GET', '/import/readability'); |
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 testImportReadabilityWithRabbitEnabled() | 22 | public function testImportReadabilityWithRabbitEnabled() |
@@ -28,9 +28,9 @@ class ReadabilityControllerTest extends WallabagCoreTestCase | |||
28 | 28 | ||
29 | $crawler = $client->request('GET', '/import/readability'); | 29 | $crawler = $client->request('GET', '/import/readability'); |
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 ReadabilityControllerTest 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 testImportReadabilityWithRedisEnabled() | 55 | public function testImportReadabilityWithRedisEnabled() |
@@ -61,13 +61,13 @@ class ReadabilityControllerTest extends WallabagCoreTestCase | |||
61 | 61 | ||
62 | $crawler = $client->request('GET', '/import/readability'); | 62 | $crawler = $client->request('GET', '/import/readability'); |
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/readability.json', 'readability.json'); | 70 | $file = new UploadedFile(__DIR__ . '/../fixtures/readability.json', 'readability.json'); |
71 | 71 | ||
72 | $data = [ | 72 | $data = [ |
73 | 'upload_import_file[file]' => $file, | 73 | 'upload_import_file[file]' => $file, |
@@ -75,7 +75,7 @@ class ReadabilityControllerTest 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 ReadabilityControllerTest extends WallabagCoreTestCase | |||
95 | $crawler = $client->request('GET', '/import/readability'); | 95 | $crawler = $client->request('GET', '/import/readability'); |
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/readability.json', 'readability.json'); | 98 | $file = new UploadedFile(__DIR__ . '/../fixtures/readability.json', 'readability.json'); |
99 | 99 | ||
100 | $data = [ | 100 | $data = [ |
101 | 'upload_import_file[file]' => $file, | 101 | 'upload_import_file[file]' => $file, |
@@ -103,7 +103,7 @@ class ReadabilityControllerTest 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 | ||
@@ -111,19 +111,24 @@ class ReadabilityControllerTest extends WallabagCoreTestCase | |||
111 | ->get('doctrine.orm.entity_manager') | 111 | ->get('doctrine.orm.entity_manager') |
112 | ->getRepository('WallabagCoreBundle:Entry') | 112 | ->getRepository('WallabagCoreBundle:Entry') |
113 | ->findByUrlAndUserId( | 113 | ->findByUrlAndUserId( |
114 | 'http://www.zataz.com/90-des-dossiers-medicaux-des-coreens-du-sud-vendus-a-des-entreprises-privees/', | 114 | 'https://www.zataz.com/90-des-dossiers-medicaux-des-coreens-du-sud-vendus-a-des-entreprises-privees/', |
115 | $this->getLoggedInUserId() | 115 | $this->getLoggedInUserId() |
116 | ); | 116 | ); |
117 | 117 | ||
118 | $this->assertGreaterThan(1, $body = $crawler->filter('body')->extract(['_text'])); | 118 | $this->assertGreaterThan(1, $body = $crawler->filter('body')->extract(['_text'])); |
119 | $this->assertContains('flashes.import.notice.summary', $body[0]); | 119 | $this->assertContains('flashes.import.notice.summary', $body[0]); |
120 | 120 | ||
121 | $this->assertInstanceOf('Wallabag\CoreBundle\Entity\Entry', $content); | ||
121 | $this->assertNotEmpty($content->getMimetype(), 'Mimetype for http://www.zataz.com is ok'); | 122 | $this->assertNotEmpty($content->getMimetype(), 'Mimetype for http://www.zataz.com is ok'); |
122 | $this->assertNotEmpty($content->getPreviewPicture(), 'Preview picture for http://www.zataz.com is ok'); | 123 | $this->assertNotEmpty($content->getPreviewPicture(), 'Preview picture for http://www.zataz.com is ok'); |
123 | $this->assertNotEmpty($content->getLanguage(), 'Language for http://www.zataz.com is ok'); | 124 | $this->assertNotEmpty($content->getLanguage(), 'Language for http://www.zataz.com is ok'); |
124 | $this->assertEquals(0, count($content->getTags())); | 125 | |
126 | $tags = $content->getTags(); | ||
127 | $this->assertContains('foot', $tags, 'It includes the "foot" tag'); | ||
128 | $this->assertSame(1, count($tags)); | ||
129 | |||
125 | $this->assertInstanceOf(\DateTime::class, $content->getCreatedAt()); | 130 | $this->assertInstanceOf(\DateTime::class, $content->getCreatedAt()); |
126 | $this->assertEquals('2016-09-08', $content->getCreatedAt()->format('Y-m-d')); | 131 | $this->assertSame('2016-09-08', $content->getCreatedAt()->format('Y-m-d')); |
127 | } | 132 | } |
128 | 133 | ||
129 | public function testImportReadabilityWithFileAndMarkAllAsRead() | 134 | public function testImportReadabilityWithFileAndMarkAllAsRead() |
@@ -134,7 +139,7 @@ class ReadabilityControllerTest extends WallabagCoreTestCase | |||
134 | $crawler = $client->request('GET', '/import/readability'); | 139 | $crawler = $client->request('GET', '/import/readability'); |
135 | $form = $crawler->filter('form[name=upload_import_file] > button[type=submit]')->form(); | 140 | $form = $crawler->filter('form[name=upload_import_file] > button[type=submit]')->form(); |
136 | 141 | ||
137 | $file = new UploadedFile(__DIR__.'/../fixtures/readability-read.json', 'readability-read.json'); | 142 | $file = new UploadedFile(__DIR__ . '/../fixtures/readability-read.json', 'readability-read.json'); |
138 | 143 | ||
139 | $data = [ | 144 | $data = [ |
140 | 'upload_import_file[file]' => $file, | 145 | 'upload_import_file[file]' => $file, |
@@ -143,7 +148,7 @@ class ReadabilityControllerTest extends WallabagCoreTestCase | |||
143 | 148 | ||
144 | $client->submit($form, $data); | 149 | $client->submit($form, $data); |
145 | 150 | ||
146 | $this->assertEquals(302, $client->getResponse()->getStatusCode()); | 151 | $this->assertSame(302, $client->getResponse()->getStatusCode()); |
147 | 152 | ||
148 | $crawler = $client->followRedirect(); | 153 | $crawler = $client->followRedirect(); |
149 | 154 | ||
@@ -155,16 +160,18 @@ class ReadabilityControllerTest extends WallabagCoreTestCase | |||
155 | $this->getLoggedInUserId() | 160 | $this->getLoggedInUserId() |
156 | ); | 161 | ); |
157 | 162 | ||
163 | $this->assertInstanceOf('Wallabag\CoreBundle\Entity\Entry', $content1); | ||
158 | $this->assertTrue($content1->isArchived()); | 164 | $this->assertTrue($content1->isArchived()); |
159 | 165 | ||
160 | $content2 = $client->getContainer() | 166 | $content2 = $client->getContainer() |
161 | ->get('doctrine.orm.entity_manager') | 167 | ->get('doctrine.orm.entity_manager') |
162 | ->getRepository('WallabagCoreBundle:Entry') | 168 | ->getRepository('WallabagCoreBundle:Entry') |
163 | ->findByUrlAndUserId( | 169 | ->findByUrlAndUserId( |
164 | 'https://facebook.github.io/graphql/', | 170 | 'https://facebook.github.io/graphql/October2016/', |
165 | $this->getLoggedInUserId() | 171 | $this->getLoggedInUserId() |
166 | ); | 172 | ); |
167 | 173 | ||
174 | $this->assertInstanceOf('Wallabag\CoreBundle\Entity\Entry', $content2); | ||
168 | $this->assertTrue($content2->isArchived()); | 175 | $this->assertTrue($content2->isArchived()); |
169 | 176 | ||
170 | $this->assertGreaterThan(1, $body = $crawler->filter('body')->extract(['_text'])); | 177 | $this->assertGreaterThan(1, $body = $crawler->filter('body')->extract(['_text'])); |
@@ -179,7 +186,7 @@ class ReadabilityControllerTest extends WallabagCoreTestCase | |||
179 | $crawler = $client->request('GET', '/import/readability'); | 186 | $crawler = $client->request('GET', '/import/readability'); |
180 | $form = $crawler->filter('form[name=upload_import_file] > button[type=submit]')->form(); | 187 | $form = $crawler->filter('form[name=upload_import_file] > button[type=submit]')->form(); |
181 | 188 | ||
182 | $file = new UploadedFile(__DIR__.'/../fixtures/test.txt', 'test.txt'); | 189 | $file = new UploadedFile(__DIR__ . '/../fixtures/test.txt', 'test.txt'); |
183 | 190 | ||
184 | $data = [ | 191 | $data = [ |
185 | 'upload_import_file[file]' => $file, | 192 | 'upload_import_file[file]' => $file, |
@@ -187,7 +194,7 @@ class ReadabilityControllerTest extends WallabagCoreTestCase | |||
187 | 194 | ||
188 | $client->submit($form, $data); | 195 | $client->submit($form, $data); |
189 | 196 | ||
190 | $this->assertEquals(302, $client->getResponse()->getStatusCode()); | 197 | $this->assertSame(302, $client->getResponse()->getStatusCode()); |
191 | 198 | ||
192 | $crawler = $client->followRedirect(); | 199 | $crawler = $client->followRedirect(); |
193 | 200 | ||