Merge pull request #2275 from wallabag/export-dates

Export dates from entries
This commit is contained in:
Nicolas Lœuillet 2016-09-08 18:33:09 +02:00 committed by GitHub
commit c078d18372
5 changed files with 61 additions and 4 deletions

View File

@ -101,7 +101,7 @@ class Entry
* *
* @ORM\Column(name="created_at", type="datetime") * @ORM\Column(name="created_at", type="datetime")
* *
* @Groups({"export_all"}) * @Groups({"entries_for_user", "export_all"})
*/ */
private $createdAt; private $createdAt;
@ -110,7 +110,7 @@ class Entry
* *
* @ORM\Column(name="updated_at", type="datetime") * @ORM\Column(name="updated_at", type="datetime")
* *
* @Groups({"export_all"}) * @Groups({"entries_for_user", "export_all"})
*/ */
private $updatedAt; private $updatedAt;

View File

@ -298,7 +298,7 @@ class EntriesExport
$enclosure = '"'; $enclosure = '"';
$handle = fopen('php://memory', 'rb+'); $handle = fopen('php://memory', 'rb+');
fputcsv($handle, ['Title', 'URL', 'Content', 'Tags', 'MIME Type', 'Language'], $delimiter, $enclosure); fputcsv($handle, ['Title', 'URL', 'Content', 'Tags', 'MIME Type', 'Language', 'Creation date'], $delimiter, $enclosure);
foreach ($this->entries as $entry) { foreach ($this->entries as $entry) {
fputcsv( fputcsv(
@ -311,6 +311,7 @@ class EntriesExport
implode(', ', $entry->getTags()->toArray()), implode(', ', $entry->getTags()->toArray()),
$entry->getMimetype(), $entry->getMimetype(),
$entry->getLanguage(), $entry->getLanguage(),
$entry->getCreatedAt()->format('d/m/Y h:i:s'),
], ],
$delimiter, $delimiter,
$enclosure $enclosure

View File

@ -168,7 +168,7 @@ class ExportControllerTest extends WallabagCoreTestCase
$this->assertGreaterThan(1, $csv); $this->assertGreaterThan(1, $csv);
// +1 for title line // +1 for title line
$this->assertEquals(count($contentInDB) + 1, count($csv)); $this->assertEquals(count($contentInDB) + 1, count($csv));
$this->assertEquals('Title;URL;Content;Tags;"MIME Type";Language', $csv[0]); $this->assertEquals('Title;URL;Content;Tags;"MIME Type";Language;"Creation date"', $csv[0]);
} }
public function testJsonExport() public function testJsonExport()
@ -210,6 +210,8 @@ class ExportControllerTest extends WallabagCoreTestCase
$this->assertArrayHasKey('reading_time', $content[0]); $this->assertArrayHasKey('reading_time', $content[0]);
$this->assertArrayHasKey('domain_name', $content[0]); $this->assertArrayHasKey('domain_name', $content[0]);
$this->assertArrayHasKey('tags', $content[0]); $this->assertArrayHasKey('tags', $content[0]);
$this->assertArrayHasKey('created_at', $content[0]);
$this->assertArrayHasKey('updated_at', $content[0]);
} }
public function testXmlExport() public function testXmlExport()
@ -247,5 +249,7 @@ class ExportControllerTest extends WallabagCoreTestCase
$this->assertNotEmpty('url', (string) $content->entry[0]->url); $this->assertNotEmpty('url', (string) $content->entry[0]->url);
$this->assertNotEmpty('content', (string) $content->entry[0]->content); $this->assertNotEmpty('content', (string) $content->entry[0]->content);
$this->assertNotEmpty('domain_name', (string) $content->entry[0]->domain_name); $this->assertNotEmpty('domain_name', (string) $content->entry[0]->domain_name);
$this->assertNotEmpty('created_at', (string) $content->entry[0]->created_at);
$this->assertNotEmpty('updated_at', (string) $content->entry[0]->updated_at);
} }
} }

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long