diff options
Diffstat (limited to 'tests/Wallabag/CoreBundle/Controller/ExportControllerTest.php')
-rw-r--r-- | tests/Wallabag/CoreBundle/Controller/ExportControllerTest.php | 108 |
1 files changed, 54 insertions, 54 deletions
diff --git a/tests/Wallabag/CoreBundle/Controller/ExportControllerTest.php b/tests/Wallabag/CoreBundle/Controller/ExportControllerTest.php index b38961d3..3e216381 100644 --- a/tests/Wallabag/CoreBundle/Controller/ExportControllerTest.php +++ b/tests/Wallabag/CoreBundle/Controller/ExportControllerTest.php | |||
@@ -12,7 +12,7 @@ class ExportControllerTest extends WallabagCoreTestCase | |||
12 | 12 | ||
13 | $client->request('GET', '/export/unread.csv'); | 13 | $client->request('GET', '/export/unread.csv'); |
14 | 14 | ||
15 | $this->assertEquals(302, $client->getResponse()->getStatusCode()); | 15 | $this->assertSame(302, $client->getResponse()->getStatusCode()); |
16 | $this->assertContains('login', $client->getResponse()->headers->get('location')); | 16 | $this->assertContains('login', $client->getResponse()->headers->get('location')); |
17 | } | 17 | } |
18 | 18 | ||
@@ -23,7 +23,7 @@ class ExportControllerTest extends WallabagCoreTestCase | |||
23 | 23 | ||
24 | $client->request('GET', '/export/awesomeness.epub'); | 24 | $client->request('GET', '/export/awesomeness.epub'); |
25 | 25 | ||
26 | $this->assertEquals(404, $client->getResponse()->getStatusCode()); | 26 | $this->assertSame(404, $client->getResponse()->getStatusCode()); |
27 | } | 27 | } |
28 | 28 | ||
29 | public function testUnknownFormatExport() | 29 | public function testUnknownFormatExport() |
@@ -33,7 +33,7 @@ class ExportControllerTest extends WallabagCoreTestCase | |||
33 | 33 | ||
34 | $client->request('GET', '/export/unread.xslx'); | 34 | $client->request('GET', '/export/unread.xslx'); |
35 | 35 | ||
36 | $this->assertEquals(404, $client->getResponse()->getStatusCode()); | 36 | $this->assertSame(404, $client->getResponse()->getStatusCode()); |
37 | } | 37 | } |
38 | 38 | ||
39 | public function testUnsupportedFormatExport() | 39 | public function testUnsupportedFormatExport() |
@@ -42,15 +42,15 @@ class ExportControllerTest extends WallabagCoreTestCase | |||
42 | $client = $this->getClient(); | 42 | $client = $this->getClient(); |
43 | 43 | ||
44 | $client->request('GET', '/export/unread.doc'); | 44 | $client->request('GET', '/export/unread.doc'); |
45 | $this->assertEquals(404, $client->getResponse()->getStatusCode()); | 45 | $this->assertSame(404, $client->getResponse()->getStatusCode()); |
46 | 46 | ||
47 | $content = $client->getContainer() | 47 | $content = $client->getContainer() |
48 | ->get('doctrine.orm.entity_manager') | 48 | ->get('doctrine.orm.entity_manager') |
49 | ->getRepository('WallabagCoreBundle:Entry') | 49 | ->getRepository('WallabagCoreBundle:Entry') |
50 | ->findOneByUsernameAndNotArchived('admin'); | 50 | ->findOneByUsernameAndNotArchived('admin'); |
51 | 51 | ||
52 | $client->request('GET', '/export/'.$content->getId().'.doc'); | 52 | $client->request('GET', '/export/' . $content->getId() . '.doc'); |
53 | $this->assertEquals(404, $client->getResponse()->getStatusCode()); | 53 | $this->assertSame(404, $client->getResponse()->getStatusCode()); |
54 | } | 54 | } |
55 | 55 | ||
56 | public function testBadEntryId() | 56 | public function testBadEntryId() |
@@ -60,7 +60,7 @@ class ExportControllerTest extends WallabagCoreTestCase | |||
60 | 60 | ||
61 | $client->request('GET', '/export/0.mobi'); | 61 | $client->request('GET', '/export/0.mobi'); |
62 | 62 | ||
63 | $this->assertEquals(404, $client->getResponse()->getStatusCode()); | 63 | $this->assertSame(404, $client->getResponse()->getStatusCode()); |
64 | } | 64 | } |
65 | 65 | ||
66 | public function testEpubExport() | 66 | public function testEpubExport() |
@@ -72,12 +72,12 @@ class ExportControllerTest extends WallabagCoreTestCase | |||
72 | $crawler = $client->request('GET', '/export/archive.epub'); | 72 | $crawler = $client->request('GET', '/export/archive.epub'); |
73 | ob_end_clean(); | 73 | ob_end_clean(); |
74 | 74 | ||
75 | $this->assertEquals(200, $client->getResponse()->getStatusCode()); | 75 | $this->assertSame(200, $client->getResponse()->getStatusCode()); |
76 | 76 | ||
77 | $headers = $client->getResponse()->headers; | 77 | $headers = $client->getResponse()->headers; |
78 | $this->assertEquals('application/epub+zip', $headers->get('content-type')); | 78 | $this->assertSame('application/epub+zip', $headers->get('content-type')); |
79 | $this->assertEquals('attachment; filename="Archive articles.epub"', $headers->get('content-disposition')); | 79 | $this->assertSame('attachment; filename="Archive articles.epub"', $headers->get('content-disposition')); |
80 | $this->assertEquals('binary', $headers->get('content-transfer-encoding')); | 80 | $this->assertSame('binary', $headers->get('content-transfer-encoding')); |
81 | } | 81 | } |
82 | 82 | ||
83 | public function testMobiExport() | 83 | public function testMobiExport() |
@@ -91,15 +91,15 @@ class ExportControllerTest extends WallabagCoreTestCase | |||
91 | ->findOneByUsernameAndNotArchived('admin'); | 91 | ->findOneByUsernameAndNotArchived('admin'); |
92 | 92 | ||
93 | ob_start(); | 93 | ob_start(); |
94 | $crawler = $client->request('GET', '/export/'.$content->getId().'.mobi'); | 94 | $crawler = $client->request('GET', '/export/' . $content->getId() . '.mobi'); |
95 | ob_end_clean(); | 95 | ob_end_clean(); |
96 | 96 | ||
97 | $this->assertEquals(200, $client->getResponse()->getStatusCode()); | 97 | $this->assertSame(200, $client->getResponse()->getStatusCode()); |
98 | 98 | ||
99 | $headers = $client->getResponse()->headers; | 99 | $headers = $client->getResponse()->headers; |
100 | $this->assertEquals('application/x-mobipocket-ebook', $headers->get('content-type')); | 100 | $this->assertSame('application/x-mobipocket-ebook', $headers->get('content-type')); |
101 | $this->assertEquals('attachment; filename="'.preg_replace('/[^A-Za-z0-9\-]/', '', $content->getTitle()).'.mobi"', $headers->get('content-disposition')); | 101 | $this->assertSame('attachment; filename="' . preg_replace('/[^A-Za-z0-9\-]/', '', $content->getTitle()) . '.mobi"', $headers->get('content-disposition')); |
102 | $this->assertEquals('binary', $headers->get('content-transfer-encoding')); | 102 | $this->assertSame('binary', $headers->get('content-transfer-encoding')); |
103 | } | 103 | } |
104 | 104 | ||
105 | public function testPdfExport() | 105 | public function testPdfExport() |
@@ -111,23 +111,23 @@ class ExportControllerTest extends WallabagCoreTestCase | |||
111 | $crawler = $client->request('GET', '/export/all.pdf'); | 111 | $crawler = $client->request('GET', '/export/all.pdf'); |
112 | ob_end_clean(); | 112 | ob_end_clean(); |
113 | 113 | ||
114 | $this->assertEquals(200, $client->getResponse()->getStatusCode()); | 114 | $this->assertSame(200, $client->getResponse()->getStatusCode()); |
115 | 115 | ||
116 | $headers = $client->getResponse()->headers; | 116 | $headers = $client->getResponse()->headers; |
117 | $this->assertEquals('application/pdf', $headers->get('content-type')); | 117 | $this->assertSame('application/pdf', $headers->get('content-type')); |
118 | $this->assertEquals('attachment; filename="All articles.pdf"', $headers->get('content-disposition')); | 118 | $this->assertSame('attachment; filename="All articles.pdf"', $headers->get('content-disposition')); |
119 | $this->assertEquals('binary', $headers->get('content-transfer-encoding')); | 119 | $this->assertSame('binary', $headers->get('content-transfer-encoding')); |
120 | 120 | ||
121 | ob_start(); | 121 | ob_start(); |
122 | $crawler = $client->request('GET', '/export/tag_entries.pdf?tag=foo-bar'); | 122 | $crawler = $client->request('GET', '/export/tag_entries.pdf?tag=foo-bar'); |
123 | ob_end_clean(); | 123 | ob_end_clean(); |
124 | 124 | ||
125 | $this->assertEquals(200, $client->getResponse()->getStatusCode()); | 125 | $this->assertSame(200, $client->getResponse()->getStatusCode()); |
126 | 126 | ||
127 | $headers = $client->getResponse()->headers; | 127 | $headers = $client->getResponse()->headers; |
128 | $this->assertEquals('application/pdf', $headers->get('content-type')); | 128 | $this->assertSame('application/pdf', $headers->get('content-type')); |
129 | $this->assertEquals('attachment; filename="Tag_entries articles.pdf"', $headers->get('content-disposition')); | 129 | $this->assertSame('attachment; filename="Tag_entries articles.pdf"', $headers->get('content-disposition')); |
130 | $this->assertEquals('binary', $headers->get('content-transfer-encoding')); | 130 | $this->assertSame('binary', $headers->get('content-transfer-encoding')); |
131 | } | 131 | } |
132 | 132 | ||
133 | public function testTxtExport() | 133 | public function testTxtExport() |
@@ -139,12 +139,12 @@ class ExportControllerTest extends WallabagCoreTestCase | |||
139 | $crawler = $client->request('GET', '/export/all.txt'); | 139 | $crawler = $client->request('GET', '/export/all.txt'); |
140 | ob_end_clean(); | 140 | ob_end_clean(); |
141 | 141 | ||
142 | $this->assertEquals(200, $client->getResponse()->getStatusCode()); | 142 | $this->assertSame(200, $client->getResponse()->getStatusCode()); |
143 | 143 | ||
144 | $headers = $client->getResponse()->headers; | 144 | $headers = $client->getResponse()->headers; |
145 | $this->assertEquals('text/plain; charset=UTF-8', $headers->get('content-type')); | 145 | $this->assertSame('text/plain; charset=UTF-8', $headers->get('content-type')); |
146 | $this->assertEquals('attachment; filename="All articles.txt"', $headers->get('content-disposition')); | 146 | $this->assertSame('attachment; filename="All articles.txt"', $headers->get('content-disposition')); |
147 | $this->assertEquals('UTF-8', $headers->get('content-transfer-encoding')); | 147 | $this->assertSame('UTF-8', $headers->get('content-transfer-encoding')); |
148 | } | 148 | } |
149 | 149 | ||
150 | public function testCsvExport() | 150 | public function testCsvExport() |
@@ -169,19 +169,19 @@ class ExportControllerTest extends WallabagCoreTestCase | |||
169 | $crawler = $client->request('GET', '/export/archive.csv'); | 169 | $crawler = $client->request('GET', '/export/archive.csv'); |
170 | ob_end_clean(); | 170 | ob_end_clean(); |
171 | 171 | ||
172 | $this->assertEquals(200, $client->getResponse()->getStatusCode()); | 172 | $this->assertSame(200, $client->getResponse()->getStatusCode()); |
173 | 173 | ||
174 | $headers = $client->getResponse()->headers; | 174 | $headers = $client->getResponse()->headers; |
175 | $this->assertEquals('application/csv', $headers->get('content-type')); | 175 | $this->assertSame('application/csv', $headers->get('content-type')); |
176 | $this->assertEquals('attachment; filename="Archive articles.csv"', $headers->get('content-disposition')); | 176 | $this->assertSame('attachment; filename="Archive articles.csv"', $headers->get('content-disposition')); |
177 | $this->assertEquals('UTF-8', $headers->get('content-transfer-encoding')); | 177 | $this->assertSame('UTF-8', $headers->get('content-transfer-encoding')); |
178 | 178 | ||
179 | $csv = str_getcsv($client->getResponse()->getContent(), "\n"); | 179 | $csv = str_getcsv($client->getResponse()->getContent(), "\n"); |
180 | 180 | ||
181 | $this->assertGreaterThan(1, $csv); | 181 | $this->assertGreaterThan(1, $csv); |
182 | // +1 for title line | 182 | // +1 for title line |
183 | $this->assertEquals(count($contentInDB) + 1, count($csv)); | 183 | $this->assertSame(count($contentInDB) + 1, count($csv)); |
184 | $this->assertEquals('Title;URL;Content;Tags;"MIME Type";Language;"Creation date"', $csv[0]); | 184 | $this->assertSame('Title;URL;Content;Tags;"MIME Type";Language;"Creation date"', $csv[0]); |
185 | $this->assertContains($contentInDB[0]['title'], $csv[1]); | 185 | $this->assertContains($contentInDB[0]['title'], $csv[1]); |
186 | $this->assertContains($contentInDB[0]['url'], $csv[1]); | 186 | $this->assertContains($contentInDB[0]['url'], $csv[1]); |
187 | $this->assertContains($contentInDB[0]['content'], $csv[1]); | 187 | $this->assertContains($contentInDB[0]['content'], $csv[1]); |
@@ -205,15 +205,15 @@ class ExportControllerTest extends WallabagCoreTestCase | |||
205 | ->findByUrlAndUserId('http://0.0.0.0/entry1', $this->getLoggedInUserId()); | 205 | ->findByUrlAndUserId('http://0.0.0.0/entry1', $this->getLoggedInUserId()); |
206 | 206 | ||
207 | ob_start(); | 207 | ob_start(); |
208 | $crawler = $client->request('GET', '/export/'.$contentInDB->getId().'.json'); | 208 | $crawler = $client->request('GET', '/export/' . $contentInDB->getId() . '.json'); |
209 | ob_end_clean(); | 209 | ob_end_clean(); |
210 | 210 | ||
211 | $this->assertEquals(200, $client->getResponse()->getStatusCode()); | 211 | $this->assertSame(200, $client->getResponse()->getStatusCode()); |
212 | 212 | ||
213 | $headers = $client->getResponse()->headers; | 213 | $headers = $client->getResponse()->headers; |
214 | $this->assertEquals('application/json', $headers->get('content-type')); | 214 | $this->assertSame('application/json', $headers->get('content-type')); |
215 | $this->assertEquals('attachment; filename="'.$contentInDB->getTitle().'.json"', $headers->get('content-disposition')); | 215 | $this->assertSame('attachment; filename="' . $contentInDB->getTitle() . '.json"', $headers->get('content-disposition')); |
216 | $this->assertEquals('UTF-8', $headers->get('content-transfer-encoding')); | 216 | $this->assertSame('UTF-8', $headers->get('content-transfer-encoding')); |
217 | 217 | ||
218 | $content = json_decode($client->getResponse()->getContent(), true); | 218 | $content = json_decode($client->getResponse()->getContent(), true); |
219 | $this->assertArrayHasKey('id', $content[0]); | 219 | $this->assertArrayHasKey('id', $content[0]); |
@@ -230,16 +230,16 @@ class ExportControllerTest extends WallabagCoreTestCase | |||
230 | $this->assertArrayHasKey('created_at', $content[0]); | 230 | $this->assertArrayHasKey('created_at', $content[0]); |
231 | $this->assertArrayHasKey('updated_at', $content[0]); | 231 | $this->assertArrayHasKey('updated_at', $content[0]); |
232 | 232 | ||
233 | $this->assertEquals($contentInDB->isArchived(), $content[0]['is_archived']); | 233 | $this->assertSame((int) $contentInDB->isArchived(), $content[0]['is_archived']); |
234 | $this->assertEquals($contentInDB->isStarred(), $content[0]['is_starred']); | 234 | $this->assertSame((int) $contentInDB->isStarred(), $content[0]['is_starred']); |
235 | $this->assertEquals($contentInDB->getTitle(), $content[0]['title']); | 235 | $this->assertSame($contentInDB->getTitle(), $content[0]['title']); |
236 | $this->assertEquals($contentInDB->getUrl(), $content[0]['url']); | 236 | $this->assertSame($contentInDB->getUrl(), $content[0]['url']); |
237 | $this->assertEquals([['text' => 'This is my annotation /o/', 'quote' => 'content']], $content[0]['annotations']); | 237 | $this->assertSame([['text' => 'This is my annotation /o/', 'quote' => 'content']], $content[0]['annotations']); |
238 | $this->assertEquals($contentInDB->getMimetype(), $content[0]['mimetype']); | 238 | $this->assertSame($contentInDB->getMimetype(), $content[0]['mimetype']); |
239 | $this->assertEquals($contentInDB->getLanguage(), $content[0]['language']); | 239 | $this->assertSame($contentInDB->getLanguage(), $content[0]['language']); |
240 | $this->assertEquals($contentInDB->getReadingtime(), $content[0]['reading_time']); | 240 | $this->assertSame($contentInDB->getReadingtime(), $content[0]['reading_time']); |
241 | $this->assertEquals($contentInDB->getDomainname(), $content[0]['domain_name']); | 241 | $this->assertSame($contentInDB->getDomainname(), $content[0]['domain_name']); |
242 | $this->assertEquals(['foo bar', 'baz'], $content[0]['tags']); | 242 | $this->assertSame(['foo bar', 'baz'], $content[0]['tags']); |
243 | } | 243 | } |
244 | 244 | ||
245 | public function testXmlExport() | 245 | public function testXmlExport() |
@@ -262,16 +262,16 @@ class ExportControllerTest extends WallabagCoreTestCase | |||
262 | $crawler = $client->request('GET', '/export/unread.xml'); | 262 | $crawler = $client->request('GET', '/export/unread.xml'); |
263 | ob_end_clean(); | 263 | ob_end_clean(); |
264 | 264 | ||
265 | $this->assertEquals(200, $client->getResponse()->getStatusCode()); | 265 | $this->assertSame(200, $client->getResponse()->getStatusCode()); |
266 | 266 | ||
267 | $headers = $client->getResponse()->headers; | 267 | $headers = $client->getResponse()->headers; |
268 | $this->assertEquals('application/xml', $headers->get('content-type')); | 268 | $this->assertSame('application/xml', $headers->get('content-type')); |
269 | $this->assertEquals('attachment; filename="Unread articles.xml"', $headers->get('content-disposition')); | 269 | $this->assertSame('attachment; filename="Unread articles.xml"', $headers->get('content-disposition')); |
270 | $this->assertEquals('UTF-8', $headers->get('content-transfer-encoding')); | 270 | $this->assertSame('UTF-8', $headers->get('content-transfer-encoding')); |
271 | 271 | ||
272 | $content = new \SimpleXMLElement($client->getResponse()->getContent()); | 272 | $content = new \SimpleXMLElement($client->getResponse()->getContent()); |
273 | $this->assertGreaterThan(0, $content->count()); | 273 | $this->assertGreaterThan(0, $content->count()); |
274 | $this->assertEquals(count($contentInDB), $content->count()); | 274 | $this->assertSame(count($contentInDB), $content->count()); |
275 | $this->assertNotEmpty('id', (string) $content->entry[0]->id); | 275 | $this->assertNotEmpty('id', (string) $content->entry[0]->id); |
276 | $this->assertNotEmpty('title', (string) $content->entry[0]->title); | 276 | $this->assertNotEmpty('title', (string) $content->entry[0]->title); |
277 | $this->assertNotEmpty('url', (string) $content->entry[0]->url); | 277 | $this->assertNotEmpty('url', (string) $content->entry[0]->url); |