3 require_once 'plugins/isso/isso.php';
8 * Test the Isso plugin (comment system).
10 class PluginIssoTest
extends PHPUnit_Framework_TestCase
17 PluginManager
::$PLUGINS_PATH = 'plugins';
21 * Test Isso init without errors.
23 function testWallabagInitNoError()
25 $conf = new ConfigManager('');
26 $conf->set('plugins.ISSO_SERVER', 'value');
27 $errors = isso_init($conf);
28 $this->assertEmpty($errors);
32 * Test Isso init with errors.
34 function testWallabagInitError()
36 $conf = new ConfigManager('');
37 $errors = isso_init($conf);
38 $this->assertNotEmpty($errors);
42 * Test render_linklist hook with valid settings to display the comment form.
44 function testIssoDisplayed()
46 $conf = new ConfigManager('');
47 $conf->set('plugins.ISSO_SERVER', 'value');
49 $str = 'http://randomstr.com/test';
50 $date = '20161118_100001';
56 'created' => DateTime
::createFromFormat('Ymd_His', $date),
61 $data = hook_isso_render_linklist($data, $conf);
63 // data shouldn't be altered
64 $this->assertEquals($str, $data['title']);
65 $this->assertEquals($str, $data['links'][0]['url']);
68 $this->assertEquals(1, count($data['plugin_end_zone']));
69 $this->assertNotFalse(strpos($data['plugin_end_zone'][0], $date));
70 $this->assertNotFalse(strpos($data['plugin_end_zone'][0], 'embed.min.js'));
74 * Test isso plugin when multiple links are displayed (shouldn't be displayed).
76 function testIssoMultipleLinks()
78 $conf = new ConfigManager('');
79 $conf->set('plugins.ISSO_SERVER', 'value');
81 $str = 'http://randomstr.com/test';
82 $date1 = '20161118_100001';
83 $date2 = '20161118_100002';
89 'created' => DateTime
::createFromFormat('Ymd_His', $date1),
93 'created' => DateTime
::createFromFormat('Ymd_His', $date2),
98 $processed = hook_isso_render_linklist($data, $conf);
99 // data shouldn't be altered
100 $this->assertEquals($data, $processed);
104 * Test isso plugin when using search (shouldn't be displayed).
106 function testIssoNotDisplayedWhenSearch()
108 $conf = new ConfigManager('');
109 $conf->set('plugins.ISSO_SERVER', 'value');
111 $str = 'http://randomstr.com/test';
112 $date = '20161118_100001';
118 'created' => DateTime
::createFromFormat('Ymd_His', $date),
121 'search_term' => $str
124 $processed = hook_isso_render_linklist($data, $conf);
126 // data shouldn't be altered
127 $this->assertEquals($data, $processed);
131 * Test isso plugin without server configuration (shouldn't be displayed).
133 function testIssoWithoutConf()
136 $conf = new ConfigManager('');
137 $processed = hook_isso_render_linklist($data, $conf);
138 $this->assertEquals($data, $processed);