$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'));
}
$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'));
}
$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]);
$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);
$content = new \SimpleXMLElement($client->getResponse()->getContent());
$this->assertGreaterThan(0, $content->count());
- $this->assertSame(count($contentInDB), $content->count());
+ $this->assertSame(\count($contentInDB), $content->count());
$this->assertNotEmpty('id', (string) $content->entry[0]->id);
$this->assertNotEmpty('title', (string) $content->entry[0]->title);
$this->assertNotEmpty('url', (string) $content->entry[0]->url);
$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));
+ }
}