X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=tests%2FWallabag%2FCoreBundle%2FController%2FExportControllerTest.php;h=d7ce7c45a9890fc2fce96178e45a0e703ac3701b;hb=9f0957b831622ee577fa7d8f92ec0df6f3a8e274;hp=6f3308e56f337bd1d02d8cc7a36fca40a844deba;hpb=0ebf595c11031474260ba0874c7973c91163e958;p=github%2Fwallabag%2Fwallabag.git 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 $headers = $client->getResponse()->headers; $this->assertSame('application/x-mobipocket-ebook', $headers->get('content-type')); - $this->assertSame('attachment; filename="' . preg_replace('/[^A-Za-z0-9\-]/', '', $content->getTitle()) . '.mobi"', $headers->get('content-disposition')); + $this->assertSame('attachment; filename="' . $this->getSanitizedFilename($content->getTitle()) . '.mobi"', $headers->get('content-disposition')); $this->assertSame('binary', $headers->get('content-transfer-encoding')); } @@ -126,7 +126,7 @@ class ExportControllerTest extends WallabagCoreTestCase $headers = $client->getResponse()->headers; $this->assertSame('application/pdf', $headers->get('content-type')); - $this->assertSame('attachment; filename="Tag_entries articles.pdf"', $headers->get('content-disposition')); + $this->assertSame('attachment; filename="Tag foo bar articles.pdf"', $headers->get('content-disposition')); $this->assertSame('binary', $headers->get('content-transfer-encoding')); } @@ -180,7 +180,7 @@ class ExportControllerTest extends WallabagCoreTestCase $this->assertGreaterThan(1, $csv); // +1 for title line - $this->assertSame(\count($contentInDB) + 1, \count($csv)); + $this->assertCount(\count($contentInDB) + 1, $csv); $this->assertSame('Title;URL;Content;Tags;"MIME Type";Language;"Creation date"', $csv[0]); $this->assertContains($contentInDB[0]['title'], $csv[1]); $this->assertContains($contentInDB[0]['url'], $csv[1]); @@ -212,7 +212,7 @@ class ExportControllerTest extends WallabagCoreTestCase $headers = $client->getResponse()->headers; $this->assertSame('application/json', $headers->get('content-type')); - $this->assertSame('attachment; filename="' . $contentInDB->getTitle() . '.json"', $headers->get('content-disposition')); + $this->assertSame('attachment; filename="' . $this->getSanitizedFilename($contentInDB->getTitle()) . '.json"', $headers->get('content-disposition')); $this->assertSame('UTF-8', $headers->get('content-transfer-encoding')); $content = json_decode($client->getResponse()->getContent(), true); @@ -281,4 +281,9 @@ class ExportControllerTest extends WallabagCoreTestCase $this->assertNotEmpty('created_at', (string) $content->entry[0]->created_at); $this->assertNotEmpty('updated_at', (string) $content->entry[0]->updated_at); } + + private function getSanitizedFilename($title) + { + return preg_replace('/[^A-Za-z0-9\- \']/', '', iconv('utf-8', 'us-ascii//TRANSLIT', $title)); + } }