aboutsummaryrefslogtreecommitdiffhomepage
path: root/tests/Wallabag/ImportBundle/Controller
diff options
context:
space:
mode:
authorNicolas LÅ“uillet <nicolas@loeuillet.org>2016-09-20 16:45:13 +0200
committerJeremy Benoist <jeremy.benoist@gmail.com>2016-09-25 12:29:18 +0200
commitf7c55b38122cc593c2b58bb6425fca9d243b055e (patch)
tree9ea81735f65258ee7d53a4727183915ceaa3383e /tests/Wallabag/ImportBundle/Controller
parent06d13ddfbc6dad568bb28d5c33daab9e54dc6669 (diff)
downloadwallabag-f7c55b38122cc593c2b58bb6425fca9d243b055e.tar.gz
wallabag-f7c55b38122cc593c2b58bb6425fca9d243b055e.tar.zst
wallabag-f7c55b38122cc593c2b58bb6425fca9d243b055e.zip
Added tests for Chrome bookmarks import
Diffstat (limited to 'tests/Wallabag/ImportBundle/Controller')
-rw-r--r--tests/Wallabag/ImportBundle/Controller/BrowserControllerTest.php41
1 files changed, 39 insertions, 2 deletions
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');