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';
57 'created' => DateTime
::createFromFormat(LinkDB
::LINK_DATE_FORMAT
, $date),
62 $data = hook_isso_render_linklist($data, $conf);
64 // data shouldn't be altered
65 $this->assertEquals($str, $data['title']);
66 $this->assertEquals($str, $data['links'][0]['url']);
69 $this->assertEquals(1, count($data['plugin_end_zone']));
70 $this->assertNotFalse(strpos(
71 $data['plugin_end_zone'][0],
72 'data-isso-id="'. $data['links'][0]['id'] .'"'
74 $this->assertNotFalse(strpos(
75 $data['plugin_end_zone'][0],
76 'data-title="'. $data['links'][0]['id'] .'"'
78 $this->assertNotFalse(strpos($data['plugin_end_zone'][0], 'embed.min.js'));
82 * Test isso plugin when multiple links are displayed (shouldn't be displayed).
84 function testIssoMultipleLinks()
86 $conf = new ConfigManager('');
87 $conf->set('plugins.ISSO_SERVER', 'value');
89 $str = 'http://randomstr.com/test';
90 $date1 = '20161118_100001';
91 $date2 = '20161118_100002';
98 'created' => DateTime
::createFromFormat(LinkDB
::LINK_DATE_FORMAT
, $date1),
103 'created' => DateTime
::createFromFormat(LinkDB
::LINK_DATE_FORMAT
, $date2),
108 $processed = hook_isso_render_linklist($data, $conf);
109 // data shouldn't be altered
110 $this->assertEquals($data, $processed);
114 * Test isso plugin when using search (shouldn't be displayed).
116 function testIssoNotDisplayedWhenSearch()
118 $conf = new ConfigManager('');
119 $conf->set('plugins.ISSO_SERVER', 'value');
121 $str = 'http://randomstr.com/test';
122 $date = '20161118_100001';
129 'created' => DateTime
::createFromFormat(LinkDB
::LINK_DATE_FORMAT
, $date),
132 'search_term' => $str
135 $processed = hook_isso_render_linklist($data, $conf);
137 // data shouldn't be altered
138 $this->assertEquals($data, $processed);
142 * Test isso plugin without server configuration (shouldn't be displayed).
144 function testIssoWithoutConf()
147 $conf = new ConfigManager('');
148 $processed = hook_isso_render_linklist($data, $conf);
149 $this->assertEquals($data, $processed);