]>
git.immae.eu Git - github/shaarli/Shaarli.git/blob - tests/utils/ReferenceLinkDB.php
3 * Populates a reference datastore to test LinkDB
7 public static $NB_LINKS_TOTAL = 8;
9 private $_links = array();
10 private $_publicCount = 0;
11 private $_privateCount = 0;
14 * Populates the test DB with reference data
16 public function __construct()
20 'Link title: @website',
22 'Stallman has a beard and is part of the Free Software Foundation (or not). Seriously, read this. #hashtag',
24 DateTime
::createFromFormat(LinkDB
::LINK_DATE_FORMAT
, '20150310_114651'),
32 'Note: I have a big ID but an old date',
34 'Used to test links reordering.',
36 DateTime
::createFromFormat(LinkDB
::LINK_DATE_FORMAT
, '20100310_101010'),
42 'Free as in Freedom 2.0 @website',
43 'https://static.fsf.org/nosvn/faif-2.0.pdf',
44 'Richard Stallman and the Free Software Revolution. Read this. #hashtag',
46 DateTime
::createFromFormat(LinkDB
::LINK_DATE_FORMAT
, '20150310_114633'),
47 'free gnu software stallman -exclude stuff hashtag',
48 DateTime
::createFromFormat(LinkDB
::LINK_DATE_FORMAT
, '20160803_093033')
54 'http://mediagoblin.org/',
55 'A free software media publishing platform #hashtagOther',
57 DateTime
::createFromFormat(LinkDB
::LINK_DATE_FORMAT
, '20130614_184135'),
58 'gnu media web .hidden hashtag',
65 'w3c-markup-validator',
66 'https://dvcs.w3.org/hg/markup-validator/summary',
67 'Mercurial repository for the W3C Validator #private',
69 DateTime
::createFromFormat(LinkDB
::LINK_DATE_FORMAT
, '20141125_084734'),
70 'css html w3c web Mercurial'
75 'UserFriendly - Web Designer',
76 'http://ars.userfriendly.org/cartoons/?id=20121206',
77 'Naming conventions... #private',
79 DateTime
::createFromFormat(LinkDB
::LINK_DATE_FORMAT
, '20121206_142300'),
85 'UserFriendly - Samba',
86 'http://ars.userfriendly.org/cartoons/?id=20010306',
89 DateTime
::createFromFormat(LinkDB
::LINK_DATE_FORMAT
, '20121206_172539'),
96 'http://geek-and-poke.com/',
99 DateTime
::createFromFormat(LinkDB
::LINK_DATE_FORMAT
, '20121206_182539'),
100 'dev cartoon tag1 tag2 tag3 tag4 '
107 protected function addLink($id, $title, $url, $description, $private, $date, $tags, $updated = '', $shorturl = '')
113 'description' => $description,
114 'private' => $private,
117 'updated' => $updated,
118 'shorturl' => $shorturl ? $shorturl : smallHash($date->format(LinkDB
::LINK_DATE_FORMAT
) . $id),
120 $this->_links
[$id] = $link;
123 $this->_privateCount++
;
126 $this->_publicCount++
;
130 * Writes data to the datastore
132 public function write($filename)
136 '<?php /* '.base64_encode(gzdeflate(serialize($this->_links
))).' */ ?>'
141 * Returns the number of links in the reference data
143 public function countLinks()
145 return $this->_publicCount +
$this->_privateCount
;
149 * Returns the number of public links in the reference data
151 public function countPublicLinks()
153 return $this->_publicCount
;
157 * Returns the number of private links in the reference data
159 public function countPrivateLinks()
161 return $this->_privateCount
;
164 public function getLinks()
166 return $this->_links
;
170 * Setter to override link creation.
172 * @param array $links List of links.
174 public function setLinks($links)
176 $this->_links
= $links;