Fix bad date format in Browser import

This commit is contained in:
Jeremy Benoist 2016-09-25 15:29:40 +02:00
parent f0fd82d039
commit 27acc6ddb8
No known key found for this signature in database
GPG key ID: BCA73962457ACC3C
5 changed files with 31 additions and 62 deletions

View file

@ -193,6 +193,29 @@ abstract class BrowserImport extends AbstractImport
return $entry;
}
/**
* {@inheritdoc}
*/
protected function prepareEntry($entry = [])
{
$data = [
'title' => $entry['name'],
'html' => '',
'url' => $entry['url'],
'is_archived' => $this->markAsRead,
'tags' => '',
// date are in format like "13118829474385693"
// and it'll be devided by 1000 in AbstractImport
'created_at' => (int) ceil($entry['date_added'] / 10000),
];
if (array_key_exists('tags', $entry) && $entry['tags'] != '') {
$data['tags'] = $entry['tags'];
}
return $data;
}
/**
* {@inheritdoc}
*/

View file

@ -29,35 +29,4 @@ class ChromeImport extends BrowserImport
{
return 'import.chrome.description';
}
/**
* {@inheritdoc}
*/
protected function prepareEntry($entry = [])
{
$data = [
'title' => $entry['name'],
'html' => '',
'url' => $entry['url'],
'is_archived' => $this->markAsRead,
'tags' => '',
'created_at' => $entry['date_added'],
];
if (array_key_exists('tags', $entry) && $entry['tags'] != '') {
$data['tags'] = $entry['tags'];
}
return $data;
}
/**
* {@inheritdoc}
*/
protected function setEntryAsRead(array $importedEntry)
{
$importedEntry['is_archived'] = 1;
return $importedEntry;
}
}

View file

@ -29,35 +29,4 @@ class FirefoxImport extends BrowserImport
{
return 'import.firefox.description';
}
/**
* {@inheritdoc}
*/
protected function prepareEntry($entry = [])
{
$data = [
'title' => $entry['name'],
'html' => '',
'url' => $entry['url'],
'is_archived' => $this->markAsRead,
'tags' => '',
'created_at' => $entry['date_added'],
];
if (array_key_exists('tags', $entry) && $entry['tags'] != '') {
$data['tags'] = $entry['tags'];
}
return $data;
}
/**
* {@inheritdoc}
*/
protected function setEntryAsRead(array $importedEntry)
{
$importedEntry['is_archived'] = 1;
return $importedEntry;
}
}

View file

@ -120,6 +120,10 @@ class ChromeControllerTest extends WallabagCoreTestCase
$this->assertNotEmpty($content->getPreviewPicture());
$this->assertNotEmpty($content->getLanguage());
$this->assertEquals(0, count($content->getTags()));
$createdAt = $content->getCreatedAt();
$this->assertEquals('2011', $createdAt->format('Y'));
$this->assertEquals('07', $createdAt->format('m'));
}
public function testImportWallabagWithEmptyFile()

View file

@ -133,6 +133,10 @@ class FirefoxControllerTest extends WallabagCoreTestCase
$this->assertNotEmpty($content->getMimetype());
$this->assertNotEmpty($content->getPreviewPicture());
$this->assertEmpty($content->getLanguage());
$createdAt = $content->getCreatedAt();
$this->assertEquals('2011', $createdAt->format('Y'));
$this->assertEquals('07', $createdAt->format('m'));
}
public function testImportWallabagWithEmptyFile()