]> git.immae.eu Git - github/shaarli/Shaarli.git/blame - tests/utils/ReferenceLinkDB.php
LinkDB: explicit method visibility
[github/shaarli/Shaarli.git] / tests / utils / ReferenceLinkDB.php
CommitLineData
ca74886f
V
1<?php
2/**
3 * Populates a reference datastore to test LinkDB
4 */
5class ReferenceLinkDB
6{
89baf23d
A
7 public static $NB_LINKS_TOTAL = 7;
8
07b6fa75
V
9 private $_links = array();
10 private $_publicCount = 0;
11 private $_privateCount = 0;
ca74886f
V
12
13 /**
14 * Populates the test DB with reference data
15 */
735ed4a9 16 public function __construct()
ca74886f 17 {
89baf23d
A
18 $this->addLink(
19 'Link title: @website',
20 '?WDWyig',
9ccca401 21 'Stallman has a beard and is part of the Free Software Foundation (or not). Seriously, read this. #hashtag',
89baf23d
A
22 0,
23 '20150310_114651',
b1eb5d1d 24 'sTuff'
89baf23d
A
25 );
26
ca74886f 27 $this->addLink(
522b278b 28 'Free as in Freedom 2.0 @website',
ca74886f 29 'https://static.fsf.org/nosvn/faif-2.0.pdf',
9ccca401 30 'Richard Stallman and the Free Software Revolution. Read this. #hashtag',
ca74886f
V
31 0,
32 '20150310_114633',
c6d876bb
A
33 'free gnu software stallman -exclude stuff hashtag',
34 '20160803_093033'
ca74886f
V
35 );
36
37 $this->addLink(
38 'MediaGoblin',
39 'http://mediagoblin.org/',
9ccca401 40 'A free software media publishing platform #hashtagOther',
ca74886f
V
41 0,
42 '20130614_184135',
9ccca401 43 'gnu media web .hidden hashtag'
ca74886f
V
44 );
45
46 $this->addLink(
47 'w3c-markup-validator',
48 'https://dvcs.w3.org/hg/markup-validator/summary',
9ccca401 49 'Mercurial repository for the W3C Validator #private',
ca74886f
V
50 1,
51 '20141125_084734',
52 'css html w3c web Mercurial'
53 );
54
55 $this->addLink(
56 'UserFriendly - Web Designer',
57 'http://ars.userfriendly.org/cartoons/?id=20121206',
9ccca401 58 'Naming conventions... #private',
ca74886f
V
59 0,
60 '20121206_142300',
61 'dev cartoon web'
62 );
63
64 $this->addLink(
65 'UserFriendly - Samba',
66 'http://ars.userfriendly.org/cartoons/?id=20010306',
67 'Tropical printing',
68 0,
69 '20121206_172539',
70 'samba cartoon web'
71 );
72
73 $this->addLink(
74 'Geek and Poke',
75 'http://geek-and-poke.com/',
76 '',
77 1,
78 '20121206_182539',
9866b408 79 'dev cartoon tag1 tag2 tag3 tag4 '
ca74886f
V
80 );
81 }
82
83 /**
84 * Adds a new link
85 */
c6d876bb 86 protected function addLink($title, $url, $description, $private, $date, $tags, $updated = '')
ca74886f
V
87 {
88 $link = array(
89 'title' => $title,
90 'url' => $url,
91 'description' => $description,
92 'private' => $private,
93 'linkdate' => $date,
94 'tags' => $tags,
c6d876bb 95 'updated' => $updated,
ca74886f 96 );
07b6fa75 97 $this->_links[$date] = $link;
ca74886f
V
98
99 if ($private) {
07b6fa75 100 $this->_privateCount++;
ca74886f
V
101 return;
102 }
07b6fa75 103 $this->_publicCount++;
ca74886f
V
104 }
105
106 /**
107 * Writes data to the datastore
108 */
9c8752a2 109 public function write($filename)
ca74886f
V
110 {
111 file_put_contents(
112 $filename,
07b6fa75 113 '<?php /* '.base64_encode(gzdeflate(serialize($this->_links))).' */ ?>'
ca74886f
V
114 );
115 }
116
117 /**
118 * Returns the number of links in the reference data
119 */
120 public function countLinks()
121 {
07b6fa75 122 return $this->_publicCount + $this->_privateCount;
ca74886f
V
123 }
124
125 /**
126 * Returns the number of public links in the reference data
127 */
128 public function countPublicLinks()
129 {
07b6fa75 130 return $this->_publicCount;
ca74886f
V
131 }
132
133 /**
134 * Returns the number of private links in the reference data
135 */
136 public function countPrivateLinks()
137 {
07b6fa75 138 return $this->_privateCount;
ca74886f 139 }
822bffce
A
140
141 public function getLinks()
142 {
143 return $this->_links;
144 }
ca74886f 145}