aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--src/Wallabag/CoreBundle/Entity/Entry.php19
-rw-r--r--src/Wallabag/ImportBundle/Import/PocketImport.php5
-rw-r--r--src/Wallabag/ImportBundle/Import/ReadabilityImport.php5
-rw-r--r--src/Wallabag/ImportBundle/Import/WallabagImport.php4
-rw-r--r--src/Wallabag/ImportBundle/Import/WallabagV1Import.php1
-rw-r--r--tests/Wallabag/ImportBundle/Controller/ReadabilityControllerTest.php7
-rw-r--r--tests/Wallabag/ImportBundle/Controller/WallabagV1ControllerTest.php6
-rw-r--r--tests/Wallabag/ImportBundle/Controller/WallabagV2ControllerTest.php2
8 files changed, 47 insertions, 2 deletions
diff --git a/src/Wallabag/CoreBundle/Entity/Entry.php b/src/Wallabag/CoreBundle/Entity/Entry.php
index c3e6b4d5..304258a9 100644
--- a/src/Wallabag/CoreBundle/Entity/Entry.php
+++ b/src/Wallabag/CoreBundle/Entity/Entry.php
@@ -410,7 +410,22 @@ class Entry
410 } 410 }
411 411
412 /** 412 /**
413 * @return string 413 * Set created_at.
414 * Only used when importing data from an other service.
415 *
416 * @param DateTime $createdAt
417 *
418 * @return Entry
419 */
420 public function setCreatedAt(\DateTime $createdAt)
421 {
422 $this->createdAt = $createdAt;
423
424 return $this;
425 }
426
427 /**
428 * @return DateTime
414 */ 429 */
415 public function getCreatedAt() 430 public function getCreatedAt()
416 { 431 {
@@ -418,7 +433,7 @@ class Entry
418 } 433 }
419 434
420 /** 435 /**
421 * @return string 436 * @return DateTime
422 */ 437 */
423 public function getUpdatedAt() 438 public function getUpdatedAt()
424 { 439 {
diff --git a/src/Wallabag/ImportBundle/Import/PocketImport.php b/src/Wallabag/ImportBundle/Import/PocketImport.php
index 845380b7..92dcdd40 100644
--- a/src/Wallabag/ImportBundle/Import/PocketImport.php
+++ b/src/Wallabag/ImportBundle/Import/PocketImport.php
@@ -193,6 +193,11 @@ class PocketImport extends AbstractImport
193 $this->client = $client; 193 $this->client = $client;
194 } 194 }
195 195
196 /**
197 * {@inheritdoc}
198 *
199 * @see https://getpocket.com/developer/docs/v3/retrieve
200 */
196 public function parseEntry(array $importedEntry) 201 public function parseEntry(array $importedEntry)
197 { 202 {
198 $url = isset($importedEntry['resolved_url']) && $importedEntry['resolved_url'] != '' ? $importedEntry['resolved_url'] : $importedEntry['given_url']; 203 $url = isset($importedEntry['resolved_url']) && $importedEntry['resolved_url'] != '' ? $importedEntry['resolved_url'] : $importedEntry['given_url'];
diff --git a/src/Wallabag/ImportBundle/Import/ReadabilityImport.php b/src/Wallabag/ImportBundle/Import/ReadabilityImport.php
index 915d4cd3..8f080d38 100644
--- a/src/Wallabag/ImportBundle/Import/ReadabilityImport.php
+++ b/src/Wallabag/ImportBundle/Import/ReadabilityImport.php
@@ -89,6 +89,9 @@ class ReadabilityImport extends AbstractImport
89 return true; 89 return true;
90 } 90 }
91 91
92 /**
93 * {@inheritdoc}
94 */
92 public function parseEntry(array $importedEntry) 95 public function parseEntry(array $importedEntry)
93 { 96 {
94 $existingEntry = $this->em 97 $existingEntry = $this->em
@@ -108,6 +111,7 @@ class ReadabilityImport extends AbstractImport
108 'language' => '', 111 'language' => '',
109 'is_archived' => $importedEntry['archive'] || $this->markAsRead, 112 'is_archived' => $importedEntry['archive'] || $this->markAsRead,
110 'is_starred' => $importedEntry['favorite'], 113 'is_starred' => $importedEntry['favorite'],
114 'created_at' => $importedEntry['date_added'],
111 ]; 115 ];
112 116
113 $entry = $this->fetchContent( 117 $entry = $this->fetchContent(
@@ -125,6 +129,7 @@ class ReadabilityImport extends AbstractImport
125 129
126 $entry->setArchived($data['is_archived']); 130 $entry->setArchived($data['is_archived']);
127 $entry->setStarred($data['is_starred']); 131 $entry->setStarred($data['is_starred']);
132 $entry->setCreatedAt(new \DateTime($data['created_at']));
128 133
129 $this->em->persist($entry); 134 $this->em->persist($entry);
130 ++$this->importedEntries; 135 ++$this->importedEntries;
diff --git a/src/Wallabag/ImportBundle/Import/WallabagImport.php b/src/Wallabag/ImportBundle/Import/WallabagImport.php
index 026567b0..8e50b135 100644
--- a/src/Wallabag/ImportBundle/Import/WallabagImport.php
+++ b/src/Wallabag/ImportBundle/Import/WallabagImport.php
@@ -139,6 +139,10 @@ abstract class WallabagImport extends AbstractImport
139 $entry->setArchived($data['is_archived']); 139 $entry->setArchived($data['is_archived']);
140 $entry->setStarred($data['is_starred']); 140 $entry->setStarred($data['is_starred']);
141 141
142 if (!empty($data['created_at'])) {
143 $entry->setCreatedAt(new \DateTime($data['created_at']));
144 }
145
142 $this->em->persist($entry); 146 $this->em->persist($entry);
143 ++$this->importedEntries; 147 ++$this->importedEntries;
144 148
diff --git a/src/Wallabag/ImportBundle/Import/WallabagV1Import.php b/src/Wallabag/ImportBundle/Import/WallabagV1Import.php
index 292b72a7..4f001062 100644
--- a/src/Wallabag/ImportBundle/Import/WallabagV1Import.php
+++ b/src/Wallabag/ImportBundle/Import/WallabagV1Import.php
@@ -42,6 +42,7 @@ class WallabagV1Import extends WallabagImport
42 'is_archived' => $entry['is_read'] || $this->markAsRead, 42 'is_archived' => $entry['is_read'] || $this->markAsRead,
43 'is_starred' => $entry['is_fav'], 43 'is_starred' => $entry['is_fav'],
44 'tags' => '', 44 'tags' => '',
45 'created_at' => '',
45 ]; 46 ];
46 47
47 // force content to be refreshed in case on bad fetch in the v1 installation 48 // force content to be refreshed in case on bad fetch in the v1 installation
diff --git a/tests/Wallabag/ImportBundle/Controller/ReadabilityControllerTest.php b/tests/Wallabag/ImportBundle/Controller/ReadabilityControllerTest.php
index 92cf4bfc..fb39356a 100644
--- a/tests/Wallabag/ImportBundle/Controller/ReadabilityControllerTest.php
+++ b/tests/Wallabag/ImportBundle/Controller/ReadabilityControllerTest.php
@@ -49,6 +49,13 @@ class ReadabilityControllerTest extends WallabagCoreTestCase
49 49
50 $this->assertGreaterThan(1, $body = $crawler->filter('body')->extract(['_text'])); 50 $this->assertGreaterThan(1, $body = $crawler->filter('body')->extract(['_text']));
51 $this->assertContains('flashes.import.notice.summary', $body[0]); 51 $this->assertContains('flashes.import.notice.summary', $body[0]);
52
53 $this->assertNotEmpty($content->getMimetype());
54 $this->assertNotEmpty($content->getPreviewPicture());
55 $this->assertNotEmpty($content->getLanguage());
56 $this->assertEquals(0, count($content->getTags()));
57 $this->assertInstanceOf(\DateTime::class, $content->getCreatedAt());
58 $this->assertEquals('2016-08-25', $content->getCreatedAt()->format('Y-m-d'));
52 } 59 }
53 60
54 public function testImportReadabilityWithFileAndMarkAllAsRead() 61 public function testImportReadabilityWithFileAndMarkAllAsRead()
diff --git a/tests/Wallabag/ImportBundle/Controller/WallabagV1ControllerTest.php b/tests/Wallabag/ImportBundle/Controller/WallabagV1ControllerTest.php
index c1025b41..ff1bf6f0 100644
--- a/tests/Wallabag/ImportBundle/Controller/WallabagV1ControllerTest.php
+++ b/tests/Wallabag/ImportBundle/Controller/WallabagV1ControllerTest.php
@@ -56,6 +56,12 @@ class WallabagV1ControllerTest extends WallabagCoreTestCase
56 56
57 $this->assertGreaterThan(1, $body = $crawler->filter('body')->extract(['_text'])); 57 $this->assertGreaterThan(1, $body = $crawler->filter('body')->extract(['_text']));
58 $this->assertContains('flashes.import.notice.summary', $body[0]); 58 $this->assertContains('flashes.import.notice.summary', $body[0]);
59
60 $this->assertEmpty($content->getMimetype());
61 $this->assertEmpty($content->getPreviewPicture());
62 $this->assertEmpty($content->getLanguage());
63 $this->assertEquals(1, count($content->getTags()));
64 $this->assertInstanceOf(\DateTime::class, $content->getCreatedAt());
59 } 65 }
60 66
61 public function testImportWallabagWithFileAndMarkAllAsRead() 67 public function testImportWallabagWithFileAndMarkAllAsRead()
diff --git a/tests/Wallabag/ImportBundle/Controller/WallabagV2ControllerTest.php b/tests/Wallabag/ImportBundle/Controller/WallabagV2ControllerTest.php
index d8d2c8bf..149e88bb 100644
--- a/tests/Wallabag/ImportBundle/Controller/WallabagV2ControllerTest.php
+++ b/tests/Wallabag/ImportBundle/Controller/WallabagV2ControllerTest.php
@@ -67,6 +67,8 @@ class WallabagV2ControllerTest extends WallabagCoreTestCase
67 $this->assertNotEmpty($content->getPreviewPicture()); 67 $this->assertNotEmpty($content->getPreviewPicture());
68 $this->assertNotEmpty($content->getLanguage()); 68 $this->assertNotEmpty($content->getLanguage());
69 $this->assertEquals(2, count($content->getTags())); 69 $this->assertEquals(2, count($content->getTags()));
70 $this->assertInstanceOf(\DateTime::class, $content->getCreatedAt());
71 $this->assertEquals('2016-09-08', $content->getCreatedAt()->format('Y-m-d'));
70 } 72 }
71 73
72 public function testImportWallabagWithEmptyFile() 74 public function testImportWallabagWithEmptyFile()