From: Nicolas LÅ“uillet Date: Wed, 3 May 2017 09:53:01 +0000 (+0200) Subject: Merge pull request #3047 from wallabag/add-notmatches-operator X-Git-Tag: 2.3.0~31^2~111 X-Git-Url: https://git.immae.eu/?a=commitdiff_plain;h=9c09c253fea8d618f1be110677a1a9c76e3afdcd;hp=-c;p=github%2Fwallabag%2Fwallabag.git Merge pull request #3047 from wallabag/add-notmatches-operator Added notmatches operator for tagging rule --- 9c09c253fea8d618f1be110677a1a9c76e3afdcd diff --combined src/Wallabag/CoreBundle/Resources/translations/messages.en.yml index 42a12b2a,29f9938c..4b745683 --- a/src/Wallabag/CoreBundle/Resources/translations/messages.en.yml +++ b/src/Wallabag/CoreBundle/Resources/translations/messages.en.yml @@@ -155,6 -155,7 +155,7 @@@ config or: 'One rule OR another' and: 'One rule AND another' matches: 'Tests that a subject is matches a search (case-insensitive).
Example: title matches "football"' + notmatches: 'Tests that a subject is not matches a search (case-insensitive).
Example: title notmatches "football"' entry: page_titles: @@@ -361,7 -362,7 +362,7 @@@ quickstart developer: title: 'Developers' description: 'We also thought to the developers: Docker, API, translations, etc.' - create_application: 'Create your third application' + create_application: 'Create your third-party application' use_docker: 'Use Docker to install wallabag' docs: title: 'Full documentation' diff --combined tests/Wallabag/ApiBundle/Controller/EntryRestControllerTest.php index 19fb5170,d9acacfc..e6ffd664 --- a/tests/Wallabag/ApiBundle/Controller/EntryRestControllerTest.php +++ b/tests/Wallabag/ApiBundle/Controller/EntryRestControllerTest.php @@@ -298,7 -298,7 +298,7 @@@ class EntryRestControllerTest extends W $entry = $this->client->getContainer() ->get('doctrine.orm.entity_manager') ->getRepository('WallabagCoreBundle:Entry') - ->findOneByUser(1); + ->findOneByUser(1, ['id' => 'asc']); if (!$entry) { $this->markTestSkipped('No content found in db.'); @@@ -337,7 -337,7 +337,7 @@@ $this->assertEquals(false, $content['is_starred']); $this->assertEquals('New title for my article', $content['title']); $this->assertEquals(1, $content['user_id']); - $this->assertCount(1, $content['tags']); + $this->assertCount(2, $content['tags']); } public function testPostSameEntry() @@@ -356,7 -356,7 +356,7 @@@ $this->assertEquals('http://www.lemonde.fr/pixels/article/2015/03/28/plongee-dans-l-univers-d-ingress-le-jeu-de-google-aux-frontieres-du-reel_4601155_4408996.html', $content['url']); $this->assertEquals(true, $content['is_archived']); $this->assertEquals(false, $content['is_starred']); - $this->assertCount(2, $content['tags']); + $this->assertCount(3, $content['tags']); } public function testPostArchivedAndStarredEntry() @@@ -714,72 -714,4 +714,72 @@@ $this->assertEquals('application/json', $this->client->getResponse()->headers->get('Content-Type')); } + + public function testPostEntriesTagsListAction() + { + $entry = $this->client->getContainer()->get('doctrine.orm.entity_manager') + ->getRepository('WallabagCoreBundle:Entry') + ->findByUrlAndUserId('http://0.0.0.0/entry4', 1); + + $tags = $entry->getTags(); + + $this->assertCount(2, $tags); + + $list = [ + [ + 'url' => 'http://0.0.0.0/entry4', + 'tags' => 'new tag 1, new tag 2', + ], + ]; + + $this->client->request('POST', '/api/entries/tags/lists?list='.json_encode($list)); + + $this->assertEquals(200, $this->client->getResponse()->getStatusCode()); + + $content = json_decode($this->client->getResponse()->getContent(), true); + + $this->assertInternalType('int', $content[0]['entry']); + $this->assertEquals('http://0.0.0.0/entry4', $content[0]['url']); + + $entry = $this->client->getContainer()->get('doctrine.orm.entity_manager') + ->getRepository('WallabagCoreBundle:Entry') + ->findByUrlAndUserId('http://0.0.0.0/entry4', 1); + + $tags = $entry->getTags(); + $this->assertCount(4, $tags); + } + + public function testDeleteEntriesTagsListAction() + { + $entry = $this->client->getContainer()->get('doctrine.orm.entity_manager') + ->getRepository('WallabagCoreBundle:Entry') + ->findByUrlAndUserId('http://0.0.0.0/entry4', 1); + + $tags = $entry->getTags(); + + $this->assertCount(4, $tags); + + $list = [ + [ + 'url' => 'http://0.0.0.0/entry4', + 'tags' => 'new tag 1, new tag 2', + ], + ]; + + $this->client->request('DELETE', '/api/entries/tags/list?list='.json_encode($list)); + + $this->assertEquals(200, $this->client->getResponse()->getStatusCode()); + + $content = json_decode($this->client->getResponse()->getContent(), true); + + $this->assertInternalType('int', $content[0]['entry']); + $this->assertEquals('http://0.0.0.0/entry4', $content[0]['url']); + + $entry = $this->client->getContainer()->get('doctrine.orm.entity_manager') + ->getRepository('WallabagCoreBundle:Entry') + ->findByUrlAndUserId('http://0.0.0.0/entry4', 1); + + $tags = $entry->getTags(); + $this->assertCount(2, $tags); + } }