diff options
Diffstat (limited to 'tests/Wallabag/CoreBundle/Controller/ExportControllerTest.php')
-rw-r--r-- | tests/Wallabag/CoreBundle/Controller/ExportControllerTest.php | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/tests/Wallabag/CoreBundle/Controller/ExportControllerTest.php b/tests/Wallabag/CoreBundle/Controller/ExportControllerTest.php index 6f3308e5..d7ce7c45 100644 --- a/tests/Wallabag/CoreBundle/Controller/ExportControllerTest.php +++ b/tests/Wallabag/CoreBundle/Controller/ExportControllerTest.php | |||
@@ -98,7 +98,7 @@ class ExportControllerTest extends WallabagCoreTestCase | |||
98 | 98 | ||
99 | $headers = $client->getResponse()->headers; | 99 | $headers = $client->getResponse()->headers; |
100 | $this->assertSame('application/x-mobipocket-ebook', $headers->get('content-type')); | 100 | $this->assertSame('application/x-mobipocket-ebook', $headers->get('content-type')); |
101 | $this->assertSame('attachment; filename="' . preg_replace('/[^A-Za-z0-9\-]/', '', $content->getTitle()) . '.mobi"', $headers->get('content-disposition')); | 101 | $this->assertSame('attachment; filename="' . $this->getSanitizedFilename($content->getTitle()) . '.mobi"', $headers->get('content-disposition')); |
102 | $this->assertSame('binary', $headers->get('content-transfer-encoding')); | 102 | $this->assertSame('binary', $headers->get('content-transfer-encoding')); |
103 | } | 103 | } |
104 | 104 | ||
@@ -126,7 +126,7 @@ class ExportControllerTest extends WallabagCoreTestCase | |||
126 | 126 | ||
127 | $headers = $client->getResponse()->headers; | 127 | $headers = $client->getResponse()->headers; |
128 | $this->assertSame('application/pdf', $headers->get('content-type')); | 128 | $this->assertSame('application/pdf', $headers->get('content-type')); |
129 | $this->assertSame('attachment; filename="Tag_entries articles.pdf"', $headers->get('content-disposition')); | 129 | $this->assertSame('attachment; filename="Tag foo bar articles.pdf"', $headers->get('content-disposition')); |
130 | $this->assertSame('binary', $headers->get('content-transfer-encoding')); | 130 | $this->assertSame('binary', $headers->get('content-transfer-encoding')); |
131 | } | 131 | } |
132 | 132 | ||
@@ -180,7 +180,7 @@ class ExportControllerTest extends WallabagCoreTestCase | |||
180 | 180 | ||
181 | $this->assertGreaterThan(1, $csv); | 181 | $this->assertGreaterThan(1, $csv); |
182 | // +1 for title line | 182 | // +1 for title line |
183 | $this->assertSame(\count($contentInDB) + 1, \count($csv)); | 183 | $this->assertCount(\count($contentInDB) + 1, $csv); |
184 | $this->assertSame('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]); |
@@ -212,7 +212,7 @@ class ExportControllerTest extends WallabagCoreTestCase | |||
212 | 212 | ||
213 | $headers = $client->getResponse()->headers; | 213 | $headers = $client->getResponse()->headers; |
214 | $this->assertSame('application/json', $headers->get('content-type')); | 214 | $this->assertSame('application/json', $headers->get('content-type')); |
215 | $this->assertSame('attachment; filename="' . $contentInDB->getTitle() . '.json"', $headers->get('content-disposition')); | 215 | $this->assertSame('attachment; filename="' . $this->getSanitizedFilename($contentInDB->getTitle()) . '.json"', $headers->get('content-disposition')); |
216 | $this->assertSame('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); |
@@ -281,4 +281,9 @@ class ExportControllerTest extends WallabagCoreTestCase | |||
281 | $this->assertNotEmpty('created_at', (string) $content->entry[0]->created_at); | 281 | $this->assertNotEmpty('created_at', (string) $content->entry[0]->created_at); |
282 | $this->assertNotEmpty('updated_at', (string) $content->entry[0]->updated_at); | 282 | $this->assertNotEmpty('updated_at', (string) $content->entry[0]->updated_at); |
283 | } | 283 | } |
284 | |||
285 | private function getSanitizedFilename($title) | ||
286 | { | ||
287 | return preg_replace('/[^A-Za-z0-9\- \']/', '', iconv('utf-8', 'us-ascii//TRANSLIT', $title)); | ||
288 | } | ||
284 | } | 289 | } |