diff options
Diffstat (limited to 'tests/Wallabag/ImportBundle/Controller')
-rw-r--r-- | tests/Wallabag/ImportBundle/Controller/BrowserControllerTest.php | 41 |
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'); |