aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--src/Wallabag/ImportBundle/Import/BrowserImport.php23
-rw-r--r--src/Wallabag/ImportBundle/Import/ChromeImport.php31
-rw-r--r--src/Wallabag/ImportBundle/Import/FirefoxImport.php31
-rw-r--r--tests/Wallabag/ImportBundle/Controller/ChromeControllerTest.php4
-rw-r--r--tests/Wallabag/ImportBundle/Controller/FirefoxControllerTest.php4
5 files changed, 31 insertions, 62 deletions
diff --git a/src/Wallabag/ImportBundle/Import/BrowserImport.php b/src/Wallabag/ImportBundle/Import/BrowserImport.php
index 44315e8b..da69df9b 100644
--- a/src/Wallabag/ImportBundle/Import/BrowserImport.php
+++ b/src/Wallabag/ImportBundle/Import/BrowserImport.php
@@ -196,6 +196,29 @@ abstract class BrowserImport extends AbstractImport
196 /** 196 /**
197 * {@inheritdoc} 197 * {@inheritdoc}
198 */ 198 */
199 protected function prepareEntry($entry = [])
200 {
201 $data = [
202 'title' => $entry['name'],
203 'html' => '',
204 'url' => $entry['url'],
205 'is_archived' => $this->markAsRead,
206 'tags' => '',
207 // date are in format like "13118829474385693"
208 // and it'll be devided by 1000 in AbstractImport
209 'created_at' => (int) ceil($entry['date_added'] / 10000),
210 ];
211
212 if (array_key_exists('tags', $entry) && $entry['tags'] != '') {
213 $data['tags'] = $entry['tags'];
214 }
215
216 return $data;
217 }
218
219 /**
220 * {@inheritdoc}
221 */
199 protected function setEntryAsRead(array $importedEntry) 222 protected function setEntryAsRead(array $importedEntry)
200 { 223 {
201 $importedEntry['is_archived'] = 1; 224 $importedEntry['is_archived'] = 1;
diff --git a/src/Wallabag/ImportBundle/Import/ChromeImport.php b/src/Wallabag/ImportBundle/Import/ChromeImport.php
index 1af7cc87..60602a1b 100644
--- a/src/Wallabag/ImportBundle/Import/ChromeImport.php
+++ b/src/Wallabag/ImportBundle/Import/ChromeImport.php
@@ -29,35 +29,4 @@ class ChromeImport extends BrowserImport
29 { 29 {
30 return 'import.chrome.description'; 30 return 'import.chrome.description';
31 } 31 }
32
33 /**
34 * {@inheritdoc}
35 */
36 protected function prepareEntry($entry = [])
37 {
38 $data = [
39 'title' => $entry['name'],
40 'html' => '',
41 'url' => $entry['url'],
42 'is_archived' => $this->markAsRead,
43 'tags' => '',
44 'created_at' => $entry['date_added'],
45 ];
46
47 if (array_key_exists('tags', $entry) && $entry['tags'] != '') {
48 $data['tags'] = $entry['tags'];
49 }
50
51 return $data;
52 }
53
54 /**
55 * {@inheritdoc}
56 */
57 protected function setEntryAsRead(array $importedEntry)
58 {
59 $importedEntry['is_archived'] = 1;
60
61 return $importedEntry;
62 }
63} 32}
diff --git a/src/Wallabag/ImportBundle/Import/FirefoxImport.php b/src/Wallabag/ImportBundle/Import/FirefoxImport.php
index 351cbef1..1a0b1154 100644
--- a/src/Wallabag/ImportBundle/Import/FirefoxImport.php
+++ b/src/Wallabag/ImportBundle/Import/FirefoxImport.php
@@ -29,35 +29,4 @@ class FirefoxImport extends BrowserImport
29 { 29 {
30 return 'import.firefox.description'; 30 return 'import.firefox.description';
31 } 31 }
32
33 /**
34 * {@inheritdoc}
35 */
36 protected function prepareEntry($entry = [])
37 {
38 $data = [
39 'title' => $entry['name'],
40 'html' => '',
41 'url' => $entry['url'],
42 'is_archived' => $this->markAsRead,
43 'tags' => '',
44 'created_at' => $entry['date_added'],
45 ];
46
47 if (array_key_exists('tags', $entry) && $entry['tags'] != '') {
48 $data['tags'] = $entry['tags'];
49 }
50
51 return $data;
52 }
53
54 /**
55 * {@inheritdoc}
56 */
57 protected function setEntryAsRead(array $importedEntry)
58 {
59 $importedEntry['is_archived'] = 1;
60
61 return $importedEntry;
62 }
63} 32}
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
120 $this->assertNotEmpty($content->getPreviewPicture()); 120 $this->assertNotEmpty($content->getPreviewPicture());
121 $this->assertNotEmpty($content->getLanguage()); 121 $this->assertNotEmpty($content->getLanguage());
122 $this->assertEquals(0, count($content->getTags())); 122 $this->assertEquals(0, count($content->getTags()));
123
124 $createdAt = $content->getCreatedAt();
125 $this->assertEquals('2011', $createdAt->format('Y'));
126 $this->assertEquals('07', $createdAt->format('m'));
123 } 127 }
124 128
125 public function testImportWallabagWithEmptyFile() 129 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
133 $this->assertNotEmpty($content->getMimetype()); 133 $this->assertNotEmpty($content->getMimetype());
134 $this->assertNotEmpty($content->getPreviewPicture()); 134 $this->assertNotEmpty($content->getPreviewPicture());
135 $this->assertEmpty($content->getLanguage()); 135 $this->assertEmpty($content->getLanguage());
136
137 $createdAt = $content->getCreatedAt();
138 $this->assertEquals('2011', $createdAt->format('Y'));
139 $this->assertEquals('07', $createdAt->format('m'));
136 } 140 }
137 141
138 public function testImportWallabagWithEmptyFile() 142 public function testImportWallabagWithEmptyFile()