aboutsummaryrefslogtreecommitdiffhomepage
path: root/tests/plugins
diff options
context:
space:
mode:
Diffstat (limited to 'tests/plugins')
-rw-r--r--tests/plugins/PluginDefaultColorsTest.php23
-rw-r--r--tests/plugins/PluginWallabagTest.php35
-rw-r--r--tests/plugins/test/test.php16
-rw-r--r--tests/plugins/test_route_invalid/test_route_invalid.php12
4 files changed, 80 insertions, 6 deletions
diff --git a/tests/plugins/PluginDefaultColorsTest.php b/tests/plugins/PluginDefaultColorsTest.php
index cc844c60..54e97612 100644
--- a/tests/plugins/PluginDefaultColorsTest.php
+++ b/tests/plugins/PluginDefaultColorsTest.php
@@ -193,4 +193,27 @@ class PluginDefaultColorsTest extends TestCase
193 $result = default_colors_format_css_rule($data, ''); 193 $result = default_colors_format_css_rule($data, '');
194 $this->assertEmpty($result); 194 $this->assertEmpty($result);
195 } 195 }
196
197 /**
198 * Make sure that a new CSS file is generated when save_plugin_parameters hook is triggered.
199 */
200 public function testHookSavePluginParameters(): void
201 {
202 $params = [
203 'other1' => true,
204 'DEFAULT_COLORS_BACKGROUND' => 'pink',
205 'other2' => ['yep'],
206 'DEFAULT_COLORS_DARK_MAIN' => '',
207 ];
208
209 hook_default_colors_save_plugin_parameters($params);
210 $this->assertFileExists($file = 'sandbox/default_colors/default_colors.css');
211 $content = file_get_contents($file);
212 $expected = ':root {
213 --background-color: pink;
214
215}
216';
217 $this->assertEquals($expected, $content);
218 }
196} 219}
diff --git a/tests/plugins/PluginWallabagTest.php b/tests/plugins/PluginWallabagTest.php
index 36317215..9a402fb7 100644
--- a/tests/plugins/PluginWallabagTest.php
+++ b/tests/plugins/PluginWallabagTest.php
@@ -49,14 +49,15 @@ class PluginWallabagTest extends \Shaarli\TestCase
49 $conf = new ConfigManager(''); 49 $conf = new ConfigManager('');
50 $conf->set('plugins.WALLABAG_URL', 'value'); 50 $conf->set('plugins.WALLABAG_URL', 'value');
51 $str = 'http://randomstr.com/test'; 51 $str = 'http://randomstr.com/test';
52 $data = array( 52 $data = [
53 'title' => $str, 53 'title' => $str,
54 'links' => array( 54 'links' => [
55 array( 55 [
56 'url' => $str, 56 'url' => $str,
57 ) 57 ]
58 ) 58 ],
59 ); 59 '_LOGGEDIN_' => true,
60 ];
60 61
61 $data = hook_wallabag_render_linklist($data, $conf); 62 $data = hook_wallabag_render_linklist($data, $conf);
62 $link = $data['links'][0]; 63 $link = $data['links'][0];
@@ -69,4 +70,26 @@ class PluginWallabagTest extends \Shaarli\TestCase
69 $this->assertNotFalse(strpos($link['link_plugin'][0], urlencode($str))); 70 $this->assertNotFalse(strpos($link['link_plugin'][0], urlencode($str)));
70 $this->assertNotFalse(strpos($link['link_plugin'][0], $conf->get('plugins.WALLABAG_URL'))); 71 $this->assertNotFalse(strpos($link['link_plugin'][0], $conf->get('plugins.WALLABAG_URL')));
71 } 72 }
73
74 /**
75 * Test render_linklist hook while logged out: no change.
76 */
77 public function testWallabagLinklistLoggedOut(): void
78 {
79 $conf = new ConfigManager('');
80 $str = 'http://randomstr.com/test';
81 $data = [
82 'title' => $str,
83 'links' => [
84 [
85 'url' => $str,
86 ]
87 ],
88 '_LOGGEDIN_' => false,
89 ];
90
91 $result = hook_wallabag_render_linklist($data, $conf);
92
93 static::assertSame($data, $result);
94 }
72} 95}
diff --git a/tests/plugins/test/test.php b/tests/plugins/test/test.php
index 03be4f4e..34cd339e 100644
--- a/tests/plugins/test/test.php
+++ b/tests/plugins/test/test.php
@@ -27,3 +27,19 @@ function hook_test_error()
27{ 27{
28 new Unknown(); 28 new Unknown();
29} 29}
30
31function test_register_routes(): array
32{
33 return [
34 [
35 'method' => 'GET',
36 'route' => '/test',
37 'callable' => 'getFunction',
38 ],
39 [
40 'method' => 'POST',
41 'route' => '/custom',
42 'callable' => 'postFunction',
43 ],
44 ];
45}
diff --git a/tests/plugins/test_route_invalid/test_route_invalid.php b/tests/plugins/test_route_invalid/test_route_invalid.php
new file mode 100644
index 00000000..0c5a5101
--- /dev/null
+++ b/tests/plugins/test_route_invalid/test_route_invalid.php
@@ -0,0 +1,12 @@
1<?php
2
3function test_route_invalid_register_routes(): array
4{
5 return [
6 [
7 'method' => 'GET',
8 'route' => 'not a route',
9 'callable' => 'getFunction',
10 ],
11 ];
12}