mirror of
https://github.com/wallabag/wallabag.git
synced 2025-01-11 09:25:25 +00:00
Merge pull request #2092 from Rurik19/issue2089
Starred and Archived clears if article is already exists
This commit is contained in:
commit
e7658cb009
2 changed files with 92 additions and 4 deletions
|
@ -110,8 +110,8 @@ class WallabagRestController extends FOSRestController
|
|||
|
||||
$url = $request->request->get('url');
|
||||
$title = $request->request->get('title');
|
||||
$isArchived = (int) $request->request->get('archive');
|
||||
$isStarred = (int) $request->request->get('starred');
|
||||
$isArchived = $request->request->get('archive');
|
||||
$isStarred = $request->request->get('starred');
|
||||
|
||||
$entry = $this->get('wallabag_core.entry_repository')->findByUrlAndUserId($url, $this->getUser()->getId());
|
||||
|
||||
|
@ -172,8 +172,8 @@ class WallabagRestController extends FOSRestController
|
|||
$this->validateUserAccess($entry->getUser()->getId());
|
||||
|
||||
$title = $request->request->get('title');
|
||||
$isArchived = (int) $request->request->get('archive');
|
||||
$isStarred = (int) $request->request->get('starred');
|
||||
$isArchived = $request->request->get('archive');
|
||||
$isStarred = $request->request->get('starred');
|
||||
|
||||
if (!is_null($title)) {
|
||||
$entry->setTitle($title);
|
||||
|
|
|
@ -423,4 +423,92 @@ class WallabagRestControllerTest extends WallabagApiTestCase
|
|||
|
||||
$this->assertEquals($this->client->getContainer()->getParameter('wallabag_core.version'), $content);
|
||||
}
|
||||
|
||||
public function testSaveIsArchivedAfterPost()
|
||||
{
|
||||
$entry = $this->client->getContainer()
|
||||
->get('doctrine.orm.entity_manager')
|
||||
->getRepository('WallabagCoreBundle:Entry')
|
||||
->findOneBy(['user' => 1, 'isArchived' => true]);
|
||||
|
||||
if (!$entry) {
|
||||
$this->markTestSkipped('No content found in db.');
|
||||
}
|
||||
|
||||
$this->client->request('POST', '/api/entries.json', [
|
||||
'url' => $entry->getUrl(),
|
||||
]);
|
||||
|
||||
$this->assertEquals(200, $this->client->getResponse()->getStatusCode());
|
||||
|
||||
$content = json_decode($this->client->getResponse()->getContent(), true);
|
||||
|
||||
$this->assertEquals(true, $content['is_archived']);
|
||||
}
|
||||
|
||||
public function testSaveIsStarredAfterPost()
|
||||
{
|
||||
$entry = $this->client->getContainer()
|
||||
->get('doctrine.orm.entity_manager')
|
||||
->getRepository('WallabagCoreBundle:Entry')
|
||||
->findOneBy(['user' => 1, 'isStarred' => true]);
|
||||
|
||||
if (!$entry) {
|
||||
$this->markTestSkipped('No content found in db.');
|
||||
}
|
||||
|
||||
$this->client->request('POST', '/api/entries.json', [
|
||||
'url' => $entry->getUrl(),
|
||||
]);
|
||||
|
||||
$this->assertEquals(200, $this->client->getResponse()->getStatusCode());
|
||||
|
||||
$content = json_decode($this->client->getResponse()->getContent(), true);
|
||||
|
||||
$this->assertEquals(true, $content['is_starred']);
|
||||
}
|
||||
|
||||
public function testSaveIsArchivedAfterPatch()
|
||||
{
|
||||
$entry = $this->client->getContainer()
|
||||
->get('doctrine.orm.entity_manager')
|
||||
->getRepository('WallabagCoreBundle:Entry')
|
||||
->findOneBy(['user' => 1, 'isArchived' => true]);
|
||||
|
||||
if (!$entry) {
|
||||
$this->markTestSkipped('No content found in db.');
|
||||
}
|
||||
|
||||
$this->client->request('PATCH', '/api/entries/'.$entry->getId().'.json', [
|
||||
'title' => $entry->getTitle().'++',
|
||||
]);
|
||||
|
||||
$this->assertEquals(200, $this->client->getResponse()->getStatusCode());
|
||||
|
||||
$content = json_decode($this->client->getResponse()->getContent(), true);
|
||||
|
||||
$this->assertEquals(true, $content['is_archived']);
|
||||
}
|
||||
|
||||
public function testSaveIsStarredAfterPatch()
|
||||
{
|
||||
$entry = $this->client->getContainer()
|
||||
->get('doctrine.orm.entity_manager')
|
||||
->getRepository('WallabagCoreBundle:Entry')
|
||||
->findOneBy(['user' => 1, 'isStarred' => true]);
|
||||
|
||||
if (!$entry) {
|
||||
$this->markTestSkipped('No content found in db.');
|
||||
}
|
||||
$this->client->request('PATCH', '/api/entries/'.$entry->getId().'.json', [
|
||||
'title' => $entry->getTitle().'++',
|
||||
]);
|
||||
|
||||
$this->assertEquals(200, $this->client->getResponse()->getStatusCode());
|
||||
|
||||
$content = json_decode($this->client->getResponse()->getContent(), true);
|
||||
|
||||
$this->assertEquals(true, $content['is_starred']);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue