aboutsummaryrefslogtreecommitdiffhomepage
path: root/tests/Wallabag/ImportBundle
diff options
context:
space:
mode:
Diffstat (limited to 'tests/Wallabag/ImportBundle')
-rw-r--r--tests/Wallabag/ImportBundle/Command/ImportCommandTest.php1
-rw-r--r--tests/Wallabag/ImportBundle/Controller/BrowserControllerTest.php41
-rw-r--r--tests/Wallabag/ImportBundle/fixtures/chrome-bookmarks36
-rw-r--r--tests/Wallabag/ImportBundle/fixtures/firefox-bookmarks.json (renamed from tests/Wallabag/ImportBundle/fixtures/bookmarks.json)0
4 files changed, 75 insertions, 3 deletions
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;
6use Symfony\Component\Console\Tester\CommandTester; 6use Symfony\Component\Console\Tester\CommandTester;
7use Wallabag\ImportBundle\Command\ImportCommand; 7use Wallabag\ImportBundle\Command\ImportCommand;
8use Tests\Wallabag\CoreBundle\WallabagCoreTestCase; 8use Tests\Wallabag\CoreBundle\WallabagCoreTestCase;
9use M6Web\Component\RedisMock\RedisMockFactory;
10 9
11class ImportCommandTest extends WallabagCoreTestCase 10class ImportCommandTest extends WallabagCoreTestCase
12{ 11{
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
19 $this->assertEquals(1, $crawler->filter('input[type=file]')->count()); 19 $this->assertEquals(1, $crawler->filter('input[type=file]')->count());
20 } 20 }
21 21
22 public function testImportWallabagWithFile() 22 public function testImportWallabagWithFirefoxFile()
23 { 23 {
24 $this->logInAs('admin'); 24 $this->logInAs('admin');
25 $client = $this->getClient(); 25 $client = $this->getClient();
@@ -27,7 +27,7 @@ class BrowserControllerTest extends WallabagCoreTestCase
27 $crawler = $client->request('GET', '/import/browser'); 27 $crawler = $client->request('GET', '/import/browser');
28 $form = $crawler->filter('form[name=upload_import_file] > button[type=submit]')->form(); 28 $form = $crawler->filter('form[name=upload_import_file] > button[type=submit]')->form();
29 29
30 $file = new UploadedFile(__DIR__.'/../fixtures/bookmarks.json', 'Bookmarks'); 30 $file = new UploadedFile(__DIR__.'/../fixtures/firefox-bookmarks.json', 'Bookmarks');
31 31
32 $data = [ 32 $data = [
33 'upload_import_file[file]' => $file, 33 'upload_import_file[file]' => $file,
@@ -68,6 +68,43 @@ class BrowserControllerTest extends WallabagCoreTestCase
68 $this->assertEmpty($content->getLanguage()); 68 $this->assertEmpty($content->getLanguage());
69 } 69 }
70 70
71 public function testImportWallabagWithChromeFile()
72 {
73 $this->logInAs('admin');
74 $client = $this->getClient();
75
76 $crawler = $client->request('GET', '/import/browser');
77 $form = $crawler->filter('form[name=upload_import_file] > button[type=submit]')->form();
78
79 $file = new UploadedFile(__DIR__.'/../fixtures/chrome-bookmarks', 'Bookmarks');
80
81 $data = [
82 'upload_import_file[file]' => $file,
83 ];
84
85 $client->submit($form, $data);
86
87 $this->assertEquals(302, $client->getResponse()->getStatusCode());
88
89 $crawler = $client->followRedirect();
90
91 $this->assertGreaterThan(1, $body = $crawler->filter('body')->extract(['_text']));
92 $this->assertContains('flashes.import.notice.summary', $body[0]);
93
94 $content = $client->getContainer()
95 ->get('doctrine.orm.entity_manager')
96 ->getRepository('WallabagCoreBundle:Entry')
97 ->findByUrlAndUserId(
98 'http://www.usinenouvelle.com/article/la-multiplication-des-chefs-de-projet-est-une-catastrophe-manageriale-majeure-affirme-le-sociologue-francois-dupuy.N307730',
99 $this->getLoggedInUserId()
100 );
101
102 $this->assertNotEmpty($content->getMimetype());
103 $this->assertNotEmpty($content->getPreviewPicture());
104 $this->assertNotEmpty($content->getLanguage());
105 $this->assertEquals(0, count($content->getTags()));
106 }
107
71 public function testImportWallabagWithEmptyFile() 108 public function testImportWallabagWithEmptyFile()
72 { 109 {
73 $this->logInAs('admin'); 110 $this->logInAs('admin');
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 @@
1{
2 "checksum": "f3aa0e9c0edad632a246f7e98ec64918",
3 "roots": {
4 "bookmark_bar": {
5 "children": [ {
6 "date_added": "13118850929335823",
7 "id": "6",
8 "name": "\"La multiplication des chefs de projet est une catastrophe managériale majeure\", affirme le sociologue François Dupuy - Ressources humaines",
9 "type": "url",
10 "url": "http://www.usinenouvelle.com/article/la-multiplication-des-chefs-de-projet-est-une-catastrophe-manageriale-majeure-affirme-le-sociologue-francois-dupuy.N307730"
11 } ],
12 "date_added": "13118829474385693",
13 "date_modified": "13118850929335823",
14 "id": "1",
15 "name": "Barre de favoris",
16 "type": "folder"
17 },
18 "other": {
19 "children": [ ],
20 "date_added": "13118829474385701",
21 "date_modified": "0",
22 "id": "2",
23 "name": "Autres favoris",
24 "type": "folder"
25 },
26 "synced": {
27 "children": [ ],
28 "date_added": "13118829474385702",
29 "date_modified": "0",
30 "id": "3",
31 "name": "Favoris sur mobile",
32 "type": "folder"
33 }
34 },
35 "version": 1
36}
diff --git a/tests/Wallabag/ImportBundle/fixtures/bookmarks.json b/tests/Wallabag/ImportBundle/fixtures/firefox-bookmarks.json
index 8b78b8a4..8b78b8a4 100644
--- a/tests/Wallabag/ImportBundle/fixtures/bookmarks.json
+++ b/tests/Wallabag/ImportBundle/fixtures/firefox-bookmarks.json