From ae669126e718ede5dbf76929215d8514cd960976 Mon Sep 17 00:00:00 2001 From: Thomas Citharel Date: Tue, 12 Jul 2016 13:51:05 +0200 Subject: Import Firefox & Chrome bookmarks into wallabag --- .../Controller/BrowserControllerTest.php | 94 ++++++++++++++++++++++ tests/Wallabag/ImportBundle/fixtures/Bookmarks | 61 ++++++++++++++ 2 files changed, 155 insertions(+) create mode 100644 tests/Wallabag/ImportBundle/Controller/BrowserControllerTest.php create mode 100644 tests/Wallabag/ImportBundle/fixtures/Bookmarks (limited to 'tests/Wallabag/ImportBundle') diff --git a/tests/Wallabag/ImportBundle/Controller/BrowserControllerTest.php b/tests/Wallabag/ImportBundle/Controller/BrowserControllerTest.php new file mode 100644 index 00000000..8016227c --- /dev/null +++ b/tests/Wallabag/ImportBundle/Controller/BrowserControllerTest.php @@ -0,0 +1,94 @@ +logInAs('admin'); + $client = $this->getClient(); + + $crawler = $client->request('GET', '/import/browser'); + + $this->assertEquals(200, $client->getResponse()->getStatusCode()); + $this->assertEquals(1, $crawler->filter('form[name=upload_import_file] > button[type=submit]')->count()); + $this->assertEquals(1, $crawler->filter('input[type=file]')->count()); + } + + public function testImportWallabagWithFile() + { + $this->logInAs('admin'); + $client = $this->getClient(); + + $crawler = $client->request('GET', '/import/browser'); + $form = $crawler->filter('form[name=upload_import_file] > button[type=submit]')->form(); + + $file = new UploadedFile(__DIR__.'/../fixtures/Bookmarks', 'Bookmarks'); + + $data = [ + 'upload_import_file[file]' => $file, + ]; + + $client->submit($form, $data); + + $this->assertEquals(302, $client->getResponse()->getStatusCode()); + + $crawler = $client->followRedirect(); + + $this->assertGreaterThan(1, $body = $crawler->filter('body')->extract(['_text'])); + $this->assertContains('flashes.import.notice.summary', $body[0]); + + $content = $client->getContainer() + ->get('doctrine.orm.entity_manager') + ->getRepository('WallabagCoreBundle:Entry') + ->findByUrlAndUserId( + 'http://lexpansion.lexpress.fr/high-tech/orange-offre-un-meilleur-reseau-mobile-que-bouygues-et-sfr-free-derriere_1811554.html', + $this->getLoggedInUserId() + ); + + $this->assertNotEmpty($content->getMimetype()); + $this->assertNotEmpty($content->getPreviewPicture()); + $this->assertNotEmpty($content->getLanguage()); + $this->assertEquals(0, count($content->getTags())); + + $content = $client->getContainer() + ->get('doctrine.orm.entity_manager') + ->getRepository('WallabagCoreBundle:Entry') + ->findByUrlAndUserId( + 'http://stackoverflow.com/questions/15017163/parser-for-exported-bookmarks-html-file-of-google-chrome-and-mozilla-in-java', + $this->getLoggedInUserId() + ); + + $this->assertNotEmpty($content->getMimetype()); + $this->assertNotEmpty($content->getPreviewPicture()); + $this->assertEmpty($content->getLanguage()); + } + + public function testImportWallabagWithEmptyFile() + { + $this->logInAs('admin'); + $client = $this->getClient(); + + $crawler = $client->request('GET', '/import/browser'); + $form = $crawler->filter('form[name=upload_import_file] > button[type=submit]')->form(); + + $file = new UploadedFile(__DIR__.'/../fixtures/test.txt', 'test.txt'); + + $data = [ + 'upload_import_file[file]' => $file, + ]; + + $client->submit($form, $data); + + $this->assertEquals(302, $client->getResponse()->getStatusCode()); + + $crawler = $client->followRedirect(); + + $this->assertGreaterThan(1, $body = $crawler->filter('body')->extract(['_text'])); + $this->assertContains('flashes.import.notice.failed', $body[0]); + } +} diff --git a/tests/Wallabag/ImportBundle/fixtures/Bookmarks b/tests/Wallabag/ImportBundle/fixtures/Bookmarks new file mode 100644 index 00000000..8b78b8a4 --- /dev/null +++ b/tests/Wallabag/ImportBundle/fixtures/Bookmarks @@ -0,0 +1,61 @@ +{ + "checksum": "ef1e30cddf64cb94c63d7835640165be", + "roots": { + "bookmark_bar": { + "children": [ { + "date_added": "13112787540531997", + "id": "7", + "name": "Terrorisme: les sombres prédictions du directeur de la DGSI", + "type": "url", + "url": "http://www.lefigaro.fr/actualite-france/2016/07/12/01016-20160712ARTFIG00016-terrorisme-les-sombres-perspectives-de-patrick-calvar-directeur-de-la-dgsi.php" + } ], + "date_added": "13112787380480144", + "date_modified": "13112787542724942", + "id": "1", + "name": "Bookmarks bar", + "type": "folder" + }, + "other": { + "children": [ { + "date_added": "13112787503900822", + "id": "6", + "name": "Parser for Exported Bookmarks HTML file of Google Chrome and Mozilla in Java - Stack Overflow", + "type": "url", + "url": "http://stackoverflow.com/questions/15017163/parser-for-exported-bookmarks-html-file-of-google-chrome-and-mozilla-in-java" + }, { + "children": [ { + "date_added": "13112787564443378", + "id": "9", + "name": "Orange offre un meilleur réseau mobile que Bouygues et SFR, Free derrière - L'Express L'Expansion", + "type": "url", + "url": "http://lexpansion.lexpress.fr/high-tech/orange-offre-un-meilleur-reseau-mobile-que-bouygues-et-sfr-free-derriere_1811554.html" + } ], + "date_added": "13112787556763735", + "date_modified": "13112794390493325", + "id": "8", + "name": "test", + "type": "folder" + }, { + "date_added": "13112794390493325", + "id": "12", + "name": "JSON Formatter & Validator", + "type": "url", + "url": "https://jsonformatter.curiousconcept.com/" + } ], + "date_added": "13112787380480151", + "date_modified": "13112794393509988", + "id": "2", + "name": "Other bookmarks", + "type": "folder" + }, + "synced": { + "children": [ ], + "date_added": "13112787380480155", + "date_modified": "0", + "id": "3", + "name": "Mobile bookmarks", + "type": "folder" + } + }, + "version": 1 +} -- cgit v1.2.3 From efe659ab84df5db23d95203c0cef8c43ed0914e1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicolas=20L=C5=93uillet?= Date: Fri, 2 Sep 2016 13:53:45 +0200 Subject: Add Chrome path for Mac OS --- tests/Wallabag/ImportBundle/Controller/ImportControllerTest.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'tests/Wallabag/ImportBundle') diff --git a/tests/Wallabag/ImportBundle/Controller/ImportControllerTest.php b/tests/Wallabag/ImportBundle/Controller/ImportControllerTest.php index d869cdf9..23a7c877 100644 --- a/tests/Wallabag/ImportBundle/Controller/ImportControllerTest.php +++ b/tests/Wallabag/ImportBundle/Controller/ImportControllerTest.php @@ -24,6 +24,6 @@ class ImportControllerTest extends WallabagCoreTestCase $crawler = $client->request('GET', '/import/'); $this->assertEquals(200, $client->getResponse()->getStatusCode()); - $this->assertEquals(4, $crawler->filter('blockquote')->count()); + $this->assertEquals(5, $crawler->filter('blockquote')->count()); } } -- cgit v1.2.3 From 06d13ddfbc6dad568bb28d5c33daab9e54dc6669 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicolas=20L=C5=93uillet?= Date: Fri, 2 Sep 2016 15:21:07 +0200 Subject: Indentation and renamed fixtures file --- .../Controller/BrowserControllerTest.php | 2 +- tests/Wallabag/ImportBundle/fixtures/Bookmarks | 61 ---------------------- .../Wallabag/ImportBundle/fixtures/bookmarks.json | 61 ++++++++++++++++++++++ 3 files changed, 62 insertions(+), 62 deletions(-) delete mode 100644 tests/Wallabag/ImportBundle/fixtures/Bookmarks create mode 100644 tests/Wallabag/ImportBundle/fixtures/bookmarks.json (limited to 'tests/Wallabag/ImportBundle') diff --git a/tests/Wallabag/ImportBundle/Controller/BrowserControllerTest.php b/tests/Wallabag/ImportBundle/Controller/BrowserControllerTest.php index 8016227c..46c831f8 100644 --- a/tests/Wallabag/ImportBundle/Controller/BrowserControllerTest.php +++ b/tests/Wallabag/ImportBundle/Controller/BrowserControllerTest.php @@ -27,7 +27,7 @@ class BrowserControllerTest extends WallabagCoreTestCase $crawler = $client->request('GET', '/import/browser'); $form = $crawler->filter('form[name=upload_import_file] > button[type=submit]')->form(); - $file = new UploadedFile(__DIR__.'/../fixtures/Bookmarks', 'Bookmarks'); + $file = new UploadedFile(__DIR__.'/../fixtures/bookmarks.json', 'Bookmarks'); $data = [ 'upload_import_file[file]' => $file, diff --git a/tests/Wallabag/ImportBundle/fixtures/Bookmarks b/tests/Wallabag/ImportBundle/fixtures/Bookmarks deleted file mode 100644 index 8b78b8a4..00000000 --- a/tests/Wallabag/ImportBundle/fixtures/Bookmarks +++ /dev/null @@ -1,61 +0,0 @@ -{ - "checksum": "ef1e30cddf64cb94c63d7835640165be", - "roots": { - "bookmark_bar": { - "children": [ { - "date_added": "13112787540531997", - "id": "7", - "name": "Terrorisme: les sombres prédictions du directeur de la DGSI", - "type": "url", - "url": "http://www.lefigaro.fr/actualite-france/2016/07/12/01016-20160712ARTFIG00016-terrorisme-les-sombres-perspectives-de-patrick-calvar-directeur-de-la-dgsi.php" - } ], - "date_added": "13112787380480144", - "date_modified": "13112787542724942", - "id": "1", - "name": "Bookmarks bar", - "type": "folder" - }, - "other": { - "children": [ { - "date_added": "13112787503900822", - "id": "6", - "name": "Parser for Exported Bookmarks HTML file of Google Chrome and Mozilla in Java - Stack Overflow", - "type": "url", - "url": "http://stackoverflow.com/questions/15017163/parser-for-exported-bookmarks-html-file-of-google-chrome-and-mozilla-in-java" - }, { - "children": [ { - "date_added": "13112787564443378", - "id": "9", - "name": "Orange offre un meilleur réseau mobile que Bouygues et SFR, Free derrière - L'Express L'Expansion", - "type": "url", - "url": "http://lexpansion.lexpress.fr/high-tech/orange-offre-un-meilleur-reseau-mobile-que-bouygues-et-sfr-free-derriere_1811554.html" - } ], - "date_added": "13112787556763735", - "date_modified": "13112794390493325", - "id": "8", - "name": "test", - "type": "folder" - }, { - "date_added": "13112794390493325", - "id": "12", - "name": "JSON Formatter & Validator", - "type": "url", - "url": "https://jsonformatter.curiousconcept.com/" - } ], - "date_added": "13112787380480151", - "date_modified": "13112794393509988", - "id": "2", - "name": "Other bookmarks", - "type": "folder" - }, - "synced": { - "children": [ ], - "date_added": "13112787380480155", - "date_modified": "0", - "id": "3", - "name": "Mobile bookmarks", - "type": "folder" - } - }, - "version": 1 -} diff --git a/tests/Wallabag/ImportBundle/fixtures/bookmarks.json b/tests/Wallabag/ImportBundle/fixtures/bookmarks.json new file mode 100644 index 00000000..8b78b8a4 --- /dev/null +++ b/tests/Wallabag/ImportBundle/fixtures/bookmarks.json @@ -0,0 +1,61 @@ +{ + "checksum": "ef1e30cddf64cb94c63d7835640165be", + "roots": { + "bookmark_bar": { + "children": [ { + "date_added": "13112787540531997", + "id": "7", + "name": "Terrorisme: les sombres prédictions du directeur de la DGSI", + "type": "url", + "url": "http://www.lefigaro.fr/actualite-france/2016/07/12/01016-20160712ARTFIG00016-terrorisme-les-sombres-perspectives-de-patrick-calvar-directeur-de-la-dgsi.php" + } ], + "date_added": "13112787380480144", + "date_modified": "13112787542724942", + "id": "1", + "name": "Bookmarks bar", + "type": "folder" + }, + "other": { + "children": [ { + "date_added": "13112787503900822", + "id": "6", + "name": "Parser for Exported Bookmarks HTML file of Google Chrome and Mozilla in Java - Stack Overflow", + "type": "url", + "url": "http://stackoverflow.com/questions/15017163/parser-for-exported-bookmarks-html-file-of-google-chrome-and-mozilla-in-java" + }, { + "children": [ { + "date_added": "13112787564443378", + "id": "9", + "name": "Orange offre un meilleur réseau mobile que Bouygues et SFR, Free derrière - L'Express L'Expansion", + "type": "url", + "url": "http://lexpansion.lexpress.fr/high-tech/orange-offre-un-meilleur-reseau-mobile-que-bouygues-et-sfr-free-derriere_1811554.html" + } ], + "date_added": "13112787556763735", + "date_modified": "13112794390493325", + "id": "8", + "name": "test", + "type": "folder" + }, { + "date_added": "13112794390493325", + "id": "12", + "name": "JSON Formatter & Validator", + "type": "url", + "url": "https://jsonformatter.curiousconcept.com/" + } ], + "date_added": "13112787380480151", + "date_modified": "13112794393509988", + "id": "2", + "name": "Other bookmarks", + "type": "folder" + }, + "synced": { + "children": [ ], + "date_added": "13112787380480155", + "date_modified": "0", + "id": "3", + "name": "Mobile bookmarks", + "type": "folder" + } + }, + "version": 1 +} -- cgit v1.2.3 From f7c55b38122cc593c2b58bb6425fca9d243b055e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicolas=20L=C5=93uillet?= Date: Tue, 20 Sep 2016 16:45:13 +0200 Subject: Added tests for Chrome bookmarks import --- .../ImportBundle/Command/ImportCommandTest.php | 1 - .../Controller/BrowserControllerTest.php | 41 ++++++++++++++- .../Wallabag/ImportBundle/fixtures/bookmarks.json | 61 ---------------------- .../ImportBundle/fixtures/chrome-bookmarks | 36 +++++++++++++ .../ImportBundle/fixtures/firefox-bookmarks.json | 61 ++++++++++++++++++++++ 5 files changed, 136 insertions(+), 64 deletions(-) delete mode 100644 tests/Wallabag/ImportBundle/fixtures/bookmarks.json create mode 100644 tests/Wallabag/ImportBundle/fixtures/chrome-bookmarks create mode 100644 tests/Wallabag/ImportBundle/fixtures/firefox-bookmarks.json (limited to 'tests/Wallabag/ImportBundle') diff --git a/tests/Wallabag/ImportBundle/Command/ImportCommandTest.php b/tests/Wallabag/ImportBundle/Command/ImportCommandTest.php index eb7fce79..7be1eb18 100644 --- a/tests/Wallabag/ImportBundle/Command/ImportCommandTest.php +++ b/tests/Wallabag/ImportBundle/Command/ImportCommandTest.php @@ -6,7 +6,6 @@ use Symfony\Bundle\FrameworkBundle\Console\Application; use Symfony\Component\Console\Tester\CommandTester; use Wallabag\ImportBundle\Command\ImportCommand; use Tests\Wallabag\CoreBundle\WallabagCoreTestCase; -use M6Web\Component\RedisMock\RedisMockFactory; class ImportCommandTest extends WallabagCoreTestCase { diff --git a/tests/Wallabag/ImportBundle/Controller/BrowserControllerTest.php b/tests/Wallabag/ImportBundle/Controller/BrowserControllerTest.php index 46c831f8..b686fcd9 100644 --- a/tests/Wallabag/ImportBundle/Controller/BrowserControllerTest.php +++ b/tests/Wallabag/ImportBundle/Controller/BrowserControllerTest.php @@ -19,7 +19,7 @@ class BrowserControllerTest extends WallabagCoreTestCase $this->assertEquals(1, $crawler->filter('input[type=file]')->count()); } - public function testImportWallabagWithFile() + public function testImportWallabagWithFirefoxFile() { $this->logInAs('admin'); $client = $this->getClient(); @@ -27,7 +27,7 @@ class BrowserControllerTest extends WallabagCoreTestCase $crawler = $client->request('GET', '/import/browser'); $form = $crawler->filter('form[name=upload_import_file] > button[type=submit]')->form(); - $file = new UploadedFile(__DIR__.'/../fixtures/bookmarks.json', 'Bookmarks'); + $file = new UploadedFile(__DIR__.'/../fixtures/firefox-bookmarks.json', 'Bookmarks'); $data = [ 'upload_import_file[file]' => $file, @@ -68,6 +68,43 @@ class BrowserControllerTest extends WallabagCoreTestCase $this->assertEmpty($content->getLanguage()); } + public function testImportWallabagWithChromeFile() + { + $this->logInAs('admin'); + $client = $this->getClient(); + + $crawler = $client->request('GET', '/import/browser'); + $form = $crawler->filter('form[name=upload_import_file] > button[type=submit]')->form(); + + $file = new UploadedFile(__DIR__.'/../fixtures/chrome-bookmarks', 'Bookmarks'); + + $data = [ + 'upload_import_file[file]' => $file, + ]; + + $client->submit($form, $data); + + $this->assertEquals(302, $client->getResponse()->getStatusCode()); + + $crawler = $client->followRedirect(); + + $this->assertGreaterThan(1, $body = $crawler->filter('body')->extract(['_text'])); + $this->assertContains('flashes.import.notice.summary', $body[0]); + + $content = $client->getContainer() + ->get('doctrine.orm.entity_manager') + ->getRepository('WallabagCoreBundle:Entry') + ->findByUrlAndUserId( + 'http://www.usinenouvelle.com/article/la-multiplication-des-chefs-de-projet-est-une-catastrophe-manageriale-majeure-affirme-le-sociologue-francois-dupuy.N307730', + $this->getLoggedInUserId() + ); + + $this->assertNotEmpty($content->getMimetype()); + $this->assertNotEmpty($content->getPreviewPicture()); + $this->assertNotEmpty($content->getLanguage()); + $this->assertEquals(0, count($content->getTags())); + } + public function testImportWallabagWithEmptyFile() { $this->logInAs('admin'); diff --git a/tests/Wallabag/ImportBundle/fixtures/bookmarks.json b/tests/Wallabag/ImportBundle/fixtures/bookmarks.json deleted file mode 100644 index 8b78b8a4..00000000 --- a/tests/Wallabag/ImportBundle/fixtures/bookmarks.json +++ /dev/null @@ -1,61 +0,0 @@ -{ - "checksum": "ef1e30cddf64cb94c63d7835640165be", - "roots": { - "bookmark_bar": { - "children": [ { - "date_added": "13112787540531997", - "id": "7", - "name": "Terrorisme: les sombres prédictions du directeur de la DGSI", - "type": "url", - "url": "http://www.lefigaro.fr/actualite-france/2016/07/12/01016-20160712ARTFIG00016-terrorisme-les-sombres-perspectives-de-patrick-calvar-directeur-de-la-dgsi.php" - } ], - "date_added": "13112787380480144", - "date_modified": "13112787542724942", - "id": "1", - "name": "Bookmarks bar", - "type": "folder" - }, - "other": { - "children": [ { - "date_added": "13112787503900822", - "id": "6", - "name": "Parser for Exported Bookmarks HTML file of Google Chrome and Mozilla in Java - Stack Overflow", - "type": "url", - "url": "http://stackoverflow.com/questions/15017163/parser-for-exported-bookmarks-html-file-of-google-chrome-and-mozilla-in-java" - }, { - "children": [ { - "date_added": "13112787564443378", - "id": "9", - "name": "Orange offre un meilleur réseau mobile que Bouygues et SFR, Free derrière - L'Express L'Expansion", - "type": "url", - "url": "http://lexpansion.lexpress.fr/high-tech/orange-offre-un-meilleur-reseau-mobile-que-bouygues-et-sfr-free-derriere_1811554.html" - } ], - "date_added": "13112787556763735", - "date_modified": "13112794390493325", - "id": "8", - "name": "test", - "type": "folder" - }, { - "date_added": "13112794390493325", - "id": "12", - "name": "JSON Formatter & Validator", - "type": "url", - "url": "https://jsonformatter.curiousconcept.com/" - } ], - "date_added": "13112787380480151", - "date_modified": "13112794393509988", - "id": "2", - "name": "Other bookmarks", - "type": "folder" - }, - "synced": { - "children": [ ], - "date_added": "13112787380480155", - "date_modified": "0", - "id": "3", - "name": "Mobile bookmarks", - "type": "folder" - } - }, - "version": 1 -} diff --git a/tests/Wallabag/ImportBundle/fixtures/chrome-bookmarks b/tests/Wallabag/ImportBundle/fixtures/chrome-bookmarks new file mode 100644 index 00000000..0478eb41 --- /dev/null +++ b/tests/Wallabag/ImportBundle/fixtures/chrome-bookmarks @@ -0,0 +1,36 @@ +{ + "checksum": "f3aa0e9c0edad632a246f7e98ec64918", + "roots": { + "bookmark_bar": { + "children": [ { + "date_added": "13118850929335823", + "id": "6", + "name": "\"La multiplication des chefs de projet est une catastrophe managériale majeure\", affirme le sociologue François Dupuy - Ressources humaines", + "type": "url", + "url": "http://www.usinenouvelle.com/article/la-multiplication-des-chefs-de-projet-est-une-catastrophe-manageriale-majeure-affirme-le-sociologue-francois-dupuy.N307730" + } ], + "date_added": "13118829474385693", + "date_modified": "13118850929335823", + "id": "1", + "name": "Barre de favoris", + "type": "folder" + }, + "other": { + "children": [ ], + "date_added": "13118829474385701", + "date_modified": "0", + "id": "2", + "name": "Autres favoris", + "type": "folder" + }, + "synced": { + "children": [ ], + "date_added": "13118829474385702", + "date_modified": "0", + "id": "3", + "name": "Favoris sur mobile", + "type": "folder" + } + }, + "version": 1 +} diff --git a/tests/Wallabag/ImportBundle/fixtures/firefox-bookmarks.json b/tests/Wallabag/ImportBundle/fixtures/firefox-bookmarks.json new file mode 100644 index 00000000..8b78b8a4 --- /dev/null +++ b/tests/Wallabag/ImportBundle/fixtures/firefox-bookmarks.json @@ -0,0 +1,61 @@ +{ + "checksum": "ef1e30cddf64cb94c63d7835640165be", + "roots": { + "bookmark_bar": { + "children": [ { + "date_added": "13112787540531997", + "id": "7", + "name": "Terrorisme: les sombres prédictions du directeur de la DGSI", + "type": "url", + "url": "http://www.lefigaro.fr/actualite-france/2016/07/12/01016-20160712ARTFIG00016-terrorisme-les-sombres-perspectives-de-patrick-calvar-directeur-de-la-dgsi.php" + } ], + "date_added": "13112787380480144", + "date_modified": "13112787542724942", + "id": "1", + "name": "Bookmarks bar", + "type": "folder" + }, + "other": { + "children": [ { + "date_added": "13112787503900822", + "id": "6", + "name": "Parser for Exported Bookmarks HTML file of Google Chrome and Mozilla in Java - Stack Overflow", + "type": "url", + "url": "http://stackoverflow.com/questions/15017163/parser-for-exported-bookmarks-html-file-of-google-chrome-and-mozilla-in-java" + }, { + "children": [ { + "date_added": "13112787564443378", + "id": "9", + "name": "Orange offre un meilleur réseau mobile que Bouygues et SFR, Free derrière - L'Express L'Expansion", + "type": "url", + "url": "http://lexpansion.lexpress.fr/high-tech/orange-offre-un-meilleur-reseau-mobile-que-bouygues-et-sfr-free-derriere_1811554.html" + } ], + "date_added": "13112787556763735", + "date_modified": "13112794390493325", + "id": "8", + "name": "test", + "type": "folder" + }, { + "date_added": "13112794390493325", + "id": "12", + "name": "JSON Formatter & Validator", + "type": "url", + "url": "https://jsonformatter.curiousconcept.com/" + } ], + "date_added": "13112787380480151", + "date_modified": "13112794393509988", + "id": "2", + "name": "Other bookmarks", + "type": "folder" + }, + "synced": { + "children": [ ], + "date_added": "13112787380480155", + "date_modified": "0", + "id": "3", + "name": "Mobile bookmarks", + "type": "folder" + } + }, + "version": 1 +} -- cgit v1.2.3 From 59201088b4fc13fd361238396f630dabd9bd1990 Mon Sep 17 00:00:00 2001 From: Thomas Citharel Date: Wed, 21 Sep 2016 17:47:47 +0200 Subject: bring chrome and firefox as separate imports --- .../Controller/BrowserControllerTest.php | 131 ------------ .../Controller/ChromeControllerTest.php | 149 +++++++++++++ .../Controller/FirefoxControllerTest.php | 161 ++++++++++++++ .../Controller/ImportControllerTest.php | 2 +- .../Controller/ReadabilityControllerTest.php | 1 - .../ImportBundle/Import/ChromeImportTest.php | 233 +++++++++++++++++++++ .../ImportBundle/Import/FirefoxImportTest.php | 233 +++++++++++++++++++++ 7 files changed, 777 insertions(+), 133 deletions(-) delete mode 100644 tests/Wallabag/ImportBundle/Controller/BrowserControllerTest.php create mode 100644 tests/Wallabag/ImportBundle/Controller/ChromeControllerTest.php create mode 100644 tests/Wallabag/ImportBundle/Controller/FirefoxControllerTest.php create mode 100644 tests/Wallabag/ImportBundle/Import/ChromeImportTest.php create mode 100644 tests/Wallabag/ImportBundle/Import/FirefoxImportTest.php (limited to 'tests/Wallabag/ImportBundle') diff --git a/tests/Wallabag/ImportBundle/Controller/BrowserControllerTest.php b/tests/Wallabag/ImportBundle/Controller/BrowserControllerTest.php deleted file mode 100644 index b686fcd9..00000000 --- a/tests/Wallabag/ImportBundle/Controller/BrowserControllerTest.php +++ /dev/null @@ -1,131 +0,0 @@ -logInAs('admin'); - $client = $this->getClient(); - - $crawler = $client->request('GET', '/import/browser'); - - $this->assertEquals(200, $client->getResponse()->getStatusCode()); - $this->assertEquals(1, $crawler->filter('form[name=upload_import_file] > button[type=submit]')->count()); - $this->assertEquals(1, $crawler->filter('input[type=file]')->count()); - } - - public function testImportWallabagWithFirefoxFile() - { - $this->logInAs('admin'); - $client = $this->getClient(); - - $crawler = $client->request('GET', '/import/browser'); - $form = $crawler->filter('form[name=upload_import_file] > button[type=submit]')->form(); - - $file = new UploadedFile(__DIR__.'/../fixtures/firefox-bookmarks.json', 'Bookmarks'); - - $data = [ - 'upload_import_file[file]' => $file, - ]; - - $client->submit($form, $data); - - $this->assertEquals(302, $client->getResponse()->getStatusCode()); - - $crawler = $client->followRedirect(); - - $this->assertGreaterThan(1, $body = $crawler->filter('body')->extract(['_text'])); - $this->assertContains('flashes.import.notice.summary', $body[0]); - - $content = $client->getContainer() - ->get('doctrine.orm.entity_manager') - ->getRepository('WallabagCoreBundle:Entry') - ->findByUrlAndUserId( - 'http://lexpansion.lexpress.fr/high-tech/orange-offre-un-meilleur-reseau-mobile-que-bouygues-et-sfr-free-derriere_1811554.html', - $this->getLoggedInUserId() - ); - - $this->assertNotEmpty($content->getMimetype()); - $this->assertNotEmpty($content->getPreviewPicture()); - $this->assertNotEmpty($content->getLanguage()); - $this->assertEquals(0, count($content->getTags())); - - $content = $client->getContainer() - ->get('doctrine.orm.entity_manager') - ->getRepository('WallabagCoreBundle:Entry') - ->findByUrlAndUserId( - 'http://stackoverflow.com/questions/15017163/parser-for-exported-bookmarks-html-file-of-google-chrome-and-mozilla-in-java', - $this->getLoggedInUserId() - ); - - $this->assertNotEmpty($content->getMimetype()); - $this->assertNotEmpty($content->getPreviewPicture()); - $this->assertEmpty($content->getLanguage()); - } - - public function testImportWallabagWithChromeFile() - { - $this->logInAs('admin'); - $client = $this->getClient(); - - $crawler = $client->request('GET', '/import/browser'); - $form = $crawler->filter('form[name=upload_import_file] > button[type=submit]')->form(); - - $file = new UploadedFile(__DIR__.'/../fixtures/chrome-bookmarks', 'Bookmarks'); - - $data = [ - 'upload_import_file[file]' => $file, - ]; - - $client->submit($form, $data); - - $this->assertEquals(302, $client->getResponse()->getStatusCode()); - - $crawler = $client->followRedirect(); - - $this->assertGreaterThan(1, $body = $crawler->filter('body')->extract(['_text'])); - $this->assertContains('flashes.import.notice.summary', $body[0]); - - $content = $client->getContainer() - ->get('doctrine.orm.entity_manager') - ->getRepository('WallabagCoreBundle:Entry') - ->findByUrlAndUserId( - 'http://www.usinenouvelle.com/article/la-multiplication-des-chefs-de-projet-est-une-catastrophe-manageriale-majeure-affirme-le-sociologue-francois-dupuy.N307730', - $this->getLoggedInUserId() - ); - - $this->assertNotEmpty($content->getMimetype()); - $this->assertNotEmpty($content->getPreviewPicture()); - $this->assertNotEmpty($content->getLanguage()); - $this->assertEquals(0, count($content->getTags())); - } - - public function testImportWallabagWithEmptyFile() - { - $this->logInAs('admin'); - $client = $this->getClient(); - - $crawler = $client->request('GET', '/import/browser'); - $form = $crawler->filter('form[name=upload_import_file] > button[type=submit]')->form(); - - $file = new UploadedFile(__DIR__.'/../fixtures/test.txt', 'test.txt'); - - $data = [ - 'upload_import_file[file]' => $file, - ]; - - $client->submit($form, $data); - - $this->assertEquals(302, $client->getResponse()->getStatusCode()); - - $crawler = $client->followRedirect(); - - $this->assertGreaterThan(1, $body = $crawler->filter('body')->extract(['_text'])); - $this->assertContains('flashes.import.notice.failed', $body[0]); - } -} diff --git a/tests/Wallabag/ImportBundle/Controller/ChromeControllerTest.php b/tests/Wallabag/ImportBundle/Controller/ChromeControllerTest.php new file mode 100644 index 00000000..448e559f --- /dev/null +++ b/tests/Wallabag/ImportBundle/Controller/ChromeControllerTest.php @@ -0,0 +1,149 @@ +logInAs('admin'); + $client = $this->getClient(); + + $crawler = $client->request('GET', '/import/chrome'); + + $this->assertEquals(200, $client->getResponse()->getStatusCode()); + $this->assertEquals(1, $crawler->filter('form[name=upload_import_file] > button[type=submit]')->count()); + $this->assertEquals(1, $crawler->filter('input[type=file]')->count()); + } + + public function testImportChromeWithRabbitEnabled() + { + $this->logInAs('admin'); + $client = $this->getClient(); + + $client->getContainer()->get('craue_config')->set('import_with_rabbitmq', 1); + + $crawler = $client->request('GET', '/import/chrome'); + + $this->assertEquals(200, $client->getResponse()->getStatusCode()); + $this->assertEquals(1, $crawler->filter('form[name=upload_import_file] > button[type=submit]')->count()); + $this->assertEquals(1, $crawler->filter('input[type=file]')->count()); + + $client->getContainer()->get('craue_config')->set('import_with_rabbitmq', 0); + } + + public function testImportChromeBadFile() + { + $this->logInAs('admin'); + $client = $this->getClient(); + + $crawler = $client->request('GET', '/import/chrome'); + $form = $crawler->filter('form[name=upload_import_file] > button[type=submit]')->form(); + + $data = [ + 'upload_import_file[file]' => '', + ]; + + $client->submit($form, $data); + + $this->assertEquals(200, $client->getResponse()->getStatusCode()); + } + + public function testImportChromeWithRedisEnabled() + { + $this->logInAs('admin'); + $client = $this->getClient(); + $client->getContainer()->get('craue_config')->set('import_with_redis', 1); + + $crawler = $client->request('GET', '/import/chrome'); + + $this->assertEquals(200, $client->getResponse()->getStatusCode()); + $this->assertEquals(1, $crawler->filter('form[name=upload_import_file] > button[type=submit]')->count()); + $this->assertEquals(1, $crawler->filter('input[type=file]')->count()); + + $form = $crawler->filter('form[name=upload_import_file] > button[type=submit]')->form(); + + $file = new UploadedFile(__DIR__.'/../fixtures/chrome-bookmarks', 'Bookmarks'); + + $data = [ + 'upload_import_file[file]' => $file, + ]; + + $client->submit($form, $data); + + $this->assertEquals(302, $client->getResponse()->getStatusCode()); + + $crawler = $client->followRedirect(); + + $this->assertGreaterThan(1, $body = $crawler->filter('body')->extract(['_text'])); + $this->assertContains('flashes.import.notice.summary', $body[0]); + + $this->assertNotEmpty($client->getContainer()->get('wallabag_core.redis.client')->lpop('wallabag.import.chrome')); + + $client->getContainer()->get('craue_config')->set('import_with_redis', 0); + } + + public function testImportWallabagWithChromeFile() + { + $this->logInAs('admin'); + $client = $this->getClient(); + + $crawler = $client->request('GET', '/import/chrome'); + $form = $crawler->filter('form[name=upload_import_file] > button[type=submit]')->form(); + + $file = new UploadedFile(__DIR__.'/../fixtures/chrome-bookmarks', 'Bookmarks'); + + $data = [ + 'upload_import_file[file]' => $file, + ]; + + $client->submit($form, $data); + + $this->assertEquals(302, $client->getResponse()->getStatusCode()); + + $crawler = $client->followRedirect(); + + $this->assertGreaterThan(1, $body = $crawler->filter('body')->extract(['_text'])); + $this->assertContains('flashes.import.notice.summary', $body[0]); + + $content = $client->getContainer() + ->get('doctrine.orm.entity_manager') + ->getRepository('WallabagCoreBundle:Entry') + ->findByUrlAndUserId( + 'http://www.usinenouvelle.com/article/la-multiplication-des-chefs-de-projet-est-une-catastrophe-manageriale-majeure-affirme-le-sociologue-francois-dupuy.N307730', + $this->getLoggedInUserId() + ); + + $this->assertEmpty($content->getMimetype()); + $this->assertNotEmpty($content->getPreviewPicture()); + $this->assertNotEmpty($content->getLanguage()); + $this->assertEquals(0, count($content->getTags())); + } + + public function testImportWallabagWithEmptyFile() + { + $this->logInAs('admin'); + $client = $this->getClient(); + + $crawler = $client->request('GET', '/import/chrome'); + $form = $crawler->filter('form[name=upload_import_file] > button[type=submit]')->form(); + + $file = new UploadedFile(__DIR__.'/../fixtures/test.txt', 'test.txt'); + + $data = [ + 'upload_import_file[file]' => $file, + ]; + + $client->submit($form, $data); + + $this->assertEquals(302, $client->getResponse()->getStatusCode()); + + $crawler = $client->followRedirect(); + + $this->assertGreaterThan(1, $body = $crawler->filter('body')->extract(['_text'])); + $this->assertContains('flashes.import.notice.failed', $body[0]); + } +} diff --git a/tests/Wallabag/ImportBundle/Controller/FirefoxControllerTest.php b/tests/Wallabag/ImportBundle/Controller/FirefoxControllerTest.php new file mode 100644 index 00000000..2de0aa09 --- /dev/null +++ b/tests/Wallabag/ImportBundle/Controller/FirefoxControllerTest.php @@ -0,0 +1,161 @@ +logInAs('admin'); + $client = $this->getClient(); + + $crawler = $client->request('GET', '/import/firefox'); + + $this->assertEquals(200, $client->getResponse()->getStatusCode()); + $this->assertEquals(1, $crawler->filter('form[name=upload_import_file] > button[type=submit]')->count()); + $this->assertEquals(1, $crawler->filter('input[type=file]')->count()); + } + + public function testImportFirefoxWithRabbitEnabled() + { + $this->logInAs('admin'); + $client = $this->getClient(); + + $client->getContainer()->get('craue_config')->set('import_with_rabbitmq', 1); + + $crawler = $client->request('GET', '/import/firefox'); + + $this->assertEquals(200, $client->getResponse()->getStatusCode()); + $this->assertEquals(1, $crawler->filter('form[name=upload_import_file] > button[type=submit]')->count()); + $this->assertEquals(1, $crawler->filter('input[type=file]')->count()); + + $client->getContainer()->get('craue_config')->set('import_with_rabbitmq', 0); + } + + public function testImportFirefoxBadFile() + { + $this->logInAs('admin'); + $client = $this->getClient(); + + $crawler = $client->request('GET', '/import/firefox'); + $form = $crawler->filter('form[name=upload_import_file] > button[type=submit]')->form(); + + $data = [ + 'upload_import_file[file]' => '', + ]; + + $client->submit($form, $data); + + $this->assertEquals(200, $client->getResponse()->getStatusCode()); + } + + public function testImportFirefoxWithRedisEnabled() + { + $this->logInAs('admin'); + $client = $this->getClient(); + $client->getContainer()->get('craue_config')->set('import_with_redis', 1); + + $crawler = $client->request('GET', '/import/firefox'); + + $this->assertEquals(200, $client->getResponse()->getStatusCode()); + $this->assertEquals(1, $crawler->filter('form[name=upload_import_file] > button[type=submit]')->count()); + $this->assertEquals(1, $crawler->filter('input[type=file]')->count()); + + $form = $crawler->filter('form[name=upload_import_file] > button[type=submit]')->form(); + + $file = new UploadedFile(__DIR__.'/../fixtures/firefox-bookmarks.json', 'Bookmarks'); + + $data = [ + 'upload_import_file[file]' => $file, + ]; + + $client->submit($form, $data); + + $this->assertEquals(302, $client->getResponse()->getStatusCode()); + + $crawler = $client->followRedirect(); + + $this->assertGreaterThan(1, $body = $crawler->filter('body')->extract(['_text'])); + $this->assertContains('flashes.import.notice.summary', $body[0]); + + $this->assertNotEmpty($client->getContainer()->get('wallabag_core.redis.client')->lpop('wallabag.import.firefox')); + + $client->getContainer()->get('craue_config')->set('import_with_redis', 0); + } + + public function testImportWallabagWithFirefoxFile() + { + $this->logInAs('admin'); + $client = $this->getClient(); + + $crawler = $client->request('GET', '/import/firefox'); + $form = $crawler->filter('form[name=upload_import_file] > button[type=submit]')->form(); + + $file = new UploadedFile(__DIR__.'/../fixtures/firefox-bookmarks.json', 'Bookmarks'); + + $data = [ + 'upload_import_file[file]' => $file, + ]; + + $client->submit($form, $data); + + $this->assertEquals(302, $client->getResponse()->getStatusCode()); + + $crawler = $client->followRedirect(); + + $this->assertGreaterThan(1, $body = $crawler->filter('body')->extract(['_text'])); + $this->assertContains('flashes.import.notice.summary', $body[0]); + + $content = $client->getContainer() + ->get('doctrine.orm.entity_manager') + ->getRepository('WallabagCoreBundle:Entry') + ->findByUrlAndUserId( + 'http://lexpansion.lexpress.fr/high-tech/orange-offre-un-meilleur-reseau-mobile-que-bouygues-et-sfr-free-derriere_1811554.html', + $this->getLoggedInUserId() + ); + + $this->assertNotEmpty($content->getMimetype()); + $this->assertNotEmpty($content->getPreviewPicture()); + $this->assertNotEmpty($content->getLanguage()); + $this->assertEquals(0, count($content->getTags())); + + $content = $client->getContainer() + ->get('doctrine.orm.entity_manager') + ->getRepository('WallabagCoreBundle:Entry') + ->findByUrlAndUserId( + 'http://stackoverflow.com/questions/15017163/parser-for-exported-bookmarks-html-file-of-google-chrome-and-mozilla-in-java', + $this->getLoggedInUserId() + ); + + $this->assertNotEmpty($content->getMimetype()); + $this->assertNotEmpty($content->getPreviewPicture()); + $this->assertEmpty($content->getLanguage()); + } + + public function testImportWallabagWithEmptyFile() + { + $this->logInAs('admin'); + $client = $this->getClient(); + + $crawler = $client->request('GET', '/import/firefox'); + $form = $crawler->filter('form[name=upload_import_file] > button[type=submit]')->form(); + + $file = new UploadedFile(__DIR__.'/../fixtures/test.txt', 'test.txt'); + + $data = [ + 'upload_import_file[file]' => $file, + ]; + + $client->submit($form, $data); + + $this->assertEquals(302, $client->getResponse()->getStatusCode()); + + $crawler = $client->followRedirect(); + + $this->assertGreaterThan(1, $body = $crawler->filter('body')->extract(['_text'])); + $this->assertContains('flashes.import.notice.failed', $body[0]); + } +} diff --git a/tests/Wallabag/ImportBundle/Controller/ImportControllerTest.php b/tests/Wallabag/ImportBundle/Controller/ImportControllerTest.php index 23a7c877..b6783a56 100644 --- a/tests/Wallabag/ImportBundle/Controller/ImportControllerTest.php +++ b/tests/Wallabag/ImportBundle/Controller/ImportControllerTest.php @@ -24,6 +24,6 @@ class ImportControllerTest extends WallabagCoreTestCase $crawler = $client->request('GET', '/import/'); $this->assertEquals(200, $client->getResponse()->getStatusCode()); - $this->assertEquals(5, $crawler->filter('blockquote')->count()); + $this->assertEquals(6, $crawler->filter('blockquote')->count()); } } diff --git a/tests/Wallabag/ImportBundle/Controller/ReadabilityControllerTest.php b/tests/Wallabag/ImportBundle/Controller/ReadabilityControllerTest.php index 87ecb9d3..916dd297 100644 --- a/tests/Wallabag/ImportBundle/Controller/ReadabilityControllerTest.php +++ b/tests/Wallabag/ImportBundle/Controller/ReadabilityControllerTest.php @@ -57,7 +57,6 @@ class ReadabilityControllerTest extends WallabagCoreTestCase $this->checkRedis(); $this->logInAs('admin'); $client = $this->getClient(); - $client->getContainer()->get('craue_config')->set('import_with_redis', 1); $crawler = $client->request('GET', '/import/readability'); diff --git a/tests/Wallabag/ImportBundle/Import/ChromeImportTest.php b/tests/Wallabag/ImportBundle/Import/ChromeImportTest.php new file mode 100644 index 00000000..f781a4d2 --- /dev/null +++ b/tests/Wallabag/ImportBundle/Import/ChromeImportTest.php @@ -0,0 +1,233 @@ +user = new User(); + + $this->em = $this->getMockBuilder('Doctrine\ORM\EntityManager') + ->disableOriginalConstructor() + ->getMock(); + + $this->contentProxy = $this->getMockBuilder('Wallabag\CoreBundle\Helper\ContentProxy') + ->disableOriginalConstructor() + ->getMock(); + + $wallabag = new ChromeImport($this->em, $this->contentProxy); + + $this->logHandler = new TestHandler(); + $logger = new Logger('test', [$this->logHandler]); + $wallabag->setLogger($logger); + + if (false === $unsetUser) { + $wallabag->setUser($this->user); + } + + return $wallabag; + } + + public function testInit() + { + $chromeImport = $this->getChromeImport(); + + $this->assertEquals('Chrome', $chromeImport->getName()); + $this->assertNotEmpty($chromeImport->getUrl()); + $this->assertEquals('import.chrome.description', $chromeImport->getDescription()); + } + + public function testImport() + { + $chromeImport = $this->getChromeImport(); + $chromeImport->setFilepath(__DIR__.'/../fixtures/chrome-bookmarks'); + + $entryRepo = $this->getMockBuilder('Wallabag\CoreBundle\Repository\EntryRepository') + ->disableOriginalConstructor() + ->getMock(); + + $entryRepo->expects($this->exactly(4)) + ->method('findByUrlAndUserId') + ->willReturn(false); + + $this->em + ->expects($this->any()) + ->method('getRepository') + ->willReturn($entryRepo); + + $entry = $this->getMockBuilder('Wallabag\CoreBundle\Entity\Entry') + ->disableOriginalConstructor() + ->getMock(); + + $this->contentProxy + ->expects($this->exactly(4)) + ->method('updateEntry') + ->willReturn($entry); + + $res = $chromeImport->import(); + + $this->assertTrue($res); + $this->assertEquals(['skipped' => 0, 'imported' => 4, 'queued' => 0], $chromeImport->getSummary()); + } + + public function testImportAndMarkAllAsRead() + { + $chromeImport = $this->getChromeImport(); + $chromeImport->setFilepath(__DIR__.'/../fixtures/readability-read.json'); + + $entryRepo = $this->getMockBuilder('Wallabag\CoreBundle\Repository\EntryRepository') + ->disableOriginalConstructor() + ->getMock(); + + $entryRepo->expects($this->exactly(2)) + ->method('findByUrlAndUserId') + ->will($this->onConsecutiveCalls(false, true)); + + $this->em + ->expects($this->any()) + ->method('getRepository') + ->willReturn($entryRepo); + + $this->contentProxy + ->expects($this->exactly(1)) + ->method('updateEntry') + ->willReturn(new Entry($this->user)); + + // check that every entry persisted are archived + $this->em + ->expects($this->any()) + ->method('persist') + ->with($this->callback(function ($persistedEntry) { + return $persistedEntry->isArchived(); + })); + + $res = $chromeImport->setMarkAsRead(true)->import(); + + $this->assertTrue($res); + + $this->assertEquals(['skipped' => 1, 'imported' => 1, 'queued' => 0], $chromeImport->getSummary()); + } + + public function testImportWithRabbit() + { + $chromeImport = $this->getChromeImport(); + $chromeImport->setFilepath(__DIR__.'/../fixtures/readability.json'); + + $entryRepo = $this->getMockBuilder('Wallabag\CoreBundle\Repository\EntryRepository') + ->disableOriginalConstructor() + ->getMock(); + + $entryRepo->expects($this->never()) + ->method('findByUrlAndUserId'); + + $this->em + ->expects($this->never()) + ->method('getRepository'); + + $entry = $this->getMockBuilder('Wallabag\CoreBundle\Entity\Entry') + ->disableOriginalConstructor() + ->getMock(); + + $this->contentProxy + ->expects($this->never()) + ->method('updateEntry'); + + $producer = $this->getMockBuilder('OldSound\RabbitMqBundle\RabbitMq\Producer') + ->disableOriginalConstructor() + ->getMock(); + + $producer + ->expects($this->exactly(4)) + ->method('publish'); + + $chromeImport->setProducer($producer); + + $res = $readabilityImport->setMarkAsRead(true)->import(); + + $this->assertTrue($res); + $this->assertEquals(['skipped' => 0, 'imported' => 0, 'queued' => 4], $chromeImport->getSummary()); + } + + public function testImportWithRedis() + { + $chromeImport = $this->getReadabilityImport(); + $chromeImport->setFilepath(__DIR__.'/../fixtures/chrome-bookmarks'); + + $entryRepo = $this->getMockBuilder('Wallabag\CoreBundle\Repository\EntryRepository') + ->disableOriginalConstructor() + ->getMock(); + + $entryRepo->expects($this->never()) + ->method('findByUrlAndUserId'); + + $this->em + ->expects($this->never()) + ->method('getRepository'); + + $entry = $this->getMockBuilder('Wallabag\CoreBundle\Entity\Entry') + ->disableOriginalConstructor() + ->getMock(); + + $this->contentProxy + ->expects($this->never()) + ->method('updateEntry'); + + $factory = new RedisMockFactory(); + $redisMock = $factory->getAdapter('Predis\Client', true); + + $queue = new RedisQueue($redisMock, 'chrome'); + $producer = new Producer($queue); + + $chromeImport->setProducer($producer); + + $res = $chromeImport->setMarkAsRead(true)->import(); + + $this->assertTrue($res); + $this->assertEquals(['skipped' => 0, 'imported' => 0, 'queued' => 4], $chromeImport->getSummary()); + + $this->assertNotEmpty($redisMock->lpop('chrome')); + } + + public function testImportBadFile() + { + $chromeImport = $this->getChromeImport(); + $chromeImport->setFilepath(__DIR__.'/../fixtures/wallabag-v1.jsonx'); + + $res = $chromeImport->import(); + + $this->assertFalse($res); + + $records = $this->logHandler->getRecords(); + $this->assertContains('ChromeImport: unable to read file', $records[0]['message']); + $this->assertEquals('ERROR', $records[0]['level_name']); + } + + public function testImportUserNotDefined() + { + $chromeImport = $this->getChromeImport(true); + $chromeImport->setFilepath(__DIR__.'/../fixtures/readability.json'); + + $res = $chromeImport->import(); + + $this->assertFalse($res); + + $records = $this->logHandler->getRecords(); + $this->assertContains('ChromeImport: user is not defined', $records[0]['message']); + $this->assertEquals('ERROR', $records[0]['level_name']); + } +} diff --git a/tests/Wallabag/ImportBundle/Import/FirefoxImportTest.php b/tests/Wallabag/ImportBundle/Import/FirefoxImportTest.php new file mode 100644 index 00000000..0b4a28b4 --- /dev/null +++ b/tests/Wallabag/ImportBundle/Import/FirefoxImportTest.php @@ -0,0 +1,233 @@ +user = new User(); + + $this->em = $this->getMockBuilder('Doctrine\ORM\EntityManager') + ->disableOriginalConstructor() + ->getMock(); + + $this->contentProxy = $this->getMockBuilder('Wallabag\CoreBundle\Helper\ContentProxy') + ->disableOriginalConstructor() + ->getMock(); + + $wallabag = new FirefoxImport($this->em, $this->contentProxy); + + $this->logHandler = new TestHandler(); + $logger = new Logger('test', [$this->logHandler]); + $wallabag->setLogger($logger); + + if (false === $unsetUser) { + $wallabag->setUser($this->user); + } + + return $wallabag; + } + + public function testInit() + { + $firefoxImport = $this->getFirefoxImport(); + + $this->assertEquals('Firefox', $firefoxImport->getName()); + $this->assertNotEmpty($firefoxImport->getUrl()); + $this->assertEquals('import.firefox.description', $firefoxImport->getDescription()); + } + + public function testImport() + { + $firefoxImport = $this->getFirefoxImport(); + $firefoxImport->setFilepath(__DIR__.'/../fixtures/firefox-bookmarks.json'); + + $entryRepo = $this->getMockBuilder('Wallabag\CoreBundle\Repository\EntryRepository') + ->disableOriginalConstructor() + ->getMock(); + + $entryRepo->expects($this->exactly(4)) + ->method('findByUrlAndUserId') + ->willReturn(false); + + $this->em + ->expects($this->any()) + ->method('getRepository') + ->willReturn($entryRepo); + + $entry = $this->getMockBuilder('Wallabag\CoreBundle\Entity\Entry') + ->disableOriginalConstructor() + ->getMock(); + + $this->contentProxy + ->expects($this->exactly(4)) + ->method('updateEntry') + ->willReturn($entry); + + $res = $firefoxImport->import(); + + $this->assertTrue($res); + $this->assertEquals(['skipped' => 0, 'imported' => 4, 'queued' => 0], $firefoxImport->getSummary()); + } + + public function testImportAndMarkAllAsRead() + { + $firefoxImport = $this->getFirefoxImport(); + $firefoxImport->setFilepath(__DIR__.'/../fixtures/readability-read.json'); + + $entryRepo = $this->getMockBuilder('Wallabag\CoreBundle\Repository\EntryRepository') + ->disableOriginalConstructor() + ->getMock(); + + $entryRepo->expects($this->exactly(2)) + ->method('findByUrlAndUserId') + ->will($this->onConsecutiveCalls(false, true)); + + $this->em + ->expects($this->any()) + ->method('getRepository') + ->willReturn($entryRepo); + + $this->contentProxy + ->expects($this->exactly(1)) + ->method('updateEntry') + ->willReturn(new Entry($this->user)); + + // check that every entry persisted are archived + $this->em + ->expects($this->any()) + ->method('persist') + ->with($this->callback(function ($persistedEntry) { + return $persistedEntry->isArchived(); + })); + + $res = $firefoxImport->setMarkAsRead(true)->import(); + + $this->assertTrue($res); + + $this->assertEquals(['skipped' => 1, 'imported' => 1, 'queued' => 0], $firefoxImport->getSummary()); + } + + public function testImportWithRabbit() + { + $firefoxImport = $this->getFirefoxImport(); + $firefoxImport->setFilepath(__DIR__.'/../fixtures/readability.json'); + + $entryRepo = $this->getMockBuilder('Wallabag\CoreBundle\Repository\EntryRepository') + ->disableOriginalConstructor() + ->getMock(); + + $entryRepo->expects($this->never()) + ->method('findByUrlAndUserId'); + + $this->em + ->expects($this->never()) + ->method('getRepository'); + + $entry = $this->getMockBuilder('Wallabag\CoreBundle\Entity\Entry') + ->disableOriginalConstructor() + ->getMock(); + + $this->contentProxy + ->expects($this->never()) + ->method('updateEntry'); + + $producer = $this->getMockBuilder('OldSound\RabbitMqBundle\RabbitMq\Producer') + ->disableOriginalConstructor() + ->getMock(); + + $producer + ->expects($this->exactly(4)) + ->method('publish'); + + $firefoxImport->setProducer($producer); + + $res = $readabilityImport->setMarkAsRead(true)->import(); + + $this->assertTrue($res); + $this->assertEquals(['skipped' => 0, 'imported' => 0, 'queued' => 4], $firefoxImport->getSummary()); + } + + public function testImportWithRedis() + { + $firefoxImport = $this->getReadabilityImport(); + $firefoxImport->setFilepath(__DIR__.'/../fixtures/firefox-bookmarks.json'); + + $entryRepo = $this->getMockBuilder('Wallabag\CoreBundle\Repository\EntryRepository') + ->disableOriginalConstructor() + ->getMock(); + + $entryRepo->expects($this->never()) + ->method('findByUrlAndUserId'); + + $this->em + ->expects($this->never()) + ->method('getRepository'); + + $entry = $this->getMockBuilder('Wallabag\CoreBundle\Entity\Entry') + ->disableOriginalConstructor() + ->getMock(); + + $this->contentProxy + ->expects($this->never()) + ->method('updateEntry'); + + $factory = new RedisMockFactory(); + $redisMock = $factory->getAdapter('Predis\Client', true); + + $queue = new RedisQueue($redisMock, 'firefox'); + $producer = new Producer($queue); + + $firefoxImport->setProducer($producer); + + $res = $firefoxImport->setMarkAsRead(true)->import(); + + $this->assertTrue($res); + $this->assertEquals(['skipped' => 0, 'imported' => 0, 'queued' => 4], $firefoxImport->getSummary()); + + $this->assertNotEmpty($redisMock->lpop('firefox')); + } + + public function testImportBadFile() + { + $firefoxImport = $this->getFirefoxImport(); + $firefoxImport->setFilepath(__DIR__.'/../fixtures/wallabag-v1.jsonx'); + + $res = $firefoxImport->import(); + + $this->assertFalse($res); + + $records = $this->logHandler->getRecords(); + $this->assertContains('FirefoxImport: unable to read file', $records[0]['message']); + $this->assertEquals('ERROR', $records[0]['level_name']); + } + + public function testImportUserNotDefined() + { + $firefoxImport = $this->getFirefoxImport(true); + $firefoxImport->setFilepath(__DIR__.'/../fixtures/readability.json'); + + $res = $firefoxImport->import(); + + $this->assertFalse($res); + + $records = $this->logHandler->getRecords(); + $this->assertContains('FirefoxImport: user is not defined', $records[0]['message']); + $this->assertEquals('ERROR', $records[0]['level_name']); + } +} -- cgit v1.2.3 From 64b1229b2d711e6b2f0e60de482802d9e86b912f Mon Sep 17 00:00:00 2001 From: Thomas Citharel Date: Wed, 21 Sep 2016 19:24:19 +0200 Subject: fix tests --- .../Controller/ChromeControllerTest.php | 1 - .../ImportBundle/Import/ChromeImportTest.php | 30 +++++++++++----------- .../ImportBundle/Import/FirefoxImportTest.php | 24 ++++++++--------- 3 files changed, 27 insertions(+), 28 deletions(-) (limited to 'tests/Wallabag/ImportBundle') diff --git a/tests/Wallabag/ImportBundle/Controller/ChromeControllerTest.php b/tests/Wallabag/ImportBundle/Controller/ChromeControllerTest.php index 448e559f..8890c5b1 100644 --- a/tests/Wallabag/ImportBundle/Controller/ChromeControllerTest.php +++ b/tests/Wallabag/ImportBundle/Controller/ChromeControllerTest.php @@ -117,7 +117,6 @@ class ChromeControllerTest extends WallabagCoreTestCase $this->getLoggedInUserId() ); - $this->assertEmpty($content->getMimetype()); $this->assertNotEmpty($content->getPreviewPicture()); $this->assertNotEmpty($content->getLanguage()); $this->assertEquals(0, count($content->getTags())); diff --git a/tests/Wallabag/ImportBundle/Import/ChromeImportTest.php b/tests/Wallabag/ImportBundle/Import/ChromeImportTest.php index f781a4d2..1e52615c 100644 --- a/tests/Wallabag/ImportBundle/Import/ChromeImportTest.php +++ b/tests/Wallabag/ImportBundle/Import/ChromeImportTest.php @@ -61,7 +61,7 @@ class ChromeImportTest extends \PHPUnit_Framework_TestCase ->disableOriginalConstructor() ->getMock(); - $entryRepo->expects($this->exactly(4)) + $entryRepo->expects($this->exactly(1)) ->method('findByUrlAndUserId') ->willReturn(false); @@ -75,26 +75,26 @@ class ChromeImportTest extends \PHPUnit_Framework_TestCase ->getMock(); $this->contentProxy - ->expects($this->exactly(4)) + ->expects($this->exactly(1)) ->method('updateEntry') ->willReturn($entry); $res = $chromeImport->import(); $this->assertTrue($res); - $this->assertEquals(['skipped' => 0, 'imported' => 4, 'queued' => 0], $chromeImport->getSummary()); + $this->assertEquals(['skipped' => 0, 'imported' => 1, 'queued' => 0], $chromeImport->getSummary()); } public function testImportAndMarkAllAsRead() { $chromeImport = $this->getChromeImport(); - $chromeImport->setFilepath(__DIR__.'/../fixtures/readability-read.json'); + $chromeImport->setFilepath(__DIR__.'/../fixtures/chrome-bookmarks'); $entryRepo = $this->getMockBuilder('Wallabag\CoreBundle\Repository\EntryRepository') ->disableOriginalConstructor() ->getMock(); - $entryRepo->expects($this->exactly(2)) + $entryRepo->expects($this->exactly(1)) ->method('findByUrlAndUserId') ->will($this->onConsecutiveCalls(false, true)); @@ -120,13 +120,13 @@ class ChromeImportTest extends \PHPUnit_Framework_TestCase $this->assertTrue($res); - $this->assertEquals(['skipped' => 1, 'imported' => 1, 'queued' => 0], $chromeImport->getSummary()); + $this->assertEquals(['skipped' => 0, 'imported' => 1, 'queued' => 0], $chromeImport->getSummary()); } public function testImportWithRabbit() { $chromeImport = $this->getChromeImport(); - $chromeImport->setFilepath(__DIR__.'/../fixtures/readability.json'); + $chromeImport->setFilepath(__DIR__.'/../fixtures/chrome-bookmarks'); $entryRepo = $this->getMockBuilder('Wallabag\CoreBundle\Repository\EntryRepository') ->disableOriginalConstructor() @@ -152,20 +152,20 @@ class ChromeImportTest extends \PHPUnit_Framework_TestCase ->getMock(); $producer - ->expects($this->exactly(4)) + ->expects($this->exactly(1)) ->method('publish'); $chromeImport->setProducer($producer); - $res = $readabilityImport->setMarkAsRead(true)->import(); + $res = $chromeImport->setMarkAsRead(true)->import(); $this->assertTrue($res); - $this->assertEquals(['skipped' => 0, 'imported' => 0, 'queued' => 4], $chromeImport->getSummary()); + $this->assertEquals(['skipped' => 0, 'imported' => 0, 'queued' => 1], $chromeImport->getSummary()); } public function testImportWithRedis() { - $chromeImport = $this->getReadabilityImport(); + $chromeImport = $this->getChromeImport(); $chromeImport->setFilepath(__DIR__.'/../fixtures/chrome-bookmarks'); $entryRepo = $this->getMockBuilder('Wallabag\CoreBundle\Repository\EntryRepository') @@ -198,7 +198,7 @@ class ChromeImportTest extends \PHPUnit_Framework_TestCase $res = $chromeImport->setMarkAsRead(true)->import(); $this->assertTrue($res); - $this->assertEquals(['skipped' => 0, 'imported' => 0, 'queued' => 4], $chromeImport->getSummary()); + $this->assertEquals(['skipped' => 0, 'imported' => 0, 'queued' => 1], $chromeImport->getSummary()); $this->assertNotEmpty($redisMock->lpop('chrome')); } @@ -213,21 +213,21 @@ class ChromeImportTest extends \PHPUnit_Framework_TestCase $this->assertFalse($res); $records = $this->logHandler->getRecords(); - $this->assertContains('ChromeImport: unable to read file', $records[0]['message']); + $this->assertContains('Wallabag Browser Import: unable to read file', $records[0]['message']); $this->assertEquals('ERROR', $records[0]['level_name']); } public function testImportUserNotDefined() { $chromeImport = $this->getChromeImport(true); - $chromeImport->setFilepath(__DIR__.'/../fixtures/readability.json'); + $chromeImport->setFilepath(__DIR__.'/../fixtures/chrome-bookmarks'); $res = $chromeImport->import(); $this->assertFalse($res); $records = $this->logHandler->getRecords(); - $this->assertContains('ChromeImport: user is not defined', $records[0]['message']); + $this->assertContains('Wallabag Browser Import: user is not defined', $records[0]['message']); $this->assertEquals('ERROR', $records[0]['level_name']); } } diff --git a/tests/Wallabag/ImportBundle/Import/FirefoxImportTest.php b/tests/Wallabag/ImportBundle/Import/FirefoxImportTest.php index 0b4a28b4..e8f0f3c7 100644 --- a/tests/Wallabag/ImportBundle/Import/FirefoxImportTest.php +++ b/tests/Wallabag/ImportBundle/Import/FirefoxImportTest.php @@ -88,13 +88,13 @@ class FirefoxImportTest extends \PHPUnit_Framework_TestCase public function testImportAndMarkAllAsRead() { $firefoxImport = $this->getFirefoxImport(); - $firefoxImport->setFilepath(__DIR__.'/../fixtures/readability-read.json'); + $firefoxImport->setFilepath(__DIR__.'/../fixtures/firefox-bookmarks.json'); $entryRepo = $this->getMockBuilder('Wallabag\CoreBundle\Repository\EntryRepository') ->disableOriginalConstructor() ->getMock(); - $entryRepo->expects($this->exactly(2)) + $entryRepo->expects($this->exactly(4)) ->method('findByUrlAndUserId') ->will($this->onConsecutiveCalls(false, true)); @@ -120,13 +120,13 @@ class FirefoxImportTest extends \PHPUnit_Framework_TestCase $this->assertTrue($res); - $this->assertEquals(['skipped' => 1, 'imported' => 1, 'queued' => 0], $firefoxImport->getSummary()); + $this->assertEquals(['skipped' => 3, 'imported' => 1, 'queued' => 0], $firefoxImport->getSummary()); } public function testImportWithRabbit() { $firefoxImport = $this->getFirefoxImport(); - $firefoxImport->setFilepath(__DIR__.'/../fixtures/readability.json'); + $firefoxImport->setFilepath(__DIR__.'/../fixtures/firefox-bookmarks.json'); $entryRepo = $this->getMockBuilder('Wallabag\CoreBundle\Repository\EntryRepository') ->disableOriginalConstructor() @@ -152,20 +152,20 @@ class FirefoxImportTest extends \PHPUnit_Framework_TestCase ->getMock(); $producer - ->expects($this->exactly(4)) + ->expects($this->exactly(1)) ->method('publish'); $firefoxImport->setProducer($producer); - $res = $readabilityImport->setMarkAsRead(true)->import(); + $res = $firefoxImport->setMarkAsRead(true)->import(); $this->assertTrue($res); - $this->assertEquals(['skipped' => 0, 'imported' => 0, 'queued' => 4], $firefoxImport->getSummary()); + $this->assertEquals(['skipped' => 0, 'imported' => 0, 'queued' => 1], $firefoxImport->getSummary()); } public function testImportWithRedis() { - $firefoxImport = $this->getReadabilityImport(); + $firefoxImport = $this->getFirefoxImport(); $firefoxImport->setFilepath(__DIR__.'/../fixtures/firefox-bookmarks.json'); $entryRepo = $this->getMockBuilder('Wallabag\CoreBundle\Repository\EntryRepository') @@ -198,7 +198,7 @@ class FirefoxImportTest extends \PHPUnit_Framework_TestCase $res = $firefoxImport->setMarkAsRead(true)->import(); $this->assertTrue($res); - $this->assertEquals(['skipped' => 0, 'imported' => 0, 'queued' => 4], $firefoxImport->getSummary()); + $this->assertEquals(['skipped' => 0, 'imported' => 0, 'queued' => 1], $firefoxImport->getSummary()); $this->assertNotEmpty($redisMock->lpop('firefox')); } @@ -213,21 +213,21 @@ class FirefoxImportTest extends \PHPUnit_Framework_TestCase $this->assertFalse($res); $records = $this->logHandler->getRecords(); - $this->assertContains('FirefoxImport: unable to read file', $records[0]['message']); + $this->assertContains('Wallabag Browser Import: unable to read file', $records[0]['message']); $this->assertEquals('ERROR', $records[0]['level_name']); } public function testImportUserNotDefined() { $firefoxImport = $this->getFirefoxImport(true); - $firefoxImport->setFilepath(__DIR__.'/../fixtures/readability.json'); + $firefoxImport->setFilepath(__DIR__.'/../fixtures/firefox-bookmarks.json'); $res = $firefoxImport->import(); $this->assertFalse($res); $records = $this->logHandler->getRecords(); - $this->assertContains('FirefoxImport: user is not defined', $records[0]['message']); + $this->assertContains('Wallabag Browser Import: user is not defined', $records[0]['message']); $this->assertEquals('ERROR', $records[0]['level_name']); } } -- cgit v1.2.3 From 27acc6ddb8b0a1549a3f015171621e3056ef65d2 Mon Sep 17 00:00:00 2001 From: Jeremy Benoist Date: Sun, 25 Sep 2016 15:29:40 +0200 Subject: Fix bad date format in Browser import --- tests/Wallabag/ImportBundle/Controller/ChromeControllerTest.php | 4 ++++ tests/Wallabag/ImportBundle/Controller/FirefoxControllerTest.php | 4 ++++ 2 files changed, 8 insertions(+) (limited to 'tests/Wallabag/ImportBundle') diff --git a/tests/Wallabag/ImportBundle/Controller/ChromeControllerTest.php b/tests/Wallabag/ImportBundle/Controller/ChromeControllerTest.php index 8890c5b1..23c80bec 100644 --- a/tests/Wallabag/ImportBundle/Controller/ChromeControllerTest.php +++ b/tests/Wallabag/ImportBundle/Controller/ChromeControllerTest.php @@ -120,6 +120,10 @@ class ChromeControllerTest extends WallabagCoreTestCase $this->assertNotEmpty($content->getPreviewPicture()); $this->assertNotEmpty($content->getLanguage()); $this->assertEquals(0, count($content->getTags())); + + $createdAt = $content->getCreatedAt(); + $this->assertEquals('2011', $createdAt->format('Y')); + $this->assertEquals('07', $createdAt->format('m')); } public function testImportWallabagWithEmptyFile() diff --git a/tests/Wallabag/ImportBundle/Controller/FirefoxControllerTest.php b/tests/Wallabag/ImportBundle/Controller/FirefoxControllerTest.php index 2de0aa09..10fbc225 100644 --- a/tests/Wallabag/ImportBundle/Controller/FirefoxControllerTest.php +++ b/tests/Wallabag/ImportBundle/Controller/FirefoxControllerTest.php @@ -133,6 +133,10 @@ class FirefoxControllerTest extends WallabagCoreTestCase $this->assertNotEmpty($content->getMimetype()); $this->assertNotEmpty($content->getPreviewPicture()); $this->assertEmpty($content->getLanguage()); + + $createdAt = $content->getCreatedAt(); + $this->assertEquals('2011', $createdAt->format('Y')); + $this->assertEquals('07', $createdAt->format('m')); } public function testImportWallabagWithEmptyFile() -- cgit v1.2.3 From 12d93e6896f2d99b6329b7979ee7b6d11e457c3a Mon Sep 17 00:00:00 2001 From: Jeremy Benoist Date: Sun, 25 Sep 2016 22:24:07 +0200 Subject: Update Firefox file With real data, the previous looks more than a Chrome converted file. Also, fix date conversion (hope so). --- .../Controller/FirefoxControllerTest.php | 4 +- .../ImportBundle/Import/FirefoxImportTest.php | 10 +- .../ImportBundle/fixtures/firefox-bookmarks.json | 119 +++++++++++---------- 3 files changed, 67 insertions(+), 66 deletions(-) (limited to 'tests/Wallabag/ImportBundle') diff --git a/tests/Wallabag/ImportBundle/Controller/FirefoxControllerTest.php b/tests/Wallabag/ImportBundle/Controller/FirefoxControllerTest.php index 10fbc225..dea5b79c 100644 --- a/tests/Wallabag/ImportBundle/Controller/FirefoxControllerTest.php +++ b/tests/Wallabag/ImportBundle/Controller/FirefoxControllerTest.php @@ -135,8 +135,8 @@ class FirefoxControllerTest extends WallabagCoreTestCase $this->assertEmpty($content->getLanguage()); $createdAt = $content->getCreatedAt(); - $this->assertEquals('2011', $createdAt->format('Y')); - $this->assertEquals('07', $createdAt->format('m')); + $this->assertEquals('2013', $createdAt->format('Y')); + $this->assertEquals('12', $createdAt->format('m')); } public function testImportWallabagWithEmptyFile() diff --git a/tests/Wallabag/ImportBundle/Import/FirefoxImportTest.php b/tests/Wallabag/ImportBundle/Import/FirefoxImportTest.php index e8f0f3c7..007dda6a 100644 --- a/tests/Wallabag/ImportBundle/Import/FirefoxImportTest.php +++ b/tests/Wallabag/ImportBundle/Import/FirefoxImportTest.php @@ -61,7 +61,7 @@ class FirefoxImportTest extends \PHPUnit_Framework_TestCase ->disableOriginalConstructor() ->getMock(); - $entryRepo->expects($this->exactly(4)) + $entryRepo->expects($this->exactly(2)) ->method('findByUrlAndUserId') ->willReturn(false); @@ -75,14 +75,14 @@ class FirefoxImportTest extends \PHPUnit_Framework_TestCase ->getMock(); $this->contentProxy - ->expects($this->exactly(4)) + ->expects($this->exactly(2)) ->method('updateEntry') ->willReturn($entry); $res = $firefoxImport->import(); $this->assertTrue($res); - $this->assertEquals(['skipped' => 0, 'imported' => 4, 'queued' => 0], $firefoxImport->getSummary()); + $this->assertEquals(['skipped' => 0, 'imported' => 2, 'queued' => 0], $firefoxImport->getSummary()); } public function testImportAndMarkAllAsRead() @@ -94,7 +94,7 @@ class FirefoxImportTest extends \PHPUnit_Framework_TestCase ->disableOriginalConstructor() ->getMock(); - $entryRepo->expects($this->exactly(4)) + $entryRepo->expects($this->exactly(2)) ->method('findByUrlAndUserId') ->will($this->onConsecutiveCalls(false, true)); @@ -120,7 +120,7 @@ class FirefoxImportTest extends \PHPUnit_Framework_TestCase $this->assertTrue($res); - $this->assertEquals(['skipped' => 3, 'imported' => 1, 'queued' => 0], $firefoxImport->getSummary()); + $this->assertEquals(['skipped' => 1, 'imported' => 1, 'queued' => 0], $firefoxImport->getSummary()); } public function testImportWithRabbit() diff --git a/tests/Wallabag/ImportBundle/fixtures/firefox-bookmarks.json b/tests/Wallabag/ImportBundle/fixtures/firefox-bookmarks.json index 8b78b8a4..ee06a16c 100644 --- a/tests/Wallabag/ImportBundle/fixtures/firefox-bookmarks.json +++ b/tests/Wallabag/ImportBundle/fixtures/firefox-bookmarks.json @@ -1,61 +1,62 @@ { - "checksum": "ef1e30cddf64cb94c63d7835640165be", - "roots": { - "bookmark_bar": { - "children": [ { - "date_added": "13112787540531997", - "id": "7", - "name": "Terrorisme: les sombres prédictions du directeur de la DGSI", - "type": "url", - "url": "http://www.lefigaro.fr/actualite-france/2016/07/12/01016-20160712ARTFIG00016-terrorisme-les-sombres-perspectives-de-patrick-calvar-directeur-de-la-dgsi.php" - } ], - "date_added": "13112787380480144", - "date_modified": "13112787542724942", - "id": "1", - "name": "Bookmarks bar", - "type": "folder" - }, - "other": { - "children": [ { - "date_added": "13112787503900822", - "id": "6", - "name": "Parser for Exported Bookmarks HTML file of Google Chrome and Mozilla in Java - Stack Overflow", - "type": "url", - "url": "http://stackoverflow.com/questions/15017163/parser-for-exported-bookmarks-html-file-of-google-chrome-and-mozilla-in-java" - }, { - "children": [ { - "date_added": "13112787564443378", - "id": "9", - "name": "Orange offre un meilleur réseau mobile que Bouygues et SFR, Free derrière - L'Express L'Expansion", - "type": "url", - "url": "http://lexpansion.lexpress.fr/high-tech/orange-offre-un-meilleur-reseau-mobile-que-bouygues-et-sfr-free-derriere_1811554.html" - } ], - "date_added": "13112787556763735", - "date_modified": "13112794390493325", - "id": "8", - "name": "test", - "type": "folder" - }, { - "date_added": "13112794390493325", - "id": "12", - "name": "JSON Formatter & Validator", - "type": "url", - "url": "https://jsonformatter.curiousconcept.com/" - } ], - "date_added": "13112787380480151", - "date_modified": "13112794393509988", - "id": "2", - "name": "Other bookmarks", - "type": "folder" - }, - "synced": { - "children": [ ], - "date_added": "13112787380480155", - "date_modified": "0", - "id": "3", - "name": "Mobile bookmarks", - "type": "folder" - } - }, - "version": 1 + "guid": "root________", + "title": "", + "index": 0, + "dateAdded": 1388166091504000, + "lastModified": 1472897622350000, + "id": 1, + "type": "text/x-moz-place-container", + "root": "placesRoot", + "children": [ + { + "guid": "toolbar_____", + "title": "Barre personnelle", + "index": 1, + "dateAdded": 1388166091504000, + "lastModified": 1472897622263000, + "id": 3, + "annos": [ + { + "name": "bookmarkProperties/description", + "flags": 0, + "expires": 4, + "value": "Ajoutez des marque-pages dans ce dossier pour les voir apparaître sur votre barre personnelle" + } + ], + "type": "text/x-moz-place-container", + "root": "toolbarFolder", + "children": [ + { + "guid": "tard77lzbC5H", + "title": "Orange offre un meilleur réseau mobile que Bouygues et SFR, Free derrière - L'Express L'Expansion", + "index": 1, + "dateAdded": 1388166091644000, + "lastModified": 1388166091644000, + "id": 4, + "type": "text/x-moz-place", + "uri": "http://lexpansion.lexpress.fr/high-tech/orange-offre-un-meilleur-reseau-mobile-que-bouygues-et-sfr-free-derriere_1811554.html" + }, + { + "guid": "E385l9vZ_LVn", + "title": "Parser for Exported Bookmarks HTML file of Google Chrome and Mozilla in Java", + "index": 1, + "dateAdded": 1388166091544000, + "lastModified": 1388166091545000, + "id": 5, + "type": "text/x-moz-place", + "uri": "http://stackoverflow.com/questions/15017163/parser-for-exported-bookmarks-html-file-of-google-chrome-and-mozilla-in-java" + } + ] + }, + { + "guid": "unfiled_____", + "title": "Autres marque-pages", + "index": 3, + "dateAdded": 1388166091504000, + "lastModified": 1388166091542000, + "id": 6, + "type": "text/x-moz-place-container", + "root": "unfiledBookmarksFolder" + } + ] } -- cgit v1.2.3 From fefef9d41b4d1bd9efbd49011159bae70bf67528 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicolas=20L=C5=93uillet?= Date: Mon, 26 Sep 2016 13:40:10 +0200 Subject: Added tags for Firefox import --- tests/Wallabag/ImportBundle/Controller/FirefoxControllerTest.php | 2 +- tests/Wallabag/ImportBundle/fixtures/firefox-bookmarks.json | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) (limited to 'tests/Wallabag/ImportBundle') diff --git a/tests/Wallabag/ImportBundle/Controller/FirefoxControllerTest.php b/tests/Wallabag/ImportBundle/Controller/FirefoxControllerTest.php index dea5b79c..98f13d72 100644 --- a/tests/Wallabag/ImportBundle/Controller/FirefoxControllerTest.php +++ b/tests/Wallabag/ImportBundle/Controller/FirefoxControllerTest.php @@ -120,7 +120,7 @@ class FirefoxControllerTest extends WallabagCoreTestCase $this->assertNotEmpty($content->getMimetype()); $this->assertNotEmpty($content->getPreviewPicture()); $this->assertNotEmpty($content->getLanguage()); - $this->assertEquals(0, count($content->getTags())); + $this->assertEquals(2, count($content->getTags())); $content = $client->getContainer() ->get('doctrine.orm.entity_manager') diff --git a/tests/Wallabag/ImportBundle/fixtures/firefox-bookmarks.json b/tests/Wallabag/ImportBundle/fixtures/firefox-bookmarks.json index ee06a16c..406b5697 100644 --- a/tests/Wallabag/ImportBundle/fixtures/firefox-bookmarks.json +++ b/tests/Wallabag/ImportBundle/fixtures/firefox-bookmarks.json @@ -32,6 +32,7 @@ "index": 1, "dateAdded": 1388166091644000, "lastModified": 1388166091644000, + "tags":"test,tag", "id": 4, "type": "text/x-moz-place", "uri": "http://lexpansion.lexpress.fr/high-tech/orange-offre-un-meilleur-reseau-mobile-que-bouygues-et-sfr-free-derriere_1811554.html" -- cgit v1.2.3