2015-10-16 10:51:53 +02:00
|
|
|
<?php
|
|
|
|
|
2016-06-01 21:27:35 +02:00
|
|
|
namespace Tests\Wallabag\CoreBundle\Controller;
|
2015-10-16 10:51:53 +02:00
|
|
|
|
2022-08-28 02:01:46 +02:00
|
|
|
use Doctrine\ORM\EntityManagerInterface;
|
2016-06-01 21:27:35 +02:00
|
|
|
use Tests\Wallabag\CoreBundle\WallabagCoreTestCase;
|
2020-02-04 22:19:45 +01:00
|
|
|
use Wallabag\CoreBundle\Entity\Entry;
|
2015-10-16 10:51:53 +02:00
|
|
|
|
|
|
|
class ExportControllerTest extends WallabagCoreTestCase
|
|
|
|
{
|
2020-02-04 22:19:45 +01:00
|
|
|
private $adminEntry;
|
|
|
|
private $bobEntry;
|
2023-06-29 17:10:23 +02:00
|
|
|
private $sameDomainEntry;
|
|
|
|
private $sameDomainEntry2;
|
2020-02-04 22:19:45 +01:00
|
|
|
|
2015-10-16 10:51:53 +02:00
|
|
|
public function testLogin()
|
|
|
|
{
|
2022-11-23 17:09:32 +01:00
|
|
|
$client = $this->getTestClient();
|
2015-10-16 10:51:53 +02:00
|
|
|
|
|
|
|
$client->request('GET', '/export/unread.csv');
|
|
|
|
|
2017-07-01 09:52:38 +02:00
|
|
|
$this->assertSame(302, $client->getResponse()->getStatusCode());
|
2020-06-15 13:37:50 +02:00
|
|
|
$this->assertStringContainsString('login', $client->getResponse()->headers->get('location'));
|
2015-10-16 10:51:53 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
public function testUnknownCategoryExport()
|
|
|
|
{
|
|
|
|
$this->logInAs('admin');
|
2022-11-23 17:09:32 +01:00
|
|
|
$client = $this->getTestClient();
|
2015-10-16 10:51:53 +02:00
|
|
|
|
2015-10-30 20:57:10 +01:00
|
|
|
$client->request('GET', '/export/awesomeness.epub');
|
2015-10-16 10:51:53 +02:00
|
|
|
|
2017-07-01 09:52:38 +02:00
|
|
|
$this->assertSame(404, $client->getResponse()->getStatusCode());
|
2015-10-16 10:51:53 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
public function testUnknownFormatExport()
|
|
|
|
{
|
|
|
|
$this->logInAs('admin');
|
2022-11-23 17:09:32 +01:00
|
|
|
$client = $this->getTestClient();
|
2015-10-16 10:51:53 +02:00
|
|
|
|
2015-10-30 20:57:10 +01:00
|
|
|
$client->request('GET', '/export/unread.xslx');
|
|
|
|
|
2017-07-01 09:52:38 +02:00
|
|
|
$this->assertSame(404, $client->getResponse()->getStatusCode());
|
2015-10-30 20:57:10 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
public function testUnsupportedFormatExport()
|
|
|
|
{
|
|
|
|
$this->logInAs('admin');
|
2022-11-23 17:09:32 +01:00
|
|
|
$client = $this->getTestClient();
|
2015-10-30 20:57:10 +01:00
|
|
|
|
2016-01-25 22:25:55 +01:00
|
|
|
$client->request('GET', '/export/unread.doc');
|
2017-07-01 09:52:38 +02:00
|
|
|
$this->assertSame(404, $client->getResponse()->getStatusCode());
|
2015-10-30 20:57:10 +01:00
|
|
|
|
|
|
|
$content = $client->getContainer()
|
2022-08-28 02:01:46 +02:00
|
|
|
->get(EntityManagerInterface::class)
|
2022-08-25 21:37:10 +02:00
|
|
|
->getRepository(Entry::class)
|
2015-10-30 20:57:10 +01:00
|
|
|
->findOneByUsernameAndNotArchived('admin');
|
|
|
|
|
2017-07-01 09:52:38 +02:00
|
|
|
$client->request('GET', '/export/' . $content->getId() . '.doc');
|
|
|
|
$this->assertSame(404, $client->getResponse()->getStatusCode());
|
2015-10-30 20:57:10 +01:00
|
|
|
}
|
|
|
|
|
2023-01-12 23:40:16 +01:00
|
|
|
public function testNonExistingEntryId()
|
2015-10-30 20:57:10 +01:00
|
|
|
{
|
|
|
|
$this->logInAs('admin');
|
2022-11-23 17:09:32 +01:00
|
|
|
$client = $this->getTestClient();
|
2015-10-30 20:57:10 +01:00
|
|
|
|
2023-08-23 08:44:40 +02:00
|
|
|
$client->request('GET', '/export/0.pdf');
|
2015-10-16 10:51:53 +02:00
|
|
|
|
2017-07-01 09:52:38 +02:00
|
|
|
$this->assertSame(404, $client->getResponse()->getStatusCode());
|
2015-10-16 10:51:53 +02:00
|
|
|
}
|
|
|
|
|
2023-01-12 23:40:16 +01:00
|
|
|
public function testForbiddenEntryId()
|
|
|
|
{
|
|
|
|
$this->logInAs('admin');
|
2023-04-24 14:36:32 +02:00
|
|
|
$client = $this->getTestClient();
|
2023-01-12 23:40:16 +01:00
|
|
|
|
2023-02-01 09:51:02 +01:00
|
|
|
$content = $client->getContainer()
|
|
|
|
->get('doctrine.orm.entity_manager')
|
2023-04-24 14:36:32 +02:00
|
|
|
->getRepository(Entry::class)
|
2023-02-01 09:51:02 +01:00
|
|
|
->findOneByUsernameAndNotArchived('bob');
|
|
|
|
|
2023-08-23 08:44:40 +02:00
|
|
|
$client->request('GET', '/export/' . $content->getId() . '.pdf');
|
2023-01-12 23:40:16 +01:00
|
|
|
|
|
|
|
$this->assertSame(404, $client->getResponse()->getStatusCode());
|
|
|
|
}
|
|
|
|
|
2015-10-16 10:51:53 +02:00
|
|
|
public function testEpubExport()
|
|
|
|
{
|
|
|
|
$this->logInAs('admin');
|
2022-11-23 17:09:32 +01:00
|
|
|
$client = $this->getTestClient();
|
2015-10-16 10:51:53 +02:00
|
|
|
|
|
|
|
ob_start();
|
|
|
|
$crawler = $client->request('GET', '/export/archive.epub');
|
|
|
|
ob_end_clean();
|
|
|
|
|
2017-07-01 09:52:38 +02:00
|
|
|
$this->assertSame(200, $client->getResponse()->getStatusCode());
|
2015-10-16 10:51:53 +02:00
|
|
|
|
|
|
|
$headers = $client->getResponse()->headers;
|
2017-07-01 09:52:38 +02:00
|
|
|
$this->assertSame('application/epub+zip', $headers->get('content-type'));
|
|
|
|
$this->assertSame('attachment; filename="Archive articles.epub"', $headers->get('content-disposition'));
|
|
|
|
$this->assertSame('binary', $headers->get('content-transfer-encoding'));
|
2015-10-16 10:51:53 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
public function testPdfExport()
|
|
|
|
{
|
|
|
|
$this->logInAs('admin');
|
2022-11-23 17:09:32 +01:00
|
|
|
$client = $this->getTestClient();
|
2015-10-16 10:51:53 +02:00
|
|
|
|
|
|
|
ob_start();
|
|
|
|
$crawler = $client->request('GET', '/export/all.pdf');
|
|
|
|
ob_end_clean();
|
|
|
|
|
2017-07-01 09:52:38 +02:00
|
|
|
$this->assertSame(200, $client->getResponse()->getStatusCode());
|
2015-10-16 10:51:53 +02:00
|
|
|
|
|
|
|
$headers = $client->getResponse()->headers;
|
2017-07-01 09:52:38 +02:00
|
|
|
$this->assertSame('application/pdf', $headers->get('content-type'));
|
|
|
|
$this->assertSame('attachment; filename="All articles.pdf"', $headers->get('content-disposition'));
|
|
|
|
$this->assertSame('binary', $headers->get('content-transfer-encoding'));
|
2016-10-29 14:03:55 +02:00
|
|
|
|
|
|
|
ob_start();
|
2023-01-09 22:18:23 +01:00
|
|
|
$crawler = $client->request('GET', '/export/tag_entries.pdf?tag=t:foo-bar');
|
2016-10-29 14:03:55 +02:00
|
|
|
ob_end_clean();
|
|
|
|
|
2017-07-01 09:52:38 +02:00
|
|
|
$this->assertSame(200, $client->getResponse()->getStatusCode());
|
2016-10-29 14:03:55 +02:00
|
|
|
|
|
|
|
$headers = $client->getResponse()->headers;
|
2017-07-01 09:52:38 +02:00
|
|
|
$this->assertSame('application/pdf', $headers->get('content-type'));
|
2019-01-07 23:50:08 +01:00
|
|
|
$this->assertSame('attachment; filename="Tag foo bar articles.pdf"', $headers->get('content-disposition'));
|
2017-07-01 09:52:38 +02:00
|
|
|
$this->assertSame('binary', $headers->get('content-transfer-encoding'));
|
2015-10-16 10:51:53 +02:00
|
|
|
}
|
|
|
|
|
2016-01-25 22:25:55 +01:00
|
|
|
public function testTxtExport()
|
|
|
|
{
|
|
|
|
$this->logInAs('admin');
|
2022-11-23 17:09:32 +01:00
|
|
|
$client = $this->getTestClient();
|
2016-01-25 22:25:55 +01:00
|
|
|
|
|
|
|
ob_start();
|
|
|
|
$crawler = $client->request('GET', '/export/all.txt');
|
|
|
|
ob_end_clean();
|
|
|
|
|
2017-07-01 09:52:38 +02:00
|
|
|
$this->assertSame(200, $client->getResponse()->getStatusCode());
|
2016-01-25 22:25:55 +01:00
|
|
|
|
|
|
|
$headers = $client->getResponse()->headers;
|
2017-07-01 09:52:38 +02:00
|
|
|
$this->assertSame('text/plain; charset=UTF-8', $headers->get('content-type'));
|
|
|
|
$this->assertSame('attachment; filename="All articles.txt"', $headers->get('content-disposition'));
|
|
|
|
$this->assertSame('UTF-8', $headers->get('content-transfer-encoding'));
|
2016-01-25 22:25:55 +01:00
|
|
|
}
|
|
|
|
|
2015-10-16 10:51:53 +02:00
|
|
|
public function testCsvExport()
|
|
|
|
{
|
|
|
|
$this->logInAs('admin');
|
2022-11-23 17:09:32 +01:00
|
|
|
$client = $this->getTestClient();
|
2015-10-16 10:51:53 +02:00
|
|
|
|
2015-10-30 20:57:10 +01:00
|
|
|
// to be sure results are the same
|
|
|
|
$contentInDB = $client->getContainer()
|
2022-08-28 02:01:46 +02:00
|
|
|
->get(EntityManagerInterface::class)
|
2022-08-25 21:37:10 +02:00
|
|
|
->getRepository(Entry::class)
|
2015-10-30 20:57:10 +01:00
|
|
|
->createQueryBuilder('e')
|
2016-10-02 16:06:42 +02:00
|
|
|
->select('e, t')
|
2015-10-30 20:57:10 +01:00
|
|
|
->leftJoin('e.user', 'u')
|
2016-10-02 16:06:42 +02:00
|
|
|
->leftJoin('e.tags', 't')
|
2015-10-30 20:57:10 +01:00
|
|
|
->where('u.username = :username')->setParameter('username', 'admin')
|
|
|
|
->andWhere('e.isArchived = true')
|
|
|
|
->getQuery()
|
|
|
|
->getArrayResult();
|
|
|
|
|
2015-10-16 10:51:53 +02:00
|
|
|
ob_start();
|
2015-10-30 20:57:10 +01:00
|
|
|
$crawler = $client->request('GET', '/export/archive.csv');
|
2015-10-16 10:51:53 +02:00
|
|
|
ob_end_clean();
|
|
|
|
|
2017-07-01 09:52:38 +02:00
|
|
|
$this->assertSame(200, $client->getResponse()->getStatusCode());
|
2015-10-16 10:51:53 +02:00
|
|
|
|
|
|
|
$headers = $client->getResponse()->headers;
|
2017-07-01 09:52:38 +02:00
|
|
|
$this->assertSame('application/csv', $headers->get('content-type'));
|
|
|
|
$this->assertSame('attachment; filename="Archive articles.csv"', $headers->get('content-disposition'));
|
|
|
|
$this->assertSame('UTF-8', $headers->get('content-transfer-encoding'));
|
2015-10-16 10:51:53 +02:00
|
|
|
|
|
|
|
$csv = str_getcsv($client->getResponse()->getContent(), "\n");
|
|
|
|
|
|
|
|
$this->assertGreaterThan(1, $csv);
|
2015-10-30 20:57:10 +01:00
|
|
|
// +1 for title line
|
2019-01-17 14:28:05 +01:00
|
|
|
$this->assertCount(\count($contentInDB) + 1, $csv);
|
2017-07-01 09:52:38 +02:00
|
|
|
$this->assertSame('Title;URL;Content;Tags;"MIME Type";Language;"Creation date"', $csv[0]);
|
2020-06-15 13:37:50 +02:00
|
|
|
$this->assertStringContainsString($contentInDB[0]['title'], $csv[1]);
|
|
|
|
$this->assertStringContainsString($contentInDB[0]['url'], $csv[1]);
|
|
|
|
$this->assertStringContainsString($contentInDB[0]['content'], $csv[1]);
|
|
|
|
$this->assertStringContainsString($contentInDB[0]['mimetype'], $csv[1]);
|
|
|
|
$this->assertStringContainsString($contentInDB[0]['language'], $csv[1]);
|
|
|
|
$this->assertStringContainsString($contentInDB[0]['createdAt']->format('d/m/Y h:i:s'), $csv[1]);
|
2016-10-02 16:06:42 +02:00
|
|
|
|
|
|
|
foreach ($contentInDB[0]['tags'] as $tag) {
|
2020-06-15 13:37:50 +02:00
|
|
|
$this->assertStringContainsString($tag['label'], $csv[1]);
|
2016-10-02 16:06:42 +02:00
|
|
|
}
|
2015-10-16 10:51:53 +02:00
|
|
|
}
|
2015-10-18 15:49:00 +02:00
|
|
|
|
|
|
|
public function testJsonExport()
|
|
|
|
{
|
|
|
|
$this->logInAs('admin');
|
2022-11-23 17:09:32 +01:00
|
|
|
$client = $this->getTestClient();
|
2015-10-18 15:49:00 +02:00
|
|
|
|
2015-10-30 20:57:10 +01:00
|
|
|
$contentInDB = $client->getContainer()
|
2022-08-28 02:01:46 +02:00
|
|
|
->get(EntityManagerInterface::class)
|
2022-08-25 21:37:10 +02:00
|
|
|
->getRepository(Entry::class)
|
2016-10-02 16:53:52 +02:00
|
|
|
->findByUrlAndUserId('http://0.0.0.0/entry1', $this->getLoggedInUserId());
|
2015-10-30 20:57:10 +01:00
|
|
|
|
2015-10-18 15:49:00 +02:00
|
|
|
ob_start();
|
2017-07-01 09:52:38 +02:00
|
|
|
$crawler = $client->request('GET', '/export/' . $contentInDB->getId() . '.json');
|
2015-10-18 15:49:00 +02:00
|
|
|
ob_end_clean();
|
|
|
|
|
2017-07-01 09:52:38 +02:00
|
|
|
$this->assertSame(200, $client->getResponse()->getStatusCode());
|
2015-10-18 15:49:00 +02:00
|
|
|
|
|
|
|
$headers = $client->getResponse()->headers;
|
2017-07-01 09:52:38 +02:00
|
|
|
$this->assertSame('application/json', $headers->get('content-type'));
|
2019-01-07 23:50:08 +01:00
|
|
|
$this->assertSame('attachment; filename="' . $this->getSanitizedFilename($contentInDB->getTitle()) . '.json"', $headers->get('content-disposition'));
|
2017-07-01 09:52:38 +02:00
|
|
|
$this->assertSame('UTF-8', $headers->get('content-transfer-encoding'));
|
2015-10-30 20:57:10 +01:00
|
|
|
|
|
|
|
$content = json_decode($client->getResponse()->getContent(), true);
|
|
|
|
$this->assertArrayHasKey('id', $content[0]);
|
|
|
|
$this->assertArrayHasKey('title', $content[0]);
|
|
|
|
$this->assertArrayHasKey('url', $content[0]);
|
|
|
|
$this->assertArrayHasKey('is_archived', $content[0]);
|
|
|
|
$this->assertArrayHasKey('is_starred', $content[0]);
|
|
|
|
$this->assertArrayHasKey('content', $content[0]);
|
|
|
|
$this->assertArrayHasKey('mimetype', $content[0]);
|
|
|
|
$this->assertArrayHasKey('language', $content[0]);
|
|
|
|
$this->assertArrayHasKey('reading_time', $content[0]);
|
|
|
|
$this->assertArrayHasKey('domain_name', $content[0]);
|
|
|
|
$this->assertArrayHasKey('tags', $content[0]);
|
2016-09-08 16:38:08 +02:00
|
|
|
$this->assertArrayHasKey('created_at', $content[0]);
|
|
|
|
$this->assertArrayHasKey('updated_at', $content[0]);
|
2016-10-02 16:06:42 +02:00
|
|
|
|
2017-07-03 07:30:54 +02:00
|
|
|
$this->assertSame((int) $contentInDB->isArchived(), $content[0]['is_archived']);
|
|
|
|
$this->assertSame((int) $contentInDB->isStarred(), $content[0]['is_starred']);
|
2017-07-01 09:52:38 +02:00
|
|
|
$this->assertSame($contentInDB->getTitle(), $content[0]['title']);
|
|
|
|
$this->assertSame($contentInDB->getUrl(), $content[0]['url']);
|
|
|
|
$this->assertSame([['text' => 'This is my annotation /o/', 'quote' => 'content']], $content[0]['annotations']);
|
|
|
|
$this->assertSame($contentInDB->getMimetype(), $content[0]['mimetype']);
|
|
|
|
$this->assertSame($contentInDB->getLanguage(), $content[0]['language']);
|
|
|
|
$this->assertSame($contentInDB->getReadingtime(), $content[0]['reading_time']);
|
|
|
|
$this->assertSame($contentInDB->getDomainname(), $content[0]['domain_name']);
|
2017-08-03 16:20:49 +02:00
|
|
|
$this->assertContains('baz', $content[0]['tags']);
|
|
|
|
$this->assertContains('foo', $content[0]['tags']);
|
2015-10-18 15:49:00 +02:00
|
|
|
}
|
|
|
|
|
2020-02-04 22:19:45 +01:00
|
|
|
public function testJsonExportFromSearch()
|
|
|
|
{
|
|
|
|
$this->setUpForJsonExportFromSearch();
|
|
|
|
|
|
|
|
$this->logInAs('admin');
|
2022-11-23 17:09:32 +01:00
|
|
|
$client = $this->getTestClient();
|
2020-02-04 22:19:45 +01:00
|
|
|
|
|
|
|
ob_start();
|
|
|
|
$crawler = $client->request('GET', '/export/search.json?search_entry[term]=entry+search¤tRoute=homepage');
|
|
|
|
ob_end_clean();
|
|
|
|
|
|
|
|
$this->assertSame(200, $client->getResponse()->getStatusCode());
|
|
|
|
|
|
|
|
$headers = $client->getResponse()->headers;
|
|
|
|
$this->assertSame('application/json', $headers->get('content-type'));
|
|
|
|
$this->assertSame('attachment; filename="Search entry search articles.json"', $headers->get('content-disposition'));
|
|
|
|
$this->assertSame('UTF-8', $headers->get('content-transfer-encoding'));
|
|
|
|
|
|
|
|
$content = json_decode($client->getResponse()->getContent(), true);
|
|
|
|
$this->assertCount(1, $content);
|
|
|
|
|
|
|
|
$this->tearDownForJsonExportFromSearch();
|
|
|
|
}
|
|
|
|
|
2015-10-18 15:49:00 +02:00
|
|
|
public function testXmlExport()
|
|
|
|
{
|
|
|
|
$this->logInAs('admin');
|
2022-11-23 17:09:32 +01:00
|
|
|
$client = $this->getTestClient();
|
2015-10-18 15:49:00 +02:00
|
|
|
|
2015-10-30 20:57:10 +01:00
|
|
|
// to be sure results are the same
|
|
|
|
$contentInDB = $client->getContainer()
|
2022-08-28 02:01:46 +02:00
|
|
|
->get(EntityManagerInterface::class)
|
2022-08-25 21:37:10 +02:00
|
|
|
->getRepository(Entry::class)
|
2015-10-30 20:57:10 +01:00
|
|
|
->createQueryBuilder('e')
|
|
|
|
->leftJoin('e.user', 'u')
|
|
|
|
->where('u.username = :username')->setParameter('username', 'admin')
|
|
|
|
->andWhere('e.isArchived = false')
|
|
|
|
->getQuery()
|
|
|
|
->getArrayResult();
|
|
|
|
|
2015-10-18 15:49:00 +02:00
|
|
|
ob_start();
|
|
|
|
$crawler = $client->request('GET', '/export/unread.xml');
|
|
|
|
ob_end_clean();
|
|
|
|
|
2017-07-01 09:52:38 +02:00
|
|
|
$this->assertSame(200, $client->getResponse()->getStatusCode());
|
2015-10-18 15:49:00 +02:00
|
|
|
|
|
|
|
$headers = $client->getResponse()->headers;
|
2017-07-01 09:52:38 +02:00
|
|
|
$this->assertSame('application/xml', $headers->get('content-type'));
|
|
|
|
$this->assertSame('attachment; filename="Unread articles.xml"', $headers->get('content-disposition'));
|
|
|
|
$this->assertSame('UTF-8', $headers->get('content-transfer-encoding'));
|
2015-10-30 20:57:10 +01:00
|
|
|
|
|
|
|
$content = new \SimpleXMLElement($client->getResponse()->getContent());
|
|
|
|
$this->assertGreaterThan(0, $content->count());
|
2020-06-15 13:37:50 +02:00
|
|
|
$this->assertCount(\count($contentInDB), $content);
|
2015-10-30 20:57:10 +01:00
|
|
|
$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('content', (string) $content->entry[0]->content);
|
|
|
|
$this->assertNotEmpty('domain_name', (string) $content->entry[0]->domain_name);
|
2016-09-08 16:38:08 +02:00
|
|
|
$this->assertNotEmpty('created_at', (string) $content->entry[0]->created_at);
|
|
|
|
$this->assertNotEmpty('updated_at', (string) $content->entry[0]->updated_at);
|
2015-10-18 15:49:00 +02:00
|
|
|
}
|
2019-01-07 23:50:08 +01:00
|
|
|
|
2023-06-29 17:10:23 +02:00
|
|
|
public function testJsonExportFromSameDomain()
|
|
|
|
{
|
|
|
|
$this->logInAs('admin');
|
|
|
|
$client = $this->getTestClient();
|
|
|
|
|
|
|
|
ob_start();
|
|
|
|
$crawler = $client->request('GET', '/export/same_domain.json?entry=1');
|
|
|
|
ob_end_clean();
|
|
|
|
|
|
|
|
$this->assertSame(200, $client->getResponse()->getStatusCode());
|
|
|
|
|
|
|
|
$headers = $client->getResponse()->headers;
|
|
|
|
$this->assertSame('application/json', $headers->get('content-type'));
|
|
|
|
$this->assertSame('attachment; filename="Same domain articles.json"', $headers->get('content-disposition'));
|
|
|
|
$this->assertSame('UTF-8', $headers->get('content-transfer-encoding'));
|
|
|
|
|
|
|
|
$content = json_decode($client->getResponse()->getContent(), true);
|
|
|
|
$this->assertCount(4, $content);
|
|
|
|
}
|
|
|
|
|
2020-02-04 22:19:45 +01:00
|
|
|
private function setUpForJsonExportFromSearch()
|
|
|
|
{
|
2022-11-23 17:09:32 +01:00
|
|
|
$client = $this->getTestClient();
|
2020-02-04 22:19:45 +01:00
|
|
|
$em = $this->getEntityManager();
|
|
|
|
|
|
|
|
$userRepository = $client->getContainer()
|
|
|
|
->get('wallabag_user.user_repository.test');
|
|
|
|
|
|
|
|
$user = $userRepository->findOneByUserName('admin');
|
|
|
|
$this->adminEntry = new Entry($user);
|
|
|
|
$this->adminEntry->setUrl('http://0.0.0.0/entry-search-admin');
|
|
|
|
$this->adminEntry->setTitle('test title entry search admin');
|
|
|
|
$this->adminEntry->setContent('this is my content /o/');
|
|
|
|
$em->persist($this->adminEntry);
|
|
|
|
|
|
|
|
$user = $userRepository->findOneByUserName('bob');
|
|
|
|
$this->bobEntry = new Entry($user);
|
|
|
|
$this->bobEntry->setUrl('http://0.0.0.0/entry-search-bob');
|
|
|
|
$this->bobEntry->setTitle('test title entry search bob');
|
|
|
|
$this->bobEntry->setContent('this is my content /o/');
|
|
|
|
$em->persist($this->bobEntry);
|
|
|
|
|
|
|
|
$em->flush();
|
|
|
|
}
|
|
|
|
|
|
|
|
private function tearDownForJsonExportFromSearch()
|
|
|
|
{
|
|
|
|
$em = $this->getEntityManager();
|
|
|
|
|
|
|
|
$em->remove($this->adminEntry);
|
|
|
|
$em->remove($this->bobEntry);
|
|
|
|
|
|
|
|
$em->flush();
|
|
|
|
}
|
|
|
|
|
2019-01-07 23:50:08 +01:00
|
|
|
private function getSanitizedFilename($title)
|
|
|
|
{
|
2022-03-20 22:51:27 +01:00
|
|
|
$transliterator = \Transliterator::createFromRules(':: Any-Latin; :: Latin-ASCII; :: NFD; :: [:Nonspacing Mark:] Remove; :: NFC;', \Transliterator::FORWARD);
|
|
|
|
|
|
|
|
return preg_replace('/[^A-Za-z0-9\- \']/', '', $transliterator->transliterate($title));
|
2019-01-07 23:50:08 +01:00
|
|
|
}
|
2015-10-16 10:51:53 +02:00
|
|
|
}
|