diff options
author | ArthurHoaro <arthur@hoa.ro> | 2016-10-03 09:43:49 +0200 |
---|---|---|
committer | ArthurHoaro <arthur@hoa.ro> | 2016-10-17 09:23:14 +0200 |
commit | bf26e7ebcb5ee69523b93a5ec7b7a65b39acb916 (patch) | |
tree | a5a8c57150576404597f2e45877f10c9ea05e59a /tests/plugins | |
parent | 06eec9bf764662cd328627247a1f43e4abd3c5ad (diff) | |
download | Shaarli-bf26e7ebcb5ee69523b93a5ec7b7a65b39acb916.tar.gz Shaarli-bf26e7ebcb5ee69523b93a5ec7b7a65b39acb916.tar.zst Shaarli-bf26e7ebcb5ee69523b93a5ec7b7a65b39acb916.zip |
Isso comments plugin
Use Isso client to let visitors comments on permalinks
Diffstat (limited to 'tests/plugins')
-rw-r--r-- | tests/plugins/PluginIssoTest.php | 136 |
1 files changed, 136 insertions, 0 deletions
diff --git a/tests/plugins/PluginIssoTest.php b/tests/plugins/PluginIssoTest.php new file mode 100644 index 00000000..1f545c7d --- /dev/null +++ b/tests/plugins/PluginIssoTest.php | |||
@@ -0,0 +1,136 @@ | |||
1 | <?php | ||
2 | |||
3 | require_once 'plugins/isso/isso.php'; | ||
4 | |||
5 | /** | ||
6 | * Class PluginIssoTest | ||
7 | * | ||
8 | * Test the Isso plugin (comment system). | ||
9 | */ | ||
10 | class PluginIssoTest extends PHPUnit_Framework_TestCase | ||
11 | { | ||
12 | /** | ||
13 | * Reset plugin path | ||
14 | */ | ||
15 | function setUp() | ||
16 | { | ||
17 | PluginManager::$PLUGINS_PATH = 'plugins'; | ||
18 | } | ||
19 | |||
20 | /** | ||
21 | * Test Isso init without errors. | ||
22 | */ | ||
23 | function testWallabagInitNoError() | ||
24 | { | ||
25 | $conf = new ConfigManager(''); | ||
26 | $conf->set('plugins.ISSO_SERVER', 'value'); | ||
27 | $errors = isso_init($conf); | ||
28 | $this->assertEmpty($errors); | ||
29 | } | ||
30 | |||
31 | /** | ||
32 | * Test Isso init with errors. | ||
33 | */ | ||
34 | function testWallabagInitError() | ||
35 | { | ||
36 | $conf = new ConfigManager(''); | ||
37 | $errors = isso_init($conf); | ||
38 | $this->assertNotEmpty($errors); | ||
39 | } | ||
40 | |||
41 | /** | ||
42 | * Test render_linklist hook with valid settings to display the comment form. | ||
43 | */ | ||
44 | function testIssoDisplayed() | ||
45 | { | ||
46 | $conf = new ConfigManager(''); | ||
47 | $conf->set('plugins.ISSO_SERVER', 'value'); | ||
48 | |||
49 | $str = 'http://randomstr.com/test'; | ||
50 | $data = array( | ||
51 | 'title' => $str, | ||
52 | 'links' => array( | ||
53 | array( | ||
54 | 'url' => $str, | ||
55 | 'linkdate' => 'abc', | ||
56 | ) | ||
57 | ) | ||
58 | ); | ||
59 | |||
60 | $data = hook_isso_render_linklist($data, $conf); | ||
61 | |||
62 | // data shouldn't be altered | ||
63 | $this->assertEquals($str, $data['title']); | ||
64 | $this->assertEquals($str, $data['links'][0]['url']); | ||
65 | |||
66 | // plugin data | ||
67 | $this->assertEquals(1, count($data['plugin_end_zone'])); | ||
68 | $this->assertNotFalse(strpos($data['plugin_end_zone'][0], 'abc')); | ||
69 | $this->assertNotFalse(strpos($data['plugin_end_zone'][0], 'embed.min.js')); | ||
70 | } | ||
71 | |||
72 | /** | ||
73 | * Test isso plugin when multiple links are displayed (shouldn't be displayed). | ||
74 | */ | ||
75 | function testIssoMultipleLinks() | ||
76 | { | ||
77 | $conf = new ConfigManager(''); | ||
78 | $conf->set('plugins.ISSO_SERVER', 'value'); | ||
79 | |||
80 | $str = 'http://randomstr.com/test'; | ||
81 | $data = array( | ||
82 | 'title' => $str, | ||
83 | 'links' => array( | ||
84 | array( | ||
85 | 'url' => $str, | ||
86 | 'linkdate' => 'abc', | ||
87 | ), | ||
88 | array( | ||
89 | 'url' => $str . '2', | ||
90 | 'linkdate' => 'abc2', | ||
91 | ), | ||
92 | ) | ||
93 | ); | ||
94 | |||
95 | $processed = hook_isso_render_linklist($data, $conf); | ||
96 | // data shouldn't be altered | ||
97 | $this->assertEquals($data, $processed); | ||
98 | } | ||
99 | |||
100 | /** | ||
101 | * Test isso plugin when using search (shouldn't be displayed). | ||
102 | */ | ||
103 | function testIssoNotDisplayedWhenSearch() | ||
104 | { | ||
105 | $conf = new ConfigManager(''); | ||
106 | $conf->set('plugins.ISSO_SERVER', 'value'); | ||
107 | |||
108 | $str = 'http://randomstr.com/test'; | ||
109 | $data = array( | ||
110 | 'title' => $str, | ||
111 | 'links' => array( | ||
112 | array( | ||
113 | 'url' => $str, | ||
114 | 'linkdate' => 'abc', | ||
115 | ) | ||
116 | ), | ||
117 | 'search_term' => $str | ||
118 | ); | ||
119 | |||
120 | $processed = hook_isso_render_linklist($data, $conf); | ||
121 | |||
122 | // data shouldn't be altered | ||
123 | $this->assertEquals($data, $processed); | ||
124 | } | ||
125 | |||
126 | /** | ||
127 | * Test isso plugin without server configuration (shouldn't be displayed). | ||
128 | */ | ||
129 | function testIssoWithoutConf() | ||
130 | { | ||
131 | $data = 'abc'; | ||
132 | $conf = new ConfigManager(''); | ||
133 | $processed = hook_isso_render_linklist($data, $conf); | ||
134 | $this->assertEquals($data, $processed); | ||
135 | } | ||
136 | } | ||