diff options
Diffstat (limited to 'tests/utils')
-rw-r--r-- | tests/utils/ReferenceLinkDB.php | 61 |
1 files changed, 47 insertions, 14 deletions
diff --git a/tests/utils/ReferenceLinkDB.php b/tests/utils/ReferenceLinkDB.php index abca4656..36d58c68 100644 --- a/tests/utils/ReferenceLinkDB.php +++ b/tests/utils/ReferenceLinkDB.php | |||
@@ -4,7 +4,7 @@ | |||
4 | */ | 4 | */ |
5 | class ReferenceLinkDB | 5 | class ReferenceLinkDB |
6 | { | 6 | { |
7 | public static $NB_LINKS_TOTAL = 7; | 7 | public static $NB_LINKS_TOTAL = 8; |
8 | 8 | ||
9 | private $_links = array(); | 9 | private $_links = array(); |
10 | private $_publicCount = 0; | 10 | private $_publicCount = 0; |
@@ -16,66 +16,87 @@ class ReferenceLinkDB | |||
16 | public function __construct() | 16 | public function __construct() |
17 | { | 17 | { |
18 | $this->addLink( | 18 | $this->addLink( |
19 | 41, | ||
19 | 'Link title: @website', | 20 | 'Link title: @website', |
20 | '?WDWyig', | 21 | '?WDWyig', |
21 | 'Stallman has a beard and is part of the Free Software Foundation (or not). Seriously, read this. #hashtag', | 22 | 'Stallman has a beard and is part of the Free Software Foundation (or not). Seriously, read this. #hashtag', |
22 | 0, | 23 | 0, |
23 | '20150310_114651', | 24 | DateTime::createFromFormat(LinkDB::LINK_DATE_FORMAT, '20150310_114651'), |
24 | 'sTuff' | 25 | 'sTuff', |
26 | null, | ||
27 | 'WDWyig' | ||
25 | ); | 28 | ); |
26 | 29 | ||
27 | $this->addLink( | 30 | $this->addLink( |
31 | 42, | ||
32 | 'Note: I have a big ID but an old date', | ||
33 | '?WDWyig', | ||
34 | 'Used to test links reordering.', | ||
35 | 0, | ||
36 | DateTime::createFromFormat(LinkDB::LINK_DATE_FORMAT, '20100310_101010'), | ||
37 | 'ut' | ||
38 | ); | ||
39 | |||
40 | $this->addLink( | ||
41 | 8, | ||
28 | 'Free as in Freedom 2.0 @website', | 42 | 'Free as in Freedom 2.0 @website', |
29 | 'https://static.fsf.org/nosvn/faif-2.0.pdf', | 43 | 'https://static.fsf.org/nosvn/faif-2.0.pdf', |
30 | 'Richard Stallman and the Free Software Revolution. Read this. #hashtag', | 44 | 'Richard Stallman and the Free Software Revolution. Read this. #hashtag', |
31 | 0, | 45 | 0, |
32 | '20150310_114633', | 46 | DateTime::createFromFormat(LinkDB::LINK_DATE_FORMAT, '20150310_114633'), |
33 | 'free gnu software stallman -exclude stuff hashtag', | 47 | 'free gnu software stallman -exclude stuff hashtag', |
34 | '20160803_093033' | 48 | DateTime::createFromFormat(LinkDB::LINK_DATE_FORMAT, '20160803_093033') |
35 | ); | 49 | ); |
36 | 50 | ||
37 | $this->addLink( | 51 | $this->addLink( |
52 | 7, | ||
38 | 'MediaGoblin', | 53 | 'MediaGoblin', |
39 | 'http://mediagoblin.org/', | 54 | 'http://mediagoblin.org/', |
40 | 'A free software media publishing platform #hashtagOther', | 55 | 'A free software media publishing platform #hashtagOther', |
41 | 0, | 56 | 0, |
42 | '20130614_184135', | 57 | DateTime::createFromFormat(LinkDB::LINK_DATE_FORMAT, '20130614_184135'), |
43 | 'gnu media web .hidden hashtag' | 58 | 'gnu media web .hidden hashtag', |
59 | null, | ||
60 | 'IuWvgA' | ||
44 | ); | 61 | ); |
45 | 62 | ||
46 | $this->addLink( | 63 | $this->addLink( |
64 | 6, | ||
47 | 'w3c-markup-validator', | 65 | 'w3c-markup-validator', |
48 | 'https://dvcs.w3.org/hg/markup-validator/summary', | 66 | 'https://dvcs.w3.org/hg/markup-validator/summary', |
49 | 'Mercurial repository for the W3C Validator #private', | 67 | 'Mercurial repository for the W3C Validator #private', |
50 | 1, | 68 | 1, |
51 | '20141125_084734', | 69 | DateTime::createFromFormat(LinkDB::LINK_DATE_FORMAT, '20141125_084734'), |
52 | 'css html w3c web Mercurial' | 70 | 'css html w3c web Mercurial' |
53 | ); | 71 | ); |
54 | 72 | ||
55 | $this->addLink( | 73 | $this->addLink( |
74 | 4, | ||
56 | 'UserFriendly - Web Designer', | 75 | 'UserFriendly - Web Designer', |
57 | 'http://ars.userfriendly.org/cartoons/?id=20121206', | 76 | 'http://ars.userfriendly.org/cartoons/?id=20121206', |
58 | 'Naming conventions... #private', | 77 | 'Naming conventions... #private', |
59 | 0, | 78 | 0, |
60 | '20121206_142300', | 79 | DateTime::createFromFormat(LinkDB::LINK_DATE_FORMAT, '20121206_142300'), |
61 | 'dev cartoon web' | 80 | 'dev cartoon web' |
62 | ); | 81 | ); |
63 | 82 | ||
64 | $this->addLink( | 83 | $this->addLink( |
84 | 1, | ||
65 | 'UserFriendly - Samba', | 85 | 'UserFriendly - Samba', |
66 | 'http://ars.userfriendly.org/cartoons/?id=20010306', | 86 | 'http://ars.userfriendly.org/cartoons/?id=20010306', |
67 | 'Tropical printing', | 87 | 'Tropical printing', |
68 | 0, | 88 | 0, |
69 | '20121206_172539', | 89 | DateTime::createFromFormat(LinkDB::LINK_DATE_FORMAT, '20121206_172539'), |
70 | 'samba cartoon web' | 90 | 'samba cartoon web' |
71 | ); | 91 | ); |
72 | 92 | ||
73 | $this->addLink( | 93 | $this->addLink( |
94 | 0, | ||
74 | 'Geek and Poke', | 95 | 'Geek and Poke', |
75 | 'http://geek-and-poke.com/', | 96 | 'http://geek-and-poke.com/', |
76 | '', | 97 | '', |
77 | 1, | 98 | 1, |
78 | '20121206_182539', | 99 | DateTime::createFromFormat(LinkDB::LINK_DATE_FORMAT, '20121206_182539'), |
79 | 'dev cartoon tag1 tag2 tag3 tag4 ' | 100 | 'dev cartoon tag1 tag2 tag3 tag4 ' |
80 | ); | 101 | ); |
81 | } | 102 | } |
@@ -83,18 +104,20 @@ class ReferenceLinkDB | |||
83 | /** | 104 | /** |
84 | * Adds a new link | 105 | * Adds a new link |
85 | */ | 106 | */ |
86 | protected function addLink($title, $url, $description, $private, $date, $tags, $updated = '') | 107 | protected function addLink($id, $title, $url, $description, $private, $date, $tags, $updated = '', $shorturl = '') |
87 | { | 108 | { |
88 | $link = array( | 109 | $link = array( |
110 | 'id' => $id, | ||
89 | 'title' => $title, | 111 | 'title' => $title, |
90 | 'url' => $url, | 112 | 'url' => $url, |
91 | 'description' => $description, | 113 | 'description' => $description, |
92 | 'private' => $private, | 114 | 'private' => $private, |
93 | 'linkdate' => $date, | ||
94 | 'tags' => $tags, | 115 | 'tags' => $tags, |
116 | 'created' => $date, | ||
95 | 'updated' => $updated, | 117 | 'updated' => $updated, |
118 | 'shorturl' => $shorturl ? $shorturl : smallHash($date->format(LinkDB::LINK_DATE_FORMAT) . $id), | ||
96 | ); | 119 | ); |
97 | $this->_links[$date] = $link; | 120 | $this->_links[$id] = $link; |
98 | 121 | ||
99 | if ($private) { | 122 | if ($private) { |
100 | $this->_privateCount++; | 123 | $this->_privateCount++; |
@@ -142,4 +165,14 @@ class ReferenceLinkDB | |||
142 | { | 165 | { |
143 | return $this->_links; | 166 | return $this->_links; |
144 | } | 167 | } |
168 | |||
169 | /** | ||
170 | * Setter to override link creation. | ||
171 | * | ||
172 | * @param array $links List of links. | ||
173 | */ | ||
174 | public function setLinks($links) | ||
175 | { | ||
176 | $this->_links = $links; | ||
177 | } | ||
145 | } | 178 | } |