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