forked from wallabag/wallabag
Merge remote-tracking branch 'origin/master' into 2.5.0
This commit is contained in:
@ -15,6 +15,7 @@ class EntryControllerTest extends WallabagCoreTestCase
|
||||
const AN_URL_CONTAINING_AN_ARTICLE_WITH_IMAGE = 'https://www.lemonde.fr/judo/article/2017/11/11/judo-la-decima-de-teddy-riner_5213605_1556020.html';
|
||||
public $downloadImagesEnabled = false;
|
||||
public $url = 'https://www.lemonde.fr/pixels/article/2019/06/18/ce-qu-il-faut-savoir-sur-le-libra-la-cryptomonnaie-de-facebook_5477887_4408996.html';
|
||||
private $entryDataTestAttribute = '[data-test="entry"]';
|
||||
|
||||
/**
|
||||
* @after
|
||||
@ -101,14 +102,14 @@ class EntryControllerTest extends WallabagCoreTestCase
|
||||
|
||||
$crawler = $client->request('GET', '/');
|
||||
|
||||
$this->assertCount(4, $crawler->filter('li.entry'));
|
||||
$this->assertCount(4, $crawler->filter($this->entryDataTestAttribute));
|
||||
|
||||
// Good URL
|
||||
$client->request('GET', '/bookmarklet', ['url' => $this->url]);
|
||||
$this->assertSame(302, $client->getResponse()->getStatusCode());
|
||||
$client->followRedirect();
|
||||
$crawler = $client->request('GET', '/');
|
||||
$this->assertCount(5, $crawler->filter('li.entry'));
|
||||
$this->assertCount(5, $crawler->filter($this->entryDataTestAttribute));
|
||||
|
||||
$em = $client->getContainer()
|
||||
->get('doctrine.orm.entity_manager');
|
||||
@ -176,6 +177,42 @@ class EntryControllerTest extends WallabagCoreTestCase
|
||||
$client->getContainer()->get('craue_config')->set('store_article_headers', 0);
|
||||
}
|
||||
|
||||
/**
|
||||
* @group NetworkCalls
|
||||
*/
|
||||
public function testPostNewOkWithTaggingRules()
|
||||
{
|
||||
$this->logInAs('empty');
|
||||
$client = $this->getClient();
|
||||
|
||||
$crawler = $client->request('GET', '/new');
|
||||
|
||||
$this->assertSame(200, $client->getResponse()->getStatusCode());
|
||||
|
||||
$form = $crawler->filter('form[name=entry]')->form();
|
||||
|
||||
$data = [
|
||||
'entry[url]' => $this->url,
|
||||
];
|
||||
|
||||
$client->submit($form, $data);
|
||||
|
||||
$this->assertSame(302, $client->getResponse()->getStatusCode());
|
||||
|
||||
$content = $client->getContainer()
|
||||
->get('doctrine.orm.entity_manager')
|
||||
->getRepository('WallabagCoreBundle:Entry')
|
||||
->findByUrlAndUserId($this->url, $this->getLoggedInUserId());
|
||||
|
||||
$tags = $content->getTagsLabel();
|
||||
|
||||
/*
|
||||
* Without the custom reading speed of `empty` user, it'll be inversed
|
||||
*/
|
||||
$this->assertContains('longread', $tags);
|
||||
$this->assertNotContains('shortread', $tags);
|
||||
}
|
||||
|
||||
/**
|
||||
* @group NetworkCalls
|
||||
*/
|
||||
@ -734,7 +771,7 @@ class EntryControllerTest extends WallabagCoreTestCase
|
||||
|
||||
$crawler = $client->submit($form, $data);
|
||||
|
||||
$this->assertCount(1, $crawler->filter('li.entry'));
|
||||
$this->assertCount(1, $crawler->filter($this->entryDataTestAttribute));
|
||||
}
|
||||
|
||||
public function testFilterOnReadingTimeWithNegativeValue()
|
||||
@ -754,7 +791,7 @@ class EntryControllerTest extends WallabagCoreTestCase
|
||||
$crawler = $client->submit($form, $data);
|
||||
|
||||
// forcing negative value results in no entry displayed
|
||||
$this->assertCount(0, $crawler->filter('li.entry'));
|
||||
$this->assertCount(0, $crawler->filter($this->entryDataTestAttribute));
|
||||
}
|
||||
|
||||
public function testFilterOnReadingTimeOnlyUpper()
|
||||
@ -763,7 +800,7 @@ class EntryControllerTest extends WallabagCoreTestCase
|
||||
$client = $this->getClient();
|
||||
|
||||
$crawler = $client->request('GET', '/all/list');
|
||||
$this->assertCount(5, $crawler->filter('li.entry'));
|
||||
$this->assertCount(5, $crawler->filter($this->entryDataTestAttribute));
|
||||
|
||||
$entry = new Entry($this->getLoggedInUser());
|
||||
$entry->setUrl($this->url);
|
||||
@ -772,7 +809,7 @@ class EntryControllerTest extends WallabagCoreTestCase
|
||||
$this->getEntityManager()->flush();
|
||||
|
||||
$crawler = $client->request('GET', '/all/list');
|
||||
$this->assertCount(6, $crawler->filter('li.entry'));
|
||||
$this->assertCount(6, $crawler->filter($this->entryDataTestAttribute));
|
||||
|
||||
$form = $crawler->filter('button[id=submit-filter]')->form();
|
||||
|
||||
@ -782,7 +819,7 @@ class EntryControllerTest extends WallabagCoreTestCase
|
||||
|
||||
$crawler = $client->submit($form, $data);
|
||||
|
||||
$this->assertCount(5, $crawler->filter('li.entry'));
|
||||
$this->assertCount(5, $crawler->filter($this->entryDataTestAttribute));
|
||||
}
|
||||
|
||||
public function testFilterOnReadingTimeOnlyLower()
|
||||
@ -800,7 +837,7 @@ class EntryControllerTest extends WallabagCoreTestCase
|
||||
|
||||
$crawler = $client->submit($form, $data);
|
||||
|
||||
$this->assertCount(0, $crawler->filter('li.entry'));
|
||||
$this->assertCount(0, $crawler->filter($this->entryDataTestAttribute));
|
||||
|
||||
$entry = new Entry($this->getLoggedInUser());
|
||||
$entry->setUrl($this->url);
|
||||
@ -809,7 +846,7 @@ class EntryControllerTest extends WallabagCoreTestCase
|
||||
$this->getEntityManager()->flush();
|
||||
|
||||
$crawler = $client->submit($form, $data);
|
||||
$this->assertCount(1, $crawler->filter('li.entry'));
|
||||
$this->assertCount(1, $crawler->filter($this->entryDataTestAttribute));
|
||||
}
|
||||
|
||||
public function testFilterOnUnreadStatus()
|
||||
@ -827,7 +864,7 @@ class EntryControllerTest extends WallabagCoreTestCase
|
||||
|
||||
$crawler = $client->submit($form, $data);
|
||||
|
||||
$this->assertCount(4, $crawler->filter('li.entry'));
|
||||
$this->assertCount(4, $crawler->filter($this->entryDataTestAttribute));
|
||||
|
||||
$entry = new Entry($this->getLoggedInUser());
|
||||
$entry->setUrl($this->url);
|
||||
@ -837,7 +874,7 @@ class EntryControllerTest extends WallabagCoreTestCase
|
||||
|
||||
$crawler = $client->submit($form, $data);
|
||||
|
||||
$this->assertCount(5, $crawler->filter('li.entry'));
|
||||
$this->assertCount(5, $crawler->filter($this->entryDataTestAttribute));
|
||||
}
|
||||
|
||||
public function testFilterOnCreationDate()
|
||||
@ -868,7 +905,7 @@ class EntryControllerTest extends WallabagCoreTestCase
|
||||
|
||||
$crawler = $client->submit($form, $data);
|
||||
|
||||
$this->assertCount(4, $crawler->filter('li.entry'));
|
||||
$this->assertCount(4, $crawler->filter($this->entryDataTestAttribute));
|
||||
|
||||
$data = [
|
||||
'entry_filter[createdAt][left_date]' => $today->format('Y-m-d'),
|
||||
@ -877,7 +914,7 @@ class EntryControllerTest extends WallabagCoreTestCase
|
||||
|
||||
$crawler = $client->submit($form, $data);
|
||||
|
||||
$this->assertCount(4, $crawler->filter('li.entry'));
|
||||
$this->assertCount(4, $crawler->filter($this->entryDataTestAttribute));
|
||||
|
||||
$data = [
|
||||
'entry_filter[createdAt][left_date]' => '1970-01-01',
|
||||
@ -886,7 +923,7 @@ class EntryControllerTest extends WallabagCoreTestCase
|
||||
|
||||
$crawler = $client->submit($form, $data);
|
||||
|
||||
$this->assertCount(0, $crawler->filter('li.entry'));
|
||||
$this->assertCount(0, $crawler->filter($this->entryDataTestAttribute));
|
||||
}
|
||||
|
||||
public function testFilterOnAnnotatedStatus()
|
||||
@ -968,7 +1005,7 @@ class EntryControllerTest extends WallabagCoreTestCase
|
||||
];
|
||||
|
||||
$crawler = $client->submit($form, $data);
|
||||
$this->assertCount(4, $crawler->filter('li.entry'));
|
||||
$this->assertCount(4, $crawler->filter($this->entryDataTestAttribute));
|
||||
|
||||
$crawler = $client->request('GET', '/unread/list');
|
||||
$form = $crawler->filter('button[id=submit-filter]')->form();
|
||||
@ -977,7 +1014,7 @@ class EntryControllerTest extends WallabagCoreTestCase
|
||||
];
|
||||
|
||||
$crawler = $client->submit($form, $data);
|
||||
$this->assertCount(4, $crawler->filter('li.entry'));
|
||||
$this->assertCount(4, $crawler->filter($this->entryDataTestAttribute));
|
||||
|
||||
$form = $crawler->filter('button[id=submit-filter]')->form();
|
||||
$data = [
|
||||
@ -985,7 +1022,7 @@ class EntryControllerTest extends WallabagCoreTestCase
|
||||
];
|
||||
|
||||
$crawler = $client->submit($form, $data);
|
||||
$this->assertCount(0, $crawler->filter('li.entry'));
|
||||
$this->assertCount(0, $crawler->filter($this->entryDataTestAttribute));
|
||||
}
|
||||
|
||||
public function testFilterOnStatus()
|
||||
@ -1000,14 +1037,14 @@ class EntryControllerTest extends WallabagCoreTestCase
|
||||
$form['entry_filter[isUnread]']->untick();
|
||||
|
||||
$crawler = $client->submit($form);
|
||||
$this->assertCount(1, $crawler->filter('li.entry'));
|
||||
$this->assertCount(1, $crawler->filter($this->entryDataTestAttribute));
|
||||
|
||||
$form = $crawler->filter('button[id=submit-filter]')->form();
|
||||
$form['entry_filter[isArchived]']->untick();
|
||||
$form['entry_filter[isStarred]']->tick();
|
||||
|
||||
$crawler = $client->submit($form);
|
||||
$this->assertCount(1, $crawler->filter('li.entry'));
|
||||
$this->assertCount(1, $crawler->filter($this->entryDataTestAttribute));
|
||||
}
|
||||
|
||||
public function testFilterPreselectedStatus()
|
||||
@ -1044,7 +1081,7 @@ class EntryControllerTest extends WallabagCoreTestCase
|
||||
$form['entry_filter[isPublic]']->tick();
|
||||
|
||||
$crawler = $client->submit($form);
|
||||
$this->assertCount(0, $crawler->filter('li.entry'));
|
||||
$this->assertCount(0, $crawler->filter($this->entryDataTestAttribute));
|
||||
}
|
||||
|
||||
public function testPreviewPictureFilter()
|
||||
@ -1057,7 +1094,7 @@ class EntryControllerTest extends WallabagCoreTestCase
|
||||
$form['entry_filter[previewPicture]']->tick();
|
||||
|
||||
$crawler = $client->submit($form);
|
||||
$this->assertCount(1, $crawler->filter('li.entry'));
|
||||
$this->assertCount(1, $crawler->filter($this->entryDataTestAttribute));
|
||||
}
|
||||
|
||||
public function testFilterOnLanguage()
|
||||
@ -1078,7 +1115,7 @@ class EntryControllerTest extends WallabagCoreTestCase
|
||||
];
|
||||
|
||||
$crawler = $client->submit($form, $data);
|
||||
$this->assertCount(3, $crawler->filter('li.entry'));
|
||||
$this->assertCount(3, $crawler->filter($this->entryDataTestAttribute));
|
||||
|
||||
$form = $crawler->filter('button[id=submit-filter]')->form();
|
||||
$data = [
|
||||
@ -1086,7 +1123,7 @@ class EntryControllerTest extends WallabagCoreTestCase
|
||||
];
|
||||
|
||||
$crawler = $client->submit($form, $data);
|
||||
$this->assertCount(2, $crawler->filter('li.entry'));
|
||||
$this->assertCount(2, $crawler->filter($this->entryDataTestAttribute));
|
||||
}
|
||||
|
||||
public function testShareEntryPublicly()
|
||||
@ -1289,7 +1326,7 @@ class EntryControllerTest extends WallabagCoreTestCase
|
||||
|
||||
$crawler = $client->submit($form, $data);
|
||||
|
||||
$this->assertCount(1, $crawler->filter('li.entry'));
|
||||
$this->assertCount(1, $crawler->filter($this->entryDataTestAttribute));
|
||||
|
||||
$entry = new Entry($this->getLoggedInUser());
|
||||
$entry->setUrl($this->url);
|
||||
@ -1312,7 +1349,7 @@ class EntryControllerTest extends WallabagCoreTestCase
|
||||
|
||||
$crawler = $client->submit($form, $data);
|
||||
|
||||
$this->assertCount(2, $crawler->filter('li.entry'));
|
||||
$this->assertCount(2, $crawler->filter($this->entryDataTestAttribute));
|
||||
|
||||
$crawler = $client->request('GET', '/all/list');
|
||||
$form = $crawler->filter('button[id=submit-filter]')->form();
|
||||
@ -1323,7 +1360,7 @@ class EntryControllerTest extends WallabagCoreTestCase
|
||||
|
||||
$crawler = $client->submit($form, $data);
|
||||
|
||||
$this->assertCount(8, $crawler->filter('li.entry'));
|
||||
$this->assertCount(8, $crawler->filter($this->entryDataTestAttribute));
|
||||
}
|
||||
|
||||
public function testSearch()
|
||||
@ -1347,7 +1384,7 @@ class EntryControllerTest extends WallabagCoreTestCase
|
||||
|
||||
$crawler = $client->submit($form, $data);
|
||||
|
||||
$this->assertCount(4, $crawler->filter('li.entry'));
|
||||
$this->assertCount(4, $crawler->filter($this->entryDataTestAttribute));
|
||||
|
||||
// Search on starred list
|
||||
$crawler = $client->request('GET', '/starred/list');
|
||||
@ -1366,7 +1403,7 @@ class EntryControllerTest extends WallabagCoreTestCase
|
||||
|
||||
$crawler = $client->submit($form, $data);
|
||||
|
||||
$this->assertCount(1, $crawler->filter('li.entry'));
|
||||
$this->assertCount(1, $crawler->filter($this->entryDataTestAttribute));
|
||||
|
||||
$crawler = $client->request('GET', '/archive/list');
|
||||
|
||||
@ -1385,7 +1422,7 @@ class EntryControllerTest extends WallabagCoreTestCase
|
||||
|
||||
$crawler = $client->submit($form, $data);
|
||||
|
||||
$this->assertCount(1, $crawler->filter('li.entry'));
|
||||
$this->assertCount(1, $crawler->filter($this->entryDataTestAttribute));
|
||||
$client->request('GET', '/delete/' . $entry->getId());
|
||||
|
||||
// test on list of all articles
|
||||
@ -1398,7 +1435,7 @@ class EntryControllerTest extends WallabagCoreTestCase
|
||||
|
||||
$crawler = $client->submit($form, $data);
|
||||
|
||||
$this->assertCount(0, $crawler->filter('li.entry'));
|
||||
$this->assertCount(0, $crawler->filter($this->entryDataTestAttribute));
|
||||
|
||||
// test url search on list of all articles
|
||||
$entry = new Entry($this->getLoggedInUser());
|
||||
@ -1417,7 +1454,7 @@ class EntryControllerTest extends WallabagCoreTestCase
|
||||
|
||||
$crawler = $client->submit($form, $data);
|
||||
|
||||
$this->assertCount(1, $crawler->filter('li.entry'));
|
||||
$this->assertCount(1, $crawler->filter($this->entryDataTestAttribute));
|
||||
|
||||
// same as previous test but for case-sensitivity
|
||||
$crawler = $client->request('GET', '/all/list');
|
||||
@ -1429,7 +1466,7 @@ class EntryControllerTest extends WallabagCoreTestCase
|
||||
|
||||
$crawler = $client->submit($form, $data);
|
||||
|
||||
$this->assertCount(1, $crawler->filter('li.entry'));
|
||||
$this->assertCount(1, $crawler->filter($this->entryDataTestAttribute));
|
||||
}
|
||||
|
||||
public function dataForLanguage()
|
||||
|
||||
@ -347,6 +347,8 @@ class ExportControllerTest extends WallabagCoreTestCase
|
||||
|
||||
private function getSanitizedFilename($title)
|
||||
{
|
||||
return preg_replace('/[^A-Za-z0-9\- \']/', '', iconv('utf-8', 'us-ascii//TRANSLIT', $title));
|
||||
$transliterator = \Transliterator::createFromRules(':: Any-Latin; :: Latin-ASCII; :: NFD; :: [:Nonspacing Mark:] Remove; :: NFC;', \Transliterator::FORWARD);
|
||||
|
||||
return preg_replace('/[^A-Za-z0-9\- \']/', '', $transliterator->transliterate($title));
|
||||
}
|
||||
}
|
||||
|
||||
@ -213,15 +213,62 @@ class FeedControllerTest extends WallabagCoreTestCase
|
||||
$config->setFeedToken('SUPERTOKEN');
|
||||
$config->setFeedLimit(null);
|
||||
$em->persist($config);
|
||||
|
||||
$entry1 = $em
|
||||
->getRepository('WallabagCoreBundle:Entry')
|
||||
->find(1)
|
||||
;
|
||||
|
||||
$entry4 = $em
|
||||
->getRepository('WallabagCoreBundle:Entry')
|
||||
->find(4)
|
||||
;
|
||||
|
||||
$now = new \DateTimeImmutable('now');
|
||||
|
||||
$day1 = $now->modify('-8 days');
|
||||
$day2 = $now->modify('-6 days');
|
||||
$day3 = $now->modify('-4 days');
|
||||
$day4 = $now->modify('-2 days');
|
||||
|
||||
$entry1->setCreatedAt($day1);
|
||||
$entry4->setCreatedAt($day2);
|
||||
|
||||
$property = (new \ReflectionObject($entry1))->getProperty('updatedAt');
|
||||
$property->setAccessible(true);
|
||||
$property->setValue($entry1, $day4);
|
||||
|
||||
$property = (new \ReflectionObject($entry4))->getProperty('updatedAt');
|
||||
$property->setAccessible(true);
|
||||
$property->setValue($entry4, $day3);
|
||||
|
||||
$em->flush();
|
||||
|
||||
$client = $this->getClient();
|
||||
$client->request('GET', '/feed/admin/SUPERTOKEN/tags/foo');
|
||||
|
||||
// tag foo - without sort
|
||||
$crawler = $client->request('GET', '/feed/admin/SUPERTOKEN/tags/foo');
|
||||
$this->assertSame(200, $client->getResponse()->getStatusCode());
|
||||
$this->assertSame('test title entry4', $crawler->filterXPath('//feed/entry[1]/title')->text());
|
||||
$this->assertSame('test title entry1', $crawler->filterXPath('//feed/entry[2]/title')->text());
|
||||
|
||||
$this->validateDom($client->getResponse()->getContent(), 'tag', 2, 'foo');
|
||||
// tag foo - with sort created
|
||||
$crawler = $client->request('GET', '/feed/admin/SUPERTOKEN/tags/foo?sort=created');
|
||||
$this->assertSame(200, $client->getResponse()->getStatusCode());
|
||||
$this->assertSame('test title entry4', $crawler->filterXPath('//feed/entry[1]/title')->text());
|
||||
$this->assertSame('test title entry1', $crawler->filterXPath('//feed/entry[2]/title')->text());
|
||||
|
||||
// tag foo - with sort updated
|
||||
$crawler = $client->request('GET', '/feed/admin/SUPERTOKEN/tags/foo?sort=updated');
|
||||
$this->assertSame(200, $client->getResponse()->getStatusCode());
|
||||
$this->assertSame('test title entry1', $crawler->filterXPath('//feed/entry[1]/title')->text());
|
||||
$this->assertSame('test title entry4', $crawler->filterXPath('//feed/entry[2]/title')->text());
|
||||
|
||||
// tag foo - with invalid sort
|
||||
$client->request('GET', '/feed/admin/SUPERTOKEN/tags/foo?sort=invalid');
|
||||
$this->assertSame(400, $client->getResponse()->getStatusCode());
|
||||
|
||||
// tag foo/3000
|
||||
$client->request('GET', '/feed/admin/SUPERTOKEN/tags/foo/3000');
|
||||
$this->assertSame(302, $client->getResponse()->getStatusCode());
|
||||
}
|
||||
|
||||
@ -476,4 +476,35 @@ class TagControllerTest extends WallabagCoreTestCase
|
||||
$this->assertNotFalse(array_search('cache', $tags, true), 'Tag cache is assigned to the entry');
|
||||
$this->assertNotFalse(array_search('caché', $tags, true), 'Tag caché is assigned to the entry');
|
||||
}
|
||||
|
||||
public function testAssignTagsOnSearchResults()
|
||||
{
|
||||
$this->logInAs('admin');
|
||||
$client = $this->getClient();
|
||||
|
||||
// Search on unread list
|
||||
$crawler = $client->request('GET', '/unread/list');
|
||||
|
||||
$form = $crawler->filter('form[name=search]')->form();
|
||||
$data = [
|
||||
'search_entry[term]' => 'title',
|
||||
];
|
||||
|
||||
$crawler = $client->submit($form, $data);
|
||||
|
||||
$client->click($crawler->selectLink('entry.list.assign_search_tag')->link());
|
||||
$client->followRedirect();
|
||||
|
||||
$entries = $client->getContainer()
|
||||
->get('doctrine.orm.entity_manager')
|
||||
->getRepository('WallabagCoreBundle:Entry')
|
||||
->getBuilderForSearchByUser($this->getLoggedInUserId(), 'title', 'unread')
|
||||
->getQuery()->getResult();
|
||||
|
||||
foreach ($entries as $entry) {
|
||||
$tags = $entry->getTagsLabel();
|
||||
|
||||
$this->assertContains('title', $tags);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user