require_once 'application/NetscapeBookmarkUtils.php';
+use Shaarli\Config\ConfigManager;
/**
* Utility function to load a file's metadata in a $_FILES-like array
*/
protected $pagecache = 'tests';
+ /**
+ * @var ConfigManager instance.
+ */
+ protected $conf;
+
/**
* @var string Save the current timezone.
*/
// start with an empty datastore
file_put_contents(self::$testDatastore, '<?php /* S7QysKquBQA= */ ?>');
$this->linkDb = new LinkDB(self::$testDatastore, true, false);
+ $this->conf = new ConfigManager('tests/utils/config/configJson');
+ $this->conf->set('resource.page_cache', $this->pagecache);
}
public static function tearDownAfterClass()
$this->assertEquals(
'File empty.htm (0 bytes) has an unknown file format.'
.' Nothing was imported.',
- NetscapeBookmarkUtils::import(NULL, $files, NULL, NULL)
+ NetscapeBookmarkUtils::import(NULL, $files, NULL, $this->conf)
);
$this->assertEquals(0, count($this->linkDb));
}
$files = file2array('no_doctype.htm');
$this->assertEquals(
'File no_doctype.htm (350 bytes) has an unknown file format. Nothing was imported.',
- NetscapeBookmarkUtils::import(NULL, $files, NULL, NULL)
+ NetscapeBookmarkUtils::import(NULL, $files, NULL, $this->conf)
);
$this->assertEquals(0, count($this->linkDb));
}
$this->assertEquals(
'File internet_explorer_encoding.htm (356 bytes) was successfully processed:'
.' 1 links imported, 0 links overwritten, 0 links skipped.',
- NetscapeBookmarkUtils::import(array(), $files, $this->linkDb, $this->pagecache)
+ NetscapeBookmarkUtils::import(array(), $files, $this->linkDb, $this->conf)
);
$this->assertEquals(1, count($this->linkDb));
$this->assertEquals(0, count_private($this->linkDb));
$this->assertEquals(
array(
'id' => 0,
- 'created' => DateTime::createFromFormat('Ymd_His', '20160618_203944'),
+ 'created' => DateTime::createFromFormat(LinkDB::LINK_DATE_FORMAT, '20160618_203944'),
'title' => 'Hg Init a Mercurial tutorial by Joel Spolsky',
'url' => 'http://hginit.com/',
'description' => '',
$this->assertEquals(
'File netscape_nested.htm (1337 bytes) was successfully processed:'
.' 8 links imported, 0 links overwritten, 0 links skipped.',
- NetscapeBookmarkUtils::import(array(), $files, $this->linkDb, $this->pagecache)
+ NetscapeBookmarkUtils::import(array(), $files, $this->linkDb, $this->conf)
);
$this->assertEquals(8, count($this->linkDb));
$this->assertEquals(2, count_private($this->linkDb));
$this->assertEquals(
array(
'id' => 0,
- 'created' => DateTime::createFromFormat('Ymd_His', '20160225_235541'),
+ 'created' => DateTime::createFromFormat(LinkDB::LINK_DATE_FORMAT, '20160225_235541'),
'title' => 'Nested 1',
'url' => 'http://nest.ed/1',
'description' => '',
$this->assertEquals(
array(
'id' => 1,
- 'created' => DateTime::createFromFormat('Ymd_His', '20160225_235542'),
+ 'created' => DateTime::createFromFormat(LinkDB::LINK_DATE_FORMAT, '20160225_235542'),
'title' => 'Nested 1-1',
'url' => 'http://nest.ed/1-1',
'description' => '',
$this->assertEquals(
array(
'id' => 2,
- 'created' => DateTime::createFromFormat('Ymd_His', '20160225_235547'),
+ 'created' => DateTime::createFromFormat(LinkDB::LINK_DATE_FORMAT, '20160225_235547'),
'title' => 'Nested 1-2',
'url' => 'http://nest.ed/1-2',
'description' => '',
$this->assertEquals(
array(
'id' => 3,
- 'created' => DateTime::createFromFormat('Ymd_His', '20160202_202222'),
+ 'created' => DateTime::createFromFormat(LinkDB::LINK_DATE_FORMAT, '20160202_202222'),
'title' => 'Nested 2-1',
'url' => 'http://nest.ed/2-1',
'description' => 'First link of the second section',
$this->assertEquals(
array(
'id' => 4,
- 'created' => DateTime::createFromFormat('Ymd_His', '20160119_230227'),
+ 'created' => DateTime::createFromFormat(LinkDB::LINK_DATE_FORMAT, '20160119_230227'),
'title' => 'Nested 2-2',
'url' => 'http://nest.ed/2-2',
'description' => 'Second link of the second section',
$this->assertEquals(
array(
'id' => 5,
- 'created' => DateTime::createFromFormat('Ymd_His', '20160202_202222'),
+ 'created' => DateTime::createFromFormat(LinkDB::LINK_DATE_FORMAT, '20160202_202222'),
'title' => 'Nested 3-1',
'url' => 'http://nest.ed/3-1',
'description' => '',
$this->assertEquals(
array(
'id' => 6,
- 'created' => DateTime::createFromFormat('Ymd_His', '20160119_230227'),
+ 'created' => DateTime::createFromFormat(LinkDB::LINK_DATE_FORMAT, '20160119_230227'),
'title' => 'Nested 3-2',
'url' => 'http://nest.ed/3-2',
'description' => '',
$this->assertEquals(
array(
'id' => 7,
- 'created' => DateTime::createFromFormat('Ymd_His', '20160229_111541'),
+ 'created' => DateTime::createFromFormat(LinkDB::LINK_DATE_FORMAT, '20160229_111541'),
'title' => 'Nested 2',
'url' => 'http://nest.ed/2',
'description' => '',
$this->assertEquals(
'File netscape_basic.htm (482 bytes) was successfully processed:'
.' 2 links imported, 0 links overwritten, 0 links skipped.',
- NetscapeBookmarkUtils::import(array(), $files, $this->linkDb, $this->pagecache)
+ NetscapeBookmarkUtils::import(array(), $files, $this->linkDb, $this->conf)
);
$this->assertEquals(2, count($this->linkDb));
array(
'id' => 0,
// Old link - UTC+4 (note that TZ in the import file is ignored).
- 'created' => DateTime::createFromFormat('Ymd_His', '20001010_135536'),
+ 'created' => DateTime::createFromFormat(LinkDB::LINK_DATE_FORMAT, '20001010_135536'),
'title' => 'Secret stuff',
'url' => 'https://private.tld',
'description' => "Super-secret stuff you're not supposed to know about",
$this->assertEquals(
array(
'id' => 1,
- 'created' => DateTime::createFromFormat('Ymd_His', '20160225_235548'),
+ 'created' => DateTime::createFromFormat(LinkDB::LINK_DATE_FORMAT, '20160225_235548'),
'title' => 'Public stuff',
'url' => 'http://public.tld',
'description' => '',
$this->assertEquals(
'File netscape_basic.htm (482 bytes) was successfully processed:'
.' 2 links imported, 0 links overwritten, 0 links skipped.',
- NetscapeBookmarkUtils::import($post, $files, $this->linkDb, $this->pagecache)
+ NetscapeBookmarkUtils::import($post, $files, $this->linkDb, $this->conf)
);
$this->assertEquals(2, count($this->linkDb));
$this->assertEquals(1, count_private($this->linkDb));
array(
'id' => 0,
// Note that TZ in the import file is ignored.
- 'created' => DateTime::createFromFormat('Ymd_His', '20001010_135536'),
+ 'created' => DateTime::createFromFormat(LinkDB::LINK_DATE_FORMAT, '20001010_135536'),
'title' => 'Secret stuff',
'url' => 'https://private.tld',
'description' => "Super-secret stuff you're not supposed to know about",
$this->assertEquals(
array(
'id' => 1,
- 'created' => DateTime::createFromFormat('Ymd_His', '20160225_235548'),
+ 'created' => DateTime::createFromFormat(LinkDB::LINK_DATE_FORMAT, '20160225_235548'),
'title' => 'Public stuff',
'url' => 'http://public.tld',
'description' => '',
$this->assertEquals(
'File netscape_basic.htm (482 bytes) was successfully processed:'
.' 2 links imported, 0 links overwritten, 0 links skipped.',
- NetscapeBookmarkUtils::import($post, $files, $this->linkDb, $this->pagecache)
+ NetscapeBookmarkUtils::import($post, $files, $this->linkDb, $this->conf)
);
$this->assertEquals(2, count($this->linkDb));
$this->assertEquals(0, count_private($this->linkDb));
$this->assertEquals(
'File netscape_basic.htm (482 bytes) was successfully processed:'
.' 2 links imported, 0 links overwritten, 0 links skipped.',
- NetscapeBookmarkUtils::import($post, $files, $this->linkDb, $this->pagecache)
+ NetscapeBookmarkUtils::import($post, $files, $this->linkDb, $this->conf)
);
$this->assertEquals(2, count($this->linkDb));
$this->assertEquals(2, count_private($this->linkDb));
$this->assertEquals(
'File netscape_basic.htm (482 bytes) was successfully processed:'
.' 2 links imported, 0 links overwritten, 0 links skipped.',
- NetscapeBookmarkUtils::import($post, $files, $this->linkDb, $this->pagecache)
+ NetscapeBookmarkUtils::import($post, $files, $this->linkDb, $this->conf)
);
$this->assertEquals(2, count($this->linkDb));
$this->assertEquals(2, count_private($this->linkDb));
$this->assertEquals(
'File netscape_basic.htm (482 bytes) was successfully processed:'
.' 2 links imported, 2 links overwritten, 0 links skipped.',
- NetscapeBookmarkUtils::import($post, $files, $this->linkDb, $this->pagecache)
+ NetscapeBookmarkUtils::import($post, $files, $this->linkDb, $this->conf)
);
$this->assertEquals(2, count($this->linkDb));
$this->assertEquals(0, count_private($this->linkDb));
$this->assertEquals(
'File netscape_basic.htm (482 bytes) was successfully processed:'
.' 2 links imported, 0 links overwritten, 0 links skipped.',
- NetscapeBookmarkUtils::import($post, $files, $this->linkDb, $this->pagecache)
+ NetscapeBookmarkUtils::import($post, $files, $this->linkDb, $this->conf)
);
$this->assertEquals(2, count($this->linkDb));
$this->assertEquals(0, count_private($this->linkDb));
$this->assertEquals(
'File netscape_basic.htm (482 bytes) was successfully processed:'
.' 2 links imported, 2 links overwritten, 0 links skipped.',
- NetscapeBookmarkUtils::import($post, $files, $this->linkDb, $this->pagecache)
+ NetscapeBookmarkUtils::import($post, $files, $this->linkDb, $this->conf)
);
$this->assertEquals(2, count($this->linkDb));
$this->assertEquals(2, count_private($this->linkDb));
$this->assertEquals(
'File netscape_basic.htm (482 bytes) was successfully processed:'
.' 2 links imported, 0 links overwritten, 0 links skipped.',
- NetscapeBookmarkUtils::import($post, $files, $this->linkDb, $this->pagecache)
+ NetscapeBookmarkUtils::import($post, $files, $this->linkDb, $this->conf)
);
$this->assertEquals(2, count($this->linkDb));
$this->assertEquals(0, count_private($this->linkDb));
$this->assertEquals(
'File netscape_basic.htm (482 bytes) was successfully processed:'
.' 0 links imported, 0 links overwritten, 2 links skipped.',
- NetscapeBookmarkUtils::import($post, $files, $this->linkDb, $this->pagecache)
+ NetscapeBookmarkUtils::import($post, $files, $this->linkDb, $this->conf)
);
$this->assertEquals(2, count($this->linkDb));
$this->assertEquals(0, count_private($this->linkDb));
$this->assertEquals(
'File netscape_basic.htm (482 bytes) was successfully processed:'
.' 2 links imported, 0 links overwritten, 0 links skipped.',
- NetscapeBookmarkUtils::import($post, $files, $this->linkDb, $this->pagecache)
+ NetscapeBookmarkUtils::import($post, $files, $this->linkDb, $this->conf)
);
$this->assertEquals(2, count($this->linkDb));
$this->assertEquals(0, count_private($this->linkDb));
$this->assertEquals(
'File netscape_basic.htm (482 bytes) was successfully processed:'
.' 2 links imported, 0 links overwritten, 0 links skipped.',
- NetscapeBookmarkUtils::import($post, $files, $this->linkDb, $this->pagecache)
+ NetscapeBookmarkUtils::import($post, $files, $this->linkDb, $this->conf)
);
$this->assertEquals(2, count($this->linkDb));
$this->assertEquals(0, count_private($this->linkDb));
$this->assertEquals(
'File same_date.htm (453 bytes) was successfully processed:'
.' 3 links imported, 0 links overwritten, 0 links skipped.',
- NetscapeBookmarkUtils::import(array(), $files, $this->linkDb, $this->pagecache)
+ NetscapeBookmarkUtils::import(array(), $files, $this->linkDb, $this->conf)
);
$this->assertEquals(3, count($this->linkDb));
$this->assertEquals(0, count_private($this->linkDb));