aboutsummaryrefslogtreecommitdiffhomepage
path: root/tests/utils/ReferenceLinkDB.php
diff options
context:
space:
mode:
Diffstat (limited to 'tests/utils/ReferenceLinkDB.php')
-rw-r--r--tests/utils/ReferenceLinkDB.php77
1 files changed, 56 insertions, 21 deletions
diff --git a/tests/utils/ReferenceLinkDB.php b/tests/utils/ReferenceLinkDB.php
index dc4f5dfa..36d58c68 100644
--- a/tests/utils/ReferenceLinkDB.php
+++ b/tests/utils/ReferenceLinkDB.php
@@ -4,7 +4,7 @@
4 */ 4 */
5class ReferenceLinkDB 5class 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;
@@ -13,86 +13,111 @@ class ReferenceLinkDB
13 /** 13 /**
14 * Populates the test DB with reference data 14 * Populates the test DB with reference data
15 */ 15 */
16 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.', 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.', 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' 47 'free gnu software stallman -exclude stuff hashtag',
48 DateTime::createFromFormat(LinkDB::LINK_DATE_FORMAT, '20160803_093033')
34 ); 49 );
35 50
36 $this->addLink( 51 $this->addLink(
52 7,
37 'MediaGoblin', 53 'MediaGoblin',
38 'http://mediagoblin.org/', 54 'http://mediagoblin.org/',
39 'A free software media publishing platform', 55 'A free software media publishing platform #hashtagOther',
40 0, 56 0,
41 '20130614_184135', 57 DateTime::createFromFormat(LinkDB::LINK_DATE_FORMAT, '20130614_184135'),
42 'gnu media web .hidden' 58 'gnu media web .hidden hashtag',
59 null,
60 'IuWvgA'
43 ); 61 );
44 62
45 $this->addLink( 63 $this->addLink(
64 6,
46 'w3c-markup-validator', 65 'w3c-markup-validator',
47 'https://dvcs.w3.org/hg/markup-validator/summary', 66 'https://dvcs.w3.org/hg/markup-validator/summary',
48 'Mercurial repository for the W3C Validator', 67 'Mercurial repository for the W3C Validator #private',
49 1, 68 1,
50 '20141125_084734', 69 DateTime::createFromFormat(LinkDB::LINK_DATE_FORMAT, '20141125_084734'),
51 'css html w3c web Mercurial' 70 'css html w3c web Mercurial'
52 ); 71 );
53 72
54 $this->addLink( 73 $this->addLink(
74 4,
55 'UserFriendly - Web Designer', 75 'UserFriendly - Web Designer',
56 'http://ars.userfriendly.org/cartoons/?id=20121206', 76 'http://ars.userfriendly.org/cartoons/?id=20121206',
57 'Naming conventions...', 77 'Naming conventions... #private',
58 0, 78 0,
59 '20121206_142300', 79 DateTime::createFromFormat(LinkDB::LINK_DATE_FORMAT, '20121206_142300'),
60 'dev cartoon web' 80 'dev cartoon web'
61 ); 81 );
62 82
63 $this->addLink( 83 $this->addLink(
84 1,
64 'UserFriendly - Samba', 85 'UserFriendly - Samba',
65 'http://ars.userfriendly.org/cartoons/?id=20010306', 86 'http://ars.userfriendly.org/cartoons/?id=20010306',
66 'Tropical printing', 87 'Tropical printing',
67 0, 88 0,
68 '20121206_172539', 89 DateTime::createFromFormat(LinkDB::LINK_DATE_FORMAT, '20121206_172539'),
69 'samba cartoon web' 90 'samba cartoon web'
70 ); 91 );
71 92
72 $this->addLink( 93 $this->addLink(
94 0,
73 'Geek and Poke', 95 'Geek and Poke',
74 'http://geek-and-poke.com/', 96 'http://geek-and-poke.com/',
75 '', 97 '',
76 1, 98 1,
77 '20121206_182539', 99 DateTime::createFromFormat(LinkDB::LINK_DATE_FORMAT, '20121206_182539'),
78 'dev cartoon' 100 'dev cartoon tag1 tag2 tag3 tag4 '
79 ); 101 );
80 } 102 }
81 103
82 /** 104 /**
83 * Adds a new link 105 * Adds a new link
84 */ 106 */
85 protected function addLink($title, $url, $description, $private, $date, $tags) 107 protected function addLink($id, $title, $url, $description, $private, $date, $tags, $updated = '', $shorturl = '')
86 { 108 {
87 $link = array( 109 $link = array(
110 'id' => $id,
88 'title' => $title, 111 'title' => $title,
89 'url' => $url, 112 'url' => $url,
90 'description' => $description, 113 'description' => $description,
91 'private' => $private, 114 'private' => $private,
92 'linkdate' => $date,
93 'tags' => $tags, 115 'tags' => $tags,
116 'created' => $date,
117 'updated' => $updated,
118 'shorturl' => $shorturl ? $shorturl : smallHash($date->format(LinkDB::LINK_DATE_FORMAT) . $id),
94 ); 119 );
95 $this->_links[$date] = $link; 120 $this->_links[$id] = $link;
96 121
97 if ($private) { 122 if ($private) {
98 $this->_privateCount++; 123 $this->_privateCount++;
@@ -140,4 +165,14 @@ class ReferenceLinkDB
140 { 165 {
141 return $this->_links; 166 return $this->_links;
142 } 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 }
143} 178}