forked from wallabag/wallabag
committed by
Nicolas Lœuillet
parent
85065b509f
commit
20578f0b8e
@ -190,6 +190,7 @@ class EntryRestControllerTest extends WallabagApiTestCase
|
||||
'tags' => 'foo',
|
||||
'since' => 1443274283,
|
||||
'public' => 0,
|
||||
'notParsed' => 0,
|
||||
]);
|
||||
|
||||
$this->assertSame(200, $this->client->getResponse()->getStatusCode());
|
||||
@ -348,6 +349,60 @@ class EntryRestControllerTest extends WallabagApiTestCase
|
||||
$this->assertSame('application/json', $this->client->getResponse()->headers->get('Content-Type'));
|
||||
}
|
||||
|
||||
public function testGetNotParsedEntries()
|
||||
{
|
||||
$this->client->request('GET', '/api/entries', ['notParsed' => 1]);
|
||||
|
||||
$this->assertSame(200, $this->client->getResponse()->getStatusCode());
|
||||
|
||||
$content = json_decode($this->client->getResponse()->getContent(), true);
|
||||
|
||||
$this->assertGreaterThanOrEqual(1, \count($content));
|
||||
$this->assertNotEmpty($content['_embedded']['items']);
|
||||
$this->assertGreaterThanOrEqual(1, $content['total']);
|
||||
$this->assertSame(1, $content['page']);
|
||||
$this->assertGreaterThanOrEqual(1, $content['pages']);
|
||||
|
||||
$this->assertArrayHasKey('_links', $content);
|
||||
$this->assertArrayHasKey('self', $content['_links']);
|
||||
$this->assertArrayHasKey('first', $content['_links']);
|
||||
$this->assertArrayHasKey('last', $content['_links']);
|
||||
|
||||
foreach (['self', 'first', 'last'] as $link) {
|
||||
$this->assertArrayHasKey('href', $content['_links'][$link]);
|
||||
$this->assertStringContainsString('notParsed=1', $content['_links'][$link]['href']);
|
||||
}
|
||||
|
||||
$this->assertSame('application/json', $this->client->getResponse()->headers->get('Content-Type'));
|
||||
}
|
||||
|
||||
public function testGetParsedEntries()
|
||||
{
|
||||
$this->client->request('GET', '/api/entries', ['notParsed' => 0]);
|
||||
|
||||
$this->assertSame(200, $this->client->getResponse()->getStatusCode());
|
||||
|
||||
$content = json_decode($this->client->getResponse()->getContent(), true);
|
||||
|
||||
$this->assertGreaterThanOrEqual(1, \count($content));
|
||||
$this->assertNotEmpty($content['_embedded']['items']);
|
||||
$this->assertGreaterThanOrEqual(1, $content['total']);
|
||||
$this->assertSame(1, $content['page']);
|
||||
$this->assertGreaterThanOrEqual(1, $content['pages']);
|
||||
|
||||
$this->assertArrayHasKey('_links', $content);
|
||||
$this->assertArrayHasKey('self', $content['_links']);
|
||||
$this->assertArrayHasKey('first', $content['_links']);
|
||||
$this->assertArrayHasKey('last', $content['_links']);
|
||||
|
||||
foreach (['self', 'first', 'last'] as $link) {
|
||||
$this->assertArrayHasKey('href', $content['_links'][$link]);
|
||||
$this->assertStringContainsString('notParsed=0', $content['_links'][$link]['href']);
|
||||
}
|
||||
|
||||
$this->assertSame('application/json', $this->client->getResponse()->headers->get('Content-Type'));
|
||||
}
|
||||
|
||||
public function testGetTaggedEntries()
|
||||
{
|
||||
$this->client->request('GET', '/api/entries', ['tags' => 'foo,bar']);
|
||||
|
||||
@ -21,6 +21,16 @@ class ReloadEntryCommandTest extends WallabagCoreTestCase
|
||||
*/
|
||||
public $bobEntry;
|
||||
|
||||
/**
|
||||
* @var Entry
|
||||
*/
|
||||
public $bobParsedEntry;
|
||||
|
||||
/**
|
||||
* @var Entry
|
||||
*/
|
||||
public $bobNotParsedEntry;
|
||||
|
||||
protected function setUp(): void
|
||||
{
|
||||
parent::setUp();
|
||||
@ -41,6 +51,19 @@ class ReloadEntryCommandTest extends WallabagCoreTestCase
|
||||
$this->bobEntry->setContent('');
|
||||
$this->getEntityManager()->persist($this->bobEntry);
|
||||
|
||||
$this->bobParsedEntry = new Entry($user);
|
||||
$this->bobParsedEntry->setUrl($this->url);
|
||||
$this->bobParsedEntry->setTitle('title foo');
|
||||
$this->bobParsedEntry->setContent('');
|
||||
$this->getEntityManager()->persist($this->bobParsedEntry);
|
||||
|
||||
$this->bobNotParsedEntry = new Entry($user);
|
||||
$this->bobNotParsedEntry->setUrl($this->url);
|
||||
$this->bobNotParsedEntry->setTitle('title foo');
|
||||
$this->bobNotParsedEntry->setContent('');
|
||||
$this->bobNotParsedEntry->setNotParsed(true);
|
||||
$this->getEntityManager()->persist($this->bobNotParsedEntry);
|
||||
|
||||
$this->getEntityManager()->flush();
|
||||
}
|
||||
|
||||
@ -95,6 +118,27 @@ class ReloadEntryCommandTest extends WallabagCoreTestCase
|
||||
$this->assertStringContainsString('Done', $tester->getDisplay());
|
||||
}
|
||||
|
||||
public function testRunReloadEntryWithNotParsedOption()
|
||||
{
|
||||
$application = new Application($this->getTestClient()->getKernel());
|
||||
|
||||
$command = $application->find('wallabag:entry:reload');
|
||||
$tester = new CommandTester($command);
|
||||
$tester->execute([
|
||||
'--only-not-parsed' => true,
|
||||
]);
|
||||
|
||||
$entryRepository = $this->getTestClient()->getContainer()->get('wallabag_core.entry_repository.test');
|
||||
|
||||
$reloadedBobParsedEntry = $entryRepository->find($this->bobParsedEntry->getId());
|
||||
$this->assertEmpty($reloadedBobParsedEntry->getContent());
|
||||
|
||||
$reloadedBobNotParsedEntry = $entryRepository->find($this->bobNotParsedEntry->getId());
|
||||
$this->assertNotEmpty($reloadedBobNotParsedEntry->getContent());
|
||||
|
||||
$this->assertStringContainsString('Done', $tester->getDisplay());
|
||||
}
|
||||
|
||||
public function testRunReloadEntryWithoutEntryCommand()
|
||||
{
|
||||
$application = new Application($this->getTestClient()->getKernel());
|
||||
|
||||
@ -967,6 +967,34 @@ class EntryControllerTest extends WallabagCoreTestCase
|
||||
$this->assertCount(3, $crawler->filter('ol.entries > li'));
|
||||
}
|
||||
|
||||
public function testFilterOnNotCorrectlyParsedStatus()
|
||||
{
|
||||
$this->logInAs('admin');
|
||||
$client = $this->getTestClient();
|
||||
|
||||
$crawler = $client->request('GET', '/all/list');
|
||||
|
||||
$form = $crawler->filter('button[id=submit-filter]')->form();
|
||||
|
||||
$data = [
|
||||
'entry_filter[isNotParsed]' => true,
|
||||
];
|
||||
|
||||
$crawler = $client->submit($form, $data);
|
||||
|
||||
$this->assertCount(1, $crawler->filter($this->entryDataTestAttribute));
|
||||
|
||||
$entry = new Entry($this->getLoggedInUser());
|
||||
$entry->setUrl($this->url);
|
||||
$entry->setNotParsed(true);
|
||||
$this->getEntityManager()->persist($entry);
|
||||
$this->getEntityManager()->flush();
|
||||
|
||||
$crawler = $client->submit($form, $data);
|
||||
|
||||
$this->assertCount(2, $crawler->filter($this->entryDataTestAttribute));
|
||||
}
|
||||
|
||||
public function testPaginationWithFilter()
|
||||
{
|
||||
$this->logInAs('admin');
|
||||
|
||||
@ -57,6 +57,7 @@ class ContentProxyTest extends TestCase
|
||||
$this->assertEmpty($entry->getLanguage());
|
||||
$this->assertSame(0.0, $entry->getReadingTime());
|
||||
$this->assertNull($entry->getDomainName());
|
||||
$this->assertTrue($entry->isNotParsed());
|
||||
}
|
||||
|
||||
public function testWithEmptyContent()
|
||||
@ -96,6 +97,7 @@ class ContentProxyTest extends TestCase
|
||||
$this->assertEmpty($entry->getLanguage());
|
||||
$this->assertSame(0.0, $entry->getReadingTime());
|
||||
$this->assertSame('0.0.0.0', $entry->getDomainName());
|
||||
$this->assertTrue($entry->isNotParsed());
|
||||
}
|
||||
|
||||
public function testWithEmptyContentButOG()
|
||||
@ -138,6 +140,7 @@ class ContentProxyTest extends TestCase
|
||||
$this->assertEmpty($entry->getMimetype());
|
||||
$this->assertSame(0.0, $entry->getReadingTime());
|
||||
$this->assertSame('domain.io', $entry->getDomainName());
|
||||
$this->assertTrue($entry->isNotParsed());
|
||||
}
|
||||
|
||||
public function testWithContent()
|
||||
@ -183,6 +186,7 @@ class ContentProxyTest extends TestCase
|
||||
$this->assertSame('200', $entry->getHttpStatus());
|
||||
$this->assertSame(4.0, $entry->getReadingTime());
|
||||
$this->assertSame('1.1.1.1', $entry->getDomainName());
|
||||
$this->assertFalse($entry->isNotParsed());
|
||||
}
|
||||
|
||||
public function testWithContentAndNoOgImage()
|
||||
@ -228,6 +232,7 @@ class ContentProxyTest extends TestCase
|
||||
$this->assertSame('200', $entry->getHttpStatus());
|
||||
$this->assertSame(4.0, $entry->getReadingTime());
|
||||
$this->assertSame('1.1.1.1', $entry->getDomainName());
|
||||
$this->assertFalse($entry->isNotParsed());
|
||||
}
|
||||
|
||||
public function testWithContentAndContentImage()
|
||||
@ -272,6 +277,7 @@ class ContentProxyTest extends TestCase
|
||||
$this->assertSame('200', $entry->getHttpStatus());
|
||||
$this->assertSame(0.0, $entry->getReadingTime());
|
||||
$this->assertSame('1.1.1.1', $entry->getDomainName());
|
||||
$this->assertFalse($entry->isNotParsed());
|
||||
}
|
||||
|
||||
public function testWithContentImageAndOgImage()
|
||||
@ -316,6 +322,7 @@ class ContentProxyTest extends TestCase
|
||||
$this->assertSame('200', $entry->getHttpStatus());
|
||||
$this->assertSame(0.0, $entry->getReadingTime());
|
||||
$this->assertSame('1.1.1.1', $entry->getDomainName());
|
||||
$this->assertFalse($entry->isNotParsed());
|
||||
}
|
||||
|
||||
public function testWithContentAndBadLanguage()
|
||||
@ -363,6 +370,7 @@ class ContentProxyTest extends TestCase
|
||||
$this->assertSame('200', $entry->getHttpStatus());
|
||||
$this->assertSame(4.0, $entry->getReadingTime());
|
||||
$this->assertSame('1.1.1.1', $entry->getDomainName());
|
||||
$this->assertFalse($entry->isNotParsed());
|
||||
}
|
||||
|
||||
public function testWithContentAndBadOgImage()
|
||||
@ -416,6 +424,7 @@ class ContentProxyTest extends TestCase
|
||||
$this->assertSame('200', $entry->getHttpStatus());
|
||||
$this->assertSame(4.0, $entry->getReadingTime());
|
||||
$this->assertSame('1.1.1.1', $entry->getDomainName());
|
||||
$this->assertFalse($entry->isNotParsed());
|
||||
}
|
||||
|
||||
public function testWithForcedContent()
|
||||
@ -460,6 +469,7 @@ class ContentProxyTest extends TestCase
|
||||
$this->assertContains('Thomas', $entry->getPublishedBy());
|
||||
$this->assertNotNull($entry->getHeaders(), 'Headers are stored, so value is not null');
|
||||
$this->assertContains('no-cache', $entry->getHeaders());
|
||||
$this->assertFalse($entry->isNotParsed());
|
||||
}
|
||||
|
||||
public function testWithForcedContentAndDateTime()
|
||||
@ -498,6 +508,7 @@ class ContentProxyTest extends TestCase
|
||||
$this->assertSame(4.0, $entry->getReadingTime());
|
||||
$this->assertSame('1.1.1.1', $entry->getDomainName());
|
||||
$this->assertSame('08/09/2016', $entry->getPublishedAt()->format('d/m/Y'));
|
||||
$this->assertFalse($entry->isNotParsed());
|
||||
}
|
||||
|
||||
public function testWithForcedContentAndBadDate()
|
||||
@ -537,6 +548,7 @@ class ContentProxyTest extends TestCase
|
||||
$this->assertSame(4.0, $entry->getReadingTime());
|
||||
$this->assertSame('1.1.1.1', $entry->getDomainName());
|
||||
$this->assertNull($entry->getPublishedAt());
|
||||
$this->assertFalse($entry->isNotParsed());
|
||||
|
||||
$records = $handler->getRecords();
|
||||
|
||||
@ -625,6 +637,7 @@ class ContentProxyTest extends TestCase
|
||||
$this->assertSame('fr', $entry->getLanguage());
|
||||
$this->assertSame('200', $entry->getHttpStatus());
|
||||
$this->assertSame('1.1.1.1', $entry->getDomainName());
|
||||
$this->assertFalse($entry->isNotParsed());
|
||||
}
|
||||
|
||||
public function testWithImageAsContent()
|
||||
@ -663,6 +676,7 @@ class ContentProxyTest extends TestCase
|
||||
$this->assertSame('image/jpeg', $entry->getMimetype());
|
||||
$this->assertSame('200', $entry->getHttpStatus());
|
||||
$this->assertSame('1.1.1.1', $entry->getDomainName());
|
||||
$this->assertFalse($entry->isNotParsed());
|
||||
}
|
||||
|
||||
public function testWebsiteWithValidUTF8TitleDoNothing()
|
||||
|
||||
Reference in New Issue
Block a user