diff options
author | Arthur <arthur@hoa.ro> | 2016-10-18 08:14:09 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2016-10-18 08:14:09 +0200 |
commit | c1c21028503f2c05206481b2b0cb7ac8d6c16a71 (patch) | |
tree | be74b08810c6160ab0e85863febd9605201b7ad9 /tests | |
parent | 8406a4b670957b7d0450f6ea5e4f2e61c7114e8f (diff) | |
parent | bf26e7ebcb5ee69523b93a5ec7b7a65b39acb916 (diff) | |
download | Shaarli-c1c21028503f2c05206481b2b0cb7ac8d6c16a71.tar.gz Shaarli-c1c21028503f2c05206481b2b0cb7ac8d6c16a71.tar.zst Shaarli-c1c21028503f2c05206481b2b0cb7ac8d6c16a71.zip |
Merge pull request #651 from ArthurHoaro/plugin-isso2
Isso comments plugin
Diffstat (limited to 'tests')
-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 | } | ||