diff options
author | Nicolas LÅ“uillet <nicolas@loeuillet.org> | 2015-02-11 07:43:43 +0100 |
---|---|---|
committer | Nicolas LÅ“uillet <nicolas@loeuillet.org> | 2015-02-11 07:43:43 +0100 |
commit | c9fa9677c1ae7b9be2305cef8f61fa2e0fc14d58 (patch) | |
tree | ed0fee1fce37145b061b751c18342427e60efd83 /src | |
parent | 19aee7cd545a904d830037e8df785b1703ac62fa (diff) | |
download | wallabag-c9fa9677c1ae7b9be2305cef8f61fa2e0fc14d58.tar.gz wallabag-c9fa9677c1ae7b9be2305cef8f61fa2e0fc14d58.tar.zst wallabag-c9fa9677c1ae7b9be2305cef8f61fa2e0fc14d58.zip |
DELETE entry and use of query for fetch entries
Diffstat (limited to 'src')
-rw-r--r-- | src/Wallabag/CoreBundle/Tests/Controller/WallabagRestControllerTest.php | 49 |
1 files changed, 43 insertions, 6 deletions
diff --git a/src/Wallabag/CoreBundle/Tests/Controller/WallabagRestControllerTest.php b/src/Wallabag/CoreBundle/Tests/Controller/WallabagRestControllerTest.php index 1240844b..c7704aa8 100644 --- a/src/Wallabag/CoreBundle/Tests/Controller/WallabagRestControllerTest.php +++ b/src/Wallabag/CoreBundle/Tests/Controller/WallabagRestControllerTest.php | |||
@@ -45,12 +45,21 @@ class WallabagRestControllerTest extends WebTestCase | |||
45 | { | 45 | { |
46 | $client = $this->createClient(); | 46 | $client = $this->createClient(); |
47 | $client->request('GET', '/api/salts/admin.json'); | 47 | $client->request('GET', '/api/salts/admin.json'); |
48 | $content = json_decode($client->getResponse()->getContent()); | 48 | $salt = json_decode($client->getResponse()->getContent()); |
49 | 49 | ||
50 | $headers = $this->generateHeaders('admin', 'test', $content[0]); | 50 | $headers = $this->generateHeaders('admin', 'test', $salt[0]); |
51 | 51 | ||
52 | $client->request('GET', '/api/entries/1.json', array(), array(), $headers); | 52 | $entry = $client->getContainer() |
53 | $this->assertContains('This is my content', $client->getResponse()->getContent()); | 53 | ->get('doctrine.orm.entity_manager') |
54 | ->getRepository('WallabagCoreBundle:Entry') | ||
55 | ->findOneByIsArchived(false); | ||
56 | |||
57 | if (!$entry) { | ||
58 | $this->markTestSkipped('No content found in db.'); | ||
59 | } | ||
60 | |||
61 | $client->request('GET', '/api/entries/'.$entry->getId().'.json', array(), array(), $headers); | ||
62 | $this->assertContains($entry->getTitle(), $client->getResponse()->getContent()); | ||
54 | 63 | ||
55 | $this->assertTrue( | 64 | $this->assertTrue( |
56 | $client->getResponse()->headers->contains( | 65 | $client->getResponse()->headers->contains( |
@@ -64,9 +73,9 @@ class WallabagRestControllerTest extends WebTestCase | |||
64 | { | 73 | { |
65 | $client = $this->createClient(); | 74 | $client = $this->createClient(); |
66 | $client->request('GET', '/api/salts/admin.json'); | 75 | $client->request('GET', '/api/salts/admin.json'); |
67 | $content = json_decode($client->getResponse()->getContent()); | 76 | $salt = json_decode($client->getResponse()->getContent()); |
68 | 77 | ||
69 | $headers = $this->generateHeaders('admin', 'test', $content[0]); | 78 | $headers = $this->generateHeaders('admin', 'test', $salt[0]); |
70 | 79 | ||
71 | $client->request('GET', '/api/entries', array(), array(), $headers); | 80 | $client->request('GET', '/api/entries', array(), array(), $headers); |
72 | $this->assertContains('Mailjet', $client->getResponse()->getContent()); | 81 | $this->assertContains('Mailjet', $client->getResponse()->getContent()); |
@@ -78,4 +87,32 @@ class WallabagRestControllerTest extends WebTestCase | |||
78 | ) | 87 | ) |
79 | ); | 88 | ); |
80 | } | 89 | } |
90 | |||
91 | public function testDeleteEntry() | ||
92 | { | ||
93 | $client = $this->createClient(); | ||
94 | $client->request('GET', '/api/salts/admin.json'); | ||
95 | $salt = json_decode($client->getResponse()->getContent()); | ||
96 | |||
97 | $headers = $this->generateHeaders('admin', 'test', $salt[0]); | ||
98 | |||
99 | $entry = $client->getContainer() | ||
100 | ->get('doctrine.orm.entity_manager') | ||
101 | ->getRepository('WallabagCoreBundle:Entry') | ||
102 | ->findOneByIsDeleted(false); | ||
103 | |||
104 | if (!$entry) { | ||
105 | $this->markTestSkipped('No content found in db.'); | ||
106 | } | ||
107 | |||
108 | $client->request('DELETE', '/api/entries/'.$entry->getId().'.json', array(), array(), $headers); | ||
109 | |||
110 | $this->assertEquals(200, $client->getResponse()->getStatusCode()); | ||
111 | |||
112 | $res = $client->getContainer() | ||
113 | ->get('doctrine.orm.entity_manager') | ||
114 | ->getRepository('WallabagCoreBundle:Entry') | ||
115 | ->findOneById($entry->getId()); | ||
116 | $this->assertEquals($res->isDeleted(), true); | ||
117 | } | ||
81 | } | 118 | } |