DELETE entry and use of query for fetch entries

This commit is contained in:
Nicolas Lœuillet 2015-02-11 07:43:43 +01:00
parent 19aee7cd54
commit c9fa9677c1

View File

@ -45,12 +45,21 @@ class WallabagRestControllerTest extends WebTestCase
{
$client = $this->createClient();
$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);
$this->assertContains('This is my content', $client->getResponse()->getContent());
$entry = $client->getContainer()
->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(
$client->getResponse()->headers->contains(
@ -64,9 +73,9 @@ class WallabagRestControllerTest extends WebTestCase
{
$client = $this->createClient();
$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);
$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);
}
}