mirror of
https://github.com/wallabag/wallabag.git
synced 2024-11-21 16:41:05 +00:00
test: Add test for http_status filter
This commit is contained in:
parent
c42a4a308f
commit
fc14f86ae4
4 changed files with 73 additions and 13 deletions
|
@ -87,6 +87,17 @@ class EntryFixtures extends Fixture implements DependentFixtureInterface
|
|||
'tags' => ['bar-tag'],
|
||||
'is_not_parsed' => true,
|
||||
],
|
||||
'entry7' => [
|
||||
'user' => 'admin-user',
|
||||
'url' => 'http://0.0.0.0/entry7',
|
||||
'reading_time' => 12,
|
||||
'domain' => 'redirect.io',
|
||||
'mime' => 'text/html',
|
||||
'title' => 'test title entry7',
|
||||
'http_status' => '302',
|
||||
'content' => 'This is redirect/o/',
|
||||
'language' => 'de',
|
||||
],
|
||||
];
|
||||
|
||||
foreach ($entries as $reference => $item) {
|
||||
|
@ -133,6 +144,10 @@ class EntryFixtures extends Fixture implements DependentFixtureInterface
|
|||
$entry->setNotParsed($item['is_not_parsed']);
|
||||
}
|
||||
|
||||
if (isset($item['http_status'])) {
|
||||
$entry->setHttpStatus($item['http_status']);
|
||||
}
|
||||
|
||||
$manager->persist($entry);
|
||||
$this->addReference($reference, $entry);
|
||||
}
|
||||
|
|
|
@ -47,7 +47,7 @@ class ExportCommandTest extends WallabagTestCase
|
|||
'username' => 'admin',
|
||||
]);
|
||||
|
||||
$this->assertStringContainsString('Exporting 5 entrie(s) for user admin...', $tester->getDisplay());
|
||||
$this->assertStringContainsString('Exporting 6 entrie(s) for user admin...', $tester->getDisplay());
|
||||
$this->assertStringContainsString('Done', $tester->getDisplay());
|
||||
$this->assertFileExists('admin-export.json');
|
||||
}
|
||||
|
|
|
@ -170,6 +170,50 @@ class EntryRestControllerTest extends WallabagApiTestCase
|
|||
$this->assertSame('application/json', $this->client->getResponse()->headers->get('Content-Type'));
|
||||
}
|
||||
|
||||
public function testGetEntriesByHttpStatusWithMatching()
|
||||
{
|
||||
$this->client->request('GET', '/api/entries?http_status=302');
|
||||
|
||||
$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->assertSame(1, $content['total']);
|
||||
$this->assertSame(1, $content['page']);
|
||||
$this->assertGreaterThanOrEqual(1, $content['pages']);
|
||||
|
||||
$this->assertSame('test title entry7', $content['_embedded']['items'][0]['title']);
|
||||
$this->assertSame('302', $content['_embedded']['items'][0]['http_status']);
|
||||
|
||||
$this->assertSame('application/json', $this->client->getResponse()->headers->get('Content-Type'));
|
||||
}
|
||||
|
||||
public function testGetEntriesByHttpStatusNoMatching()
|
||||
{
|
||||
$this->client->request('GET', '/api/entries?http_status=404');
|
||||
|
||||
$this->assertSame(200, $this->client->getResponse()->getStatusCode());
|
||||
|
||||
$content = json_decode($this->client->getResponse()->getContent(), true);
|
||||
|
||||
$this->assertGreaterThanOrEqual(1, \count($content));
|
||||
$this->assertEmpty($content['_embedded']['items']);
|
||||
$this->assertSame(0, $content['total']);
|
||||
$this->assertSame(1, $content['page']);
|
||||
$this->assertGreaterThanOrEqual(1, $content['pages']);
|
||||
|
||||
$this->assertSame('application/json', $this->client->getResponse()->headers->get('Content-Type'));
|
||||
}
|
||||
|
||||
public function testGetEntriesWithBadHttpStatusParam()
|
||||
{
|
||||
$this->client->request('GET', '/api/entries?http_status=10000');
|
||||
|
||||
$this->assertSame(200, $this->client->getResponse()->getStatusCode());
|
||||
}
|
||||
|
||||
public function testGetEntriesWithFullOptions()
|
||||
{
|
||||
$this->client->request('GET', '/api/entries', [
|
||||
|
@ -183,6 +227,7 @@ class EntryRestControllerTest extends WallabagApiTestCase
|
|||
'since' => 1443274283,
|
||||
'public' => 0,
|
||||
'notParsed' => 0,
|
||||
'http_status' => 200,
|
||||
]);
|
||||
|
||||
$this->assertSame(200, $this->client->getResponse()->getStatusCode());
|
||||
|
|
|
@ -106,14 +106,14 @@ class EntryControllerTest extends WallabagTestCase
|
|||
|
||||
$crawler = $client->request('GET', '/');
|
||||
|
||||
$this->assertCount(4, $crawler->filter($this->entryDataTestAttribute));
|
||||
$this->assertCount(5, $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($this->entryDataTestAttribute));
|
||||
$this->assertCount(6, $crawler->filter($this->entryDataTestAttribute));
|
||||
|
||||
$em = $client->getContainer()
|
||||
->get(EntityManagerInterface::class);
|
||||
|
@ -803,7 +803,7 @@ class EntryControllerTest extends WallabagTestCase
|
|||
$client = $this->getTestClient();
|
||||
|
||||
$crawler = $client->request('GET', '/all/list');
|
||||
$this->assertCount(5, $crawler->filter($this->entryDataTestAttribute));
|
||||
$this->assertCount(6, $crawler->filter($this->entryDataTestAttribute));
|
||||
|
||||
$entry = new Entry($this->getLoggedInUser());
|
||||
$entry->setUrl($this->url);
|
||||
|
@ -812,7 +812,7 @@ class EntryControllerTest extends WallabagTestCase
|
|||
$this->getEntityManager()->flush();
|
||||
|
||||
$crawler = $client->request('GET', '/all/list');
|
||||
$this->assertCount(6, $crawler->filter($this->entryDataTestAttribute));
|
||||
$this->assertCount(7, $crawler->filter($this->entryDataTestAttribute));
|
||||
|
||||
$form = $crawler->filter('button[id=submit-filter]')->form();
|
||||
|
||||
|
@ -822,7 +822,7 @@ class EntryControllerTest extends WallabagTestCase
|
|||
|
||||
$crawler = $client->submit($form, $data);
|
||||
|
||||
$this->assertCount(5, $crawler->filter($this->entryDataTestAttribute));
|
||||
$this->assertCount(6, $crawler->filter($this->entryDataTestAttribute));
|
||||
}
|
||||
|
||||
public function testFilterOnReadingTimeOnlyLower()
|
||||
|
@ -867,7 +867,7 @@ class EntryControllerTest extends WallabagTestCase
|
|||
|
||||
$crawler = $client->submit($form, $data);
|
||||
|
||||
$this->assertCount(4, $crawler->filter($this->entryDataTestAttribute));
|
||||
$this->assertCount(5, $crawler->filter($this->entryDataTestAttribute));
|
||||
|
||||
$entry = new Entry($this->getLoggedInUser());
|
||||
$entry->setUrl($this->url);
|
||||
|
@ -877,7 +877,7 @@ class EntryControllerTest extends WallabagTestCase
|
|||
|
||||
$crawler = $client->submit($form, $data);
|
||||
|
||||
$this->assertCount(5, $crawler->filter($this->entryDataTestAttribute));
|
||||
$this->assertCount(6, $crawler->filter($this->entryDataTestAttribute));
|
||||
}
|
||||
|
||||
public function testFilterOnCreationDate()
|
||||
|
@ -908,7 +908,7 @@ class EntryControllerTest extends WallabagTestCase
|
|||
|
||||
$crawler = $client->submit($form, $data);
|
||||
|
||||
$this->assertCount(4, $crawler->filter($this->entryDataTestAttribute));
|
||||
$this->assertCount(5, $crawler->filter($this->entryDataTestAttribute));
|
||||
|
||||
$data = [
|
||||
'entry_filter[createdAt][left_date]' => $today->format('Y-m-d'),
|
||||
|
@ -917,7 +917,7 @@ class EntryControllerTest extends WallabagTestCase
|
|||
|
||||
$crawler = $client->submit($form, $data);
|
||||
|
||||
$this->assertCount(4, $crawler->filter($this->entryDataTestAttribute));
|
||||
$this->assertCount(5, $crawler->filter($this->entryDataTestAttribute));
|
||||
|
||||
$data = [
|
||||
'entry_filter[createdAt][left_date]' => '1970-01-01',
|
||||
|
@ -1394,7 +1394,7 @@ class EntryControllerTest extends WallabagTestCase
|
|||
|
||||
$crawler = $client->submit($form, $data);
|
||||
|
||||
$this->assertCount(8, $crawler->filter($this->entryDataTestAttribute));
|
||||
$this->assertCount(9, $crawler->filter($this->entryDataTestAttribute));
|
||||
}
|
||||
|
||||
public function testSearch()
|
||||
|
@ -1418,7 +1418,7 @@ class EntryControllerTest extends WallabagTestCase
|
|||
|
||||
$crawler = $client->submit($form, $data);
|
||||
|
||||
$this->assertCount(4, $crawler->filter($this->entryDataTestAttribute));
|
||||
$this->assertCount(5, $crawler->filter($this->entryDataTestAttribute));
|
||||
|
||||
// Add a check with useless spaces before and after the search term
|
||||
$crawler = $client->request('GET', '/unread/list');
|
||||
|
@ -1430,7 +1430,7 @@ class EntryControllerTest extends WallabagTestCase
|
|||
|
||||
$crawler = $client->submit($form, $data);
|
||||
|
||||
$this->assertCount(4, $crawler->filter($this->entryDataTestAttribute));
|
||||
$this->assertCount(5, $crawler->filter($this->entryDataTestAttribute));
|
||||
|
||||
// Search on starred list
|
||||
$crawler = $client->request('GET', '/starred/list');
|
||||
|
|
Loading…
Reference in a new issue