forked from wallabag/wallabag
Merge remote-tracking branch 'origin/master' into 2.5.0
This commit is contained in:
@ -207,8 +207,8 @@ class EntryControllerTest extends WallabagCoreTestCase
|
||||
$authors = $content->getPublishedBy();
|
||||
$this->assertSame('2017-04-05', $content->getPublishedAt()->format('Y-m-d'));
|
||||
$this->assertSame('fr', $content->getLanguage());
|
||||
$this->assertContains('Balenieri', $authors[0]);
|
||||
$this->assertContains('Autran', $authors[1]);
|
||||
$this->assertStringContainsString('Balenieri', $authors[0]);
|
||||
$this->assertStringContainsString('Autran', $authors[1]);
|
||||
}
|
||||
|
||||
public function testPostNewOkUrlExist()
|
||||
@ -342,7 +342,7 @@ class EntryControllerTest extends WallabagCoreTestCase
|
||||
$entry = $em
|
||||
->getRepository('WallabagCoreBundle:Entry')
|
||||
->findOneByUrl($url);
|
||||
$tags = $entry->getTags();
|
||||
$tags = $entry->getTagsLabel();
|
||||
|
||||
$this->assertCount(2, $tags);
|
||||
$this->assertContains('wallabag', $tags);
|
||||
@ -372,7 +372,7 @@ class EntryControllerTest extends WallabagCoreTestCase
|
||||
->getRepository('WallabagCoreBundle:Entry')
|
||||
->findOneByUrl($url);
|
||||
|
||||
$tags = $entry->getTags();
|
||||
$tags = $entry->getTagsLabel();
|
||||
|
||||
$this->assertCount(2, $tags);
|
||||
$this->assertContains('wallabag', $tags);
|
||||
@ -1387,7 +1387,7 @@ class EntryControllerTest extends WallabagCoreTestCase
|
||||
{
|
||||
return [
|
||||
'ru' => [
|
||||
'https://www.vtimes.io/2020/12/14/ubiistvo-kotorogo-ne-bilo-a1981',
|
||||
'https://ru.wikipedia.org/wiki/Открытое_программное_обеспечение',
|
||||
'ru',
|
||||
],
|
||||
'fr' => [
|
||||
@ -1410,10 +1410,6 @@ class EntryControllerTest extends WallabagCoreTestCase
|
||||
'https://politica.estadao.com.br/noticias/eleicoes,campanha-catatonica,70002491983',
|
||||
'pt_BR',
|
||||
],
|
||||
'fucked_list_of_languages' => [
|
||||
'http://geocatalog.webservice-energy.org/geonetwork/srv/eng/main.home',
|
||||
null,
|
||||
],
|
||||
'es-ES' => [
|
||||
'https://www.20minutos.es/noticia/3360685/0/gobierno-sanchez-primero-historia-mas-mujeres-que-hombres/',
|
||||
'es_ES',
|
||||
|
||||
@ -46,7 +46,7 @@ class TagControllerTest extends WallabagCoreTestCase
|
||||
// be sure to reload the entry
|
||||
$entry = $this->getEntityManager()->getRepository(Entry::class)->find($entry->getId());
|
||||
$this->assertCount(1, $entry->getTags());
|
||||
$this->assertContains($this->tagName, $entry->getTags());
|
||||
$this->assertContains($this->tagName, $entry->getTagsLabel());
|
||||
|
||||
// tag already exists and already assigned
|
||||
$client->submit($form, $data);
|
||||
@ -127,7 +127,7 @@ class TagControllerTest extends WallabagCoreTestCase
|
||||
|
||||
// re-retrieve the entry to be sure to get fresh data from database (mostly for tags)
|
||||
$entry = $this->getEntityManager()->getRepository(Entry::class)->find($entry->getId());
|
||||
$this->assertNotContains($this->tagName, $entry->getTags());
|
||||
$this->assertNotContains($this->tagName, $entry->getTagsLabel());
|
||||
|
||||
$client->request('GET', '/remove-tag/' . $entry->getId() . '/' . $tag->getId());
|
||||
|
||||
@ -195,7 +195,7 @@ class TagControllerTest extends WallabagCoreTestCase
|
||||
$entry2 = new Entry($this->getLoggedInUser());
|
||||
$entry2->setUrl('http://0.0.0.0/bar');
|
||||
$entry2->addTag($tag);
|
||||
$this->getEntityManager()->persist($entry);
|
||||
$this->getEntityManager()->persist($entry2);
|
||||
|
||||
$this->getEntityManager()->flush();
|
||||
$this->getEntityManager()->clear();
|
||||
|
||||
@ -31,7 +31,6 @@ class DownloadImagesTest extends TestCase
|
||||
public function testProcessHtml($html, $url)
|
||||
{
|
||||
$httpMockClient = new HttpMockClient();
|
||||
|
||||
$httpMockClient->addResponse(new Response(200, ['content-type' => 'image/png'], file_get_contents(__DIR__ . '/../fixtures/unnamed.png')));
|
||||
|
||||
$logHandler = new TestHandler();
|
||||
@ -201,4 +200,23 @@ class DownloadImagesTest extends TestCase
|
||||
);
|
||||
$this->assertFalse($res);
|
||||
}
|
||||
|
||||
public function testEnsureOnlyFirstOccurenceIsReplaced()
|
||||
{
|
||||
$httpMockClient = new HttpMockClient();
|
||||
$httpMockClient->addResponse(new Response(200, ['content-type' => 'image/png'], file_get_contents(__DIR__ . '/../fixtures/unnamed.png')));
|
||||
$httpMockClient->addResponse(new Response(200, ['content-type' => 'image/png'], file_get_contents(__DIR__ . '/../fixtures/unnamed.png')));
|
||||
|
||||
$logHandler = new TestHandler();
|
||||
$logger = new Logger('test', [$logHandler]);
|
||||
|
||||
$download = new DownloadImages($httpMockClient, sys_get_temp_dir() . '/wallabag_test', 'http://wallabag.io/', $logger);
|
||||
|
||||
$html = '<img src="https://images.wsj.net/im-410981?width=860&height=573" srcset="https://images.wsj.net/im-410981?width=860&height=573&pixel_ratio=1.5 1290w" height="573" width="860" alt="" referrerpolicy="no-referrer">';
|
||||
$url = 'https://www.wsj.com/articles/5-interior-design-tips-to-max-out-your-basement-space-11633435201';
|
||||
|
||||
$res = $download->processHtml(123, $html, $url);
|
||||
|
||||
$this->assertSame('<img src="http://wallabag.io/assets/images/9/b/9b0ead26/6bef06fe.png" srcset="http://wallabag.io/assets/images/9/b/9b0ead26/43cc0123.png 1290w" height="573" width="860" alt="" referrerpolicy="no-referrer">', $res);
|
||||
}
|
||||
}
|
||||
|
||||
@ -139,6 +139,37 @@ class RuleBasedTaggerTest extends TestCase
|
||||
$this->assertCount(1, $records);
|
||||
}
|
||||
|
||||
public function testWithMixedCaseTag()
|
||||
{
|
||||
$taggingRule = $this->getTaggingRule('rule as string', ['Foo']);
|
||||
$user = $this->getUser([$taggingRule]);
|
||||
$entry = new Entry($user);
|
||||
$tag = new Tag();
|
||||
|
||||
$this->rulerz
|
||||
->expects($this->once())
|
||||
->method('satisfies')
|
||||
->with($entry, 'rule as string')
|
||||
->willReturn(true);
|
||||
|
||||
$this->tagRepository
|
||||
->expects($this->once())
|
||||
// the method `findOneByLabel` doesn't exist, EntityRepository will then call `_call` method
|
||||
// to magically call the `findOneBy` with ['label' => 'foo']
|
||||
->method('__call')
|
||||
->with('findOneByLabel', ['foo'])
|
||||
->willReturn($tag);
|
||||
|
||||
$this->tagger->tag($entry);
|
||||
|
||||
$this->assertFalse($entry->getTags()->isEmpty());
|
||||
|
||||
$tags = $entry->getTags();
|
||||
$this->assertSame($tag, $tags[0]);
|
||||
$records = $this->handler->getRecords();
|
||||
$this->assertCount(1, $records);
|
||||
}
|
||||
|
||||
public function testSameTagWithDifferentfMatchingRules()
|
||||
{
|
||||
$taggingRule = $this->getTaggingRule('bla bla', ['hey']);
|
||||
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 346 KiB After Width: | Height: | Size: 314 KiB |
Binary file not shown.
|
Before Width: | Height: | Size: 3.6 KiB After Width: | Height: | Size: 3.2 KiB |
Reference in New Issue
Block a user