mirror of
https://github.com/wallabag/wallabag.git
synced 2024-12-16 18:30:17 +01:00
DELETE entry and use of query for fetch entries
This commit is contained in:
parent
19aee7cd54
commit
c9fa9677c1
@ -45,12 +45,21 @@ class WallabagRestControllerTest extends WebTestCase
|
|||||||
{
|
{
|
||||||
$client = $this->createClient();
|
$client = $this->createClient();
|
||||||
$client->request('GET', '/api/salts/admin.json');
|
$client->request('GET', '/api/salts/admin.json');
|
||||||
$content = json_decode($client->getResponse()->getContent());
|
$salt = json_decode($client->getResponse()->getContent());
|
||||||
|
|
||||||
$headers = $this->generateHeaders('admin', 'test', $content[0]);
|
$headers = $this->generateHeaders('admin', 'test', $salt[0]);
|
||||||
|
|
||||||
$client->request('GET', '/api/entries/1.json', array(), array(), $headers);
|
$entry = $client->getContainer()
|
||||||
$this->assertContains('This is my content', $client->getResponse()->getContent());
|
->get('doctrine.orm.entity_manager')
|
||||||
|
->getRepository('WallabagCoreBundle:Entry')
|
||||||
|
->findOneByIsArchived(false);
|
||||||
|
|
||||||
|
if (!$entry) {
|
||||||
|
$this->markTestSkipped('No content found in db.');
|
||||||
|
}
|
||||||
|
|
||||||
|
$client->request('GET', '/api/entries/'.$entry->getId().'.json', array(), array(), $headers);
|
||||||
|
$this->assertContains($entry->getTitle(), $client->getResponse()->getContent());
|
||||||
|
|
||||||
$this->assertTrue(
|
$this->assertTrue(
|
||||||
$client->getResponse()->headers->contains(
|
$client->getResponse()->headers->contains(
|
||||||
@ -64,9 +73,9 @@ class WallabagRestControllerTest extends WebTestCase
|
|||||||
{
|
{
|
||||||
$client = $this->createClient();
|
$client = $this->createClient();
|
||||||
$client->request('GET', '/api/salts/admin.json');
|
$client->request('GET', '/api/salts/admin.json');
|
||||||
$content = json_decode($client->getResponse()->getContent());
|
$salt = json_decode($client->getResponse()->getContent());
|
||||||
|
|
||||||
$headers = $this->generateHeaders('admin', 'test', $content[0]);
|
$headers = $this->generateHeaders('admin', 'test', $salt[0]);
|
||||||
|
|
||||||
$client->request('GET', '/api/entries', array(), array(), $headers);
|
$client->request('GET', '/api/entries', array(), array(), $headers);
|
||||||
$this->assertContains('Mailjet', $client->getResponse()->getContent());
|
$this->assertContains('Mailjet', $client->getResponse()->getContent());
|
||||||
@ -78,4 +87,32 @@ class WallabagRestControllerTest extends WebTestCase
|
|||||||
)
|
)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function testDeleteEntry()
|
||||||
|
{
|
||||||
|
$client = $this->createClient();
|
||||||
|
$client->request('GET', '/api/salts/admin.json');
|
||||||
|
$salt = json_decode($client->getResponse()->getContent());
|
||||||
|
|
||||||
|
$headers = $this->generateHeaders('admin', 'test', $salt[0]);
|
||||||
|
|
||||||
|
$entry = $client->getContainer()
|
||||||
|
->get('doctrine.orm.entity_manager')
|
||||||
|
->getRepository('WallabagCoreBundle:Entry')
|
||||||
|
->findOneByIsDeleted(false);
|
||||||
|
|
||||||
|
if (!$entry) {
|
||||||
|
$this->markTestSkipped('No content found in db.');
|
||||||
|
}
|
||||||
|
|
||||||
|
$client->request('DELETE', '/api/entries/'.$entry->getId().'.json', array(), array(), $headers);
|
||||||
|
|
||||||
|
$this->assertEquals(200, $client->getResponse()->getStatusCode());
|
||||||
|
|
||||||
|
$res = $client->getContainer()
|
||||||
|
->get('doctrine.orm.entity_manager')
|
||||||
|
->getRepository('WallabagCoreBundle:Entry')
|
||||||
|
->findOneById($entry->getId());
|
||||||
|
$this->assertEquals($res->isDeleted(), true);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user