diff options
Diffstat (limited to 'tests/utils')
-rw-r--r-- | tests/utils/FakeConfigManager.php | 47 | ||||
-rw-r--r-- | tests/utils/ReferenceLinkDB.php | 49 | ||||
-rw-r--r-- | tests/utils/config/configJson.json.php | 71 | ||||
-rw-r--r-- | tests/utils/config/configPhp.php | 2 | ||||
-rw-r--r-- | tests/utils/config/wt.json | 12 | ||||
-rw-r--r-- | tests/utils/customtpl/dummy/language/fr/LC_MESSAGES/dummy.mo | bin | 0 -> 431 bytes | |||
-rw-r--r-- | tests/utils/customtpl/dummy/language/fr/LC_MESSAGES/dummy.po | 16 |
7 files changed, 180 insertions, 17 deletions
diff --git a/tests/utils/FakeConfigManager.php b/tests/utils/FakeConfigManager.php index f29760cb..360b34a9 100644 --- a/tests/utils/FakeConfigManager.php +++ b/tests/utils/FakeConfigManager.php | |||
@@ -5,8 +5,53 @@ | |||
5 | */ | 5 | */ |
6 | class FakeConfigManager | 6 | class FakeConfigManager |
7 | { | 7 | { |
8 | public static function get($key) | 8 | protected $values = []; |
9 | |||
10 | /** | ||
11 | * Initialize with test values | ||
12 | * | ||
13 | * @param array $values Initial values | ||
14 | */ | ||
15 | public function __construct($values = []) | ||
16 | { | ||
17 | $this->values = $values; | ||
18 | } | ||
19 | |||
20 | /** | ||
21 | * Set a given value | ||
22 | * | ||
23 | * @param string $key Key of the value to set | ||
24 | * @param mixed $value Value to set | ||
25 | */ | ||
26 | public function set($key, $value) | ||
27 | { | ||
28 | $this->values[$key] = $value; | ||
29 | } | ||
30 | |||
31 | /** | ||
32 | * Get a given configuration value | ||
33 | * | ||
34 | * @param string $key Index of the value to retrieve | ||
35 | * | ||
36 | * @return mixed The value if set, else the name of the key | ||
37 | */ | ||
38 | public function get($key) | ||
9 | { | 39 | { |
40 | if (isset($this->values[$key])) { | ||
41 | return $this->values[$key]; | ||
42 | } | ||
10 | return $key; | 43 | return $key; |
11 | } | 44 | } |
45 | |||
46 | /** | ||
47 | * Check if a setting exists | ||
48 | * | ||
49 | * @param string $setting Asked setting, keys separated with dots | ||
50 | * | ||
51 | * @return bool true if the setting exists, false otherwise | ||
52 | */ | ||
53 | public function exists($setting) | ||
54 | { | ||
55 | return array_key_exists($setting, $this->values); | ||
56 | } | ||
12 | } | 57 | } |
diff --git a/tests/utils/ReferenceLinkDB.php b/tests/utils/ReferenceLinkDB.php index e887aa78..59679e38 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 = 9; | 7 | public static $NB_LINKS_TOTAL = 11; |
8 | 8 | ||
9 | private $_links = array(); | 9 | private $_links = array(); |
10 | private $_publicCount = 0; | 10 | private $_publicCount = 0; |
@@ -16,6 +16,32 @@ class ReferenceLinkDB | |||
16 | public function __construct() | 16 | public function __construct() |
17 | { | 17 | { |
18 | $this->addLink( | 18 | $this->addLink( |
19 | 11, | ||
20 | 'Pined older', | ||
21 | '?PCRizQ', | ||
22 | 'This is an older pinned link', | ||
23 | 0, | ||
24 | DateTime::createFromFormat(LinkDB::LINK_DATE_FORMAT, '20100309_101010'), | ||
25 | '', | ||
26 | null, | ||
27 | 'PCRizQ', | ||
28 | true | ||
29 | ); | ||
30 | |||
31 | $this->addLink( | ||
32 | 10, | ||
33 | 'Pined', | ||
34 | '?0gCTjQ', | ||
35 | 'This is a pinned link', | ||
36 | 0, | ||
37 | DateTime::createFromFormat(LinkDB::LINK_DATE_FORMAT, '20121207_152312'), | ||
38 | '', | ||
39 | null, | ||
40 | '0gCTjQ', | ||
41 | true | ||
42 | ); | ||
43 | |||
44 | $this->addLink( | ||
19 | 41, | 45 | 41, |
20 | 'Link title: @website', | 46 | 'Link title: @website', |
21 | '?WDWyig', | 47 | '?WDWyig', |
@@ -114,8 +140,18 @@ class ReferenceLinkDB | |||
114 | /** | 140 | /** |
115 | * Adds a new link | 141 | * Adds a new link |
116 | */ | 142 | */ |
117 | protected function addLink($id, $title, $url, $description, $private, $date, $tags, $updated = '', $shorturl = '') | 143 | protected function addLink( |
118 | { | 144 | $id, |
145 | $title, | ||
146 | $url, | ||
147 | $description, | ||
148 | $private, | ||
149 | $date, | ||
150 | $tags, | ||
151 | $updated = '', | ||
152 | $shorturl = '', | ||
153 | $pinned = false | ||
154 | ) { | ||
119 | $link = array( | 155 | $link = array( |
120 | 'id' => $id, | 156 | 'id' => $id, |
121 | 'title' => $title, | 157 | 'title' => $title, |
@@ -126,6 +162,7 @@ class ReferenceLinkDB | |||
126 | 'created' => $date, | 162 | 'created' => $date, |
127 | 'updated' => $updated, | 163 | 'updated' => $updated, |
128 | 'shorturl' => $shorturl ? $shorturl : smallHash($date->format(LinkDB::LINK_DATE_FORMAT) . $id), | 164 | 'shorturl' => $shorturl ? $shorturl : smallHash($date->format(LinkDB::LINK_DATE_FORMAT) . $id), |
165 | 'sticky' => $pinned | ||
129 | ); | 166 | ); |
130 | $this->_links[$id] = $link; | 167 | $this->_links[$id] = $link; |
131 | 168 | ||
@@ -164,7 +201,11 @@ class ReferenceLinkDB | |||
164 | 201 | ||
165 | $order = $order === 'ASC' ? -1 : 1; | 202 | $order = $order === 'ASC' ? -1 : 1; |
166 | // Reorder array by dates. | 203 | // Reorder array by dates. |
167 | usort($this->_links, function($a, $b) use ($order) { | 204 | usort($this->_links, function ($a, $b) use ($order) { |
205 | if (isset($a['sticky']) && isset($b['sticky']) && $a['sticky'] !== $b['sticky']) { | ||
206 | return $a['sticky'] ? -1 : 1; | ||
207 | } | ||
208 | |||
168 | return $a['created'] < $b['created'] ? 1 * $order : -1 * $order; | 209 | return $a['created'] < $b['created'] ? 1 * $order : -1 * $order; |
169 | }); | 210 | }); |
170 | } | 211 | } |
diff --git a/tests/utils/config/configJson.json.php b/tests/utils/config/configJson.json.php index 9c9288f3..1549ddfc 100644 --- a/tests/utils/config/configJson.json.php +++ b/tests/utils/config/configJson.json.php | |||
@@ -1,35 +1,84 @@ | |||
1 | <?php /* | 1 | <?php /* |
2 | { | 2 | { |
3 | "credentials": { | 3 | "credentials": { |
4 | "login":"root", | 4 | "login": "root", |
5 | "hash":"hash", | 5 | "hash": "hash", |
6 | "salt":"salt" | 6 | "salt": "salt" |
7 | }, | 7 | }, |
8 | "security": { | 8 | "security": { |
9 | "session_protection_disabled":false | 9 | "session_protection_disabled": false, |
10 | "ban_after": 4, | ||
11 | "ban_duration": 1800, | ||
12 | "open_shaarli": false, | ||
13 | "allowed_protocols": [ | ||
14 | "ftp", | ||
15 | "ftps", | ||
16 | "magnet" | ||
17 | ] | ||
10 | }, | 18 | }, |
11 | "general": { | 19 | "general": { |
12 | "timezone":"Europe\/Paris", | 20 | "timezone": "Europe\/Paris", |
13 | "title": "Shaarli", | 21 | "title": "Shaarli", |
14 | "header_link": "?" | 22 | "header_link": "?", |
23 | "links_per_page": 20, | ||
24 | "enabled_plugins": [ | ||
25 | "qrcode" | ||
26 | ], | ||
27 | "default_note_title": "Note: " | ||
15 | }, | 28 | }, |
16 | "privacy": { | 29 | "privacy": { |
17 | "default_private_links":true | 30 | "default_private_links": true, |
31 | "hide_public_links": false, | ||
32 | "force_login": false, | ||
33 | "hide_timestamps": false, | ||
34 | "remember_user_default": true | ||
18 | }, | 35 | }, |
19 | "redirector": { | 36 | "redirector": { |
20 | "url":"lala" | 37 | "url": "lala", |
38 | "encode_url": true | ||
21 | }, | 39 | }, |
22 | "config": { | 40 | "config": { |
23 | "foo": "bar" | 41 | "foo": "bar" |
24 | }, | 42 | }, |
25 | "resource": { | 43 | "resource": { |
26 | "datastore": "tests\/utils\/config\/datastore.php", | 44 | "datastore": "tests\/utils\/config\/datastore.php", |
27 | "data_dir": "sandbox/", | 45 | "data_dir": "sandbox\/", |
28 | "raintpl_tpl": "tpl/" | 46 | "raintpl_tpl": "tpl\/", |
47 | "config": "data\/config.php", | ||
48 | "ban_file": "data\/ipbans.php", | ||
49 | "updates": "data\/updates.txt", | ||
50 | "log": "data\/log.txt", | ||
51 | "update_check": "data\/lastupdatecheck.txt", | ||
52 | "history": "data\/history.php", | ||
53 | "theme": "default", | ||
54 | "raintpl_tmp": "tmp\/", | ||
55 | "thumbnails_cache": "cache", | ||
56 | "page_cache": "pagecache" | ||
29 | }, | 57 | }, |
30 | "plugins": { | 58 | "plugins": { |
31 | "WALLABAG_VERSION": 1 | 59 | "WALLABAG_VERSION": 1 |
60 | }, | ||
61 | "dev": { | ||
62 | "debug": true | ||
63 | }, | ||
64 | "updates": { | ||
65 | "check_updates": false, | ||
66 | "check_updates_branch": "stable", | ||
67 | "check_updates_interval": 86400 | ||
68 | }, | ||
69 | "feed": { | ||
70 | "rss_permalinks": true, | ||
71 | "show_atom": true | ||
72 | }, | ||
73 | "translation": { | ||
74 | "language": "auto", | ||
75 | "mode": "php", | ||
76 | "extensions": [] | ||
77 | }, | ||
78 | "thumbnails": { | ||
79 | "mode": "common", | ||
80 | "width": 90, | ||
81 | "height": 53 | ||
32 | } | 82 | } |
33 | } | 83 | } |
34 | */ ?> | 84 | */ ?> |
35 | |||
diff --git a/tests/utils/config/configPhp.php b/tests/utils/config/configPhp.php index 0e034175..34b11fcd 100644 --- a/tests/utils/config/configPhp.php +++ b/tests/utils/config/configPhp.php | |||
@@ -1,4 +1,4 @@ | |||
1 | <?php | 1 | <?php |
2 | $GLOBALS['login'] = 'root'; | 2 | $GLOBALS['login'] = 'root'; |
3 | $GLOBALS['hash'] = 'hash'; | 3 | $GLOBALS['hash'] = 'hash'; |
4 | $GLOBALS['salt'] = 'salt'; | 4 | $GLOBALS['salt'] = 'salt'; |
diff --git a/tests/utils/config/wt.json b/tests/utils/config/wt.json new file mode 100644 index 00000000..69ce49a6 --- /dev/null +++ b/tests/utils/config/wt.json | |||
@@ -0,0 +1,12 @@ | |||
1 | { | ||
2 | "settings": { | ||
3 | "default": { | ||
4 | "_comment": "infinite cache", | ||
5 | "cache_duration": -1, | ||
6 | "timeout": 10 | ||
7 | }, | ||
8 | "path": { | ||
9 | "cache": "sandbox/" | ||
10 | } | ||
11 | } | ||
12 | } \ No newline at end of file | ||
diff --git a/tests/utils/customtpl/dummy/language/fr/LC_MESSAGES/dummy.mo b/tests/utils/customtpl/dummy/language/fr/LC_MESSAGES/dummy.mo new file mode 100644 index 00000000..8daae0c9 --- /dev/null +++ b/tests/utils/customtpl/dummy/language/fr/LC_MESSAGES/dummy.mo | |||
Binary files differ | |||
diff --git a/tests/utils/customtpl/dummy/language/fr/LC_MESSAGES/dummy.po b/tests/utils/customtpl/dummy/language/fr/LC_MESSAGES/dummy.po new file mode 100644 index 00000000..90d1abb0 --- /dev/null +++ b/tests/utils/customtpl/dummy/language/fr/LC_MESSAGES/dummy.po | |||
@@ -0,0 +1,16 @@ | |||
1 | msgid "" | ||
2 | msgstr "" | ||
3 | "Project-Id-Version: Theme extension test\n" | ||
4 | "POT-Creation-Date: 2017-05-20 13:54+0200\n" | ||
5 | "PO-Revision-Date: 2018-03-26 19:09+0200\n" | ||
6 | "Last-Translator: \n" | ||
7 | "Language-Team: Shaarli\n" | ||
8 | "Language: fr_FR\n" | ||
9 | "MIME-Version: 1.0\n" | ||
10 | "Content-Type: text/plain; charset=UTF-8\n" | ||
11 | "Content-Transfer-Encoding: 8bit\n" | ||
12 | "Plural-Forms: nplurals=2; plural=(n > 1);\n" | ||
13 | "X-Generator: Poedit 2.0.6\n" | ||
14 | |||
15 | msgid "rooster" | ||
16 | msgstr "coq" | ||