2 use Shaarli\Config\ConfigManager
;
4 require_once 'plugins/isso/isso.php';
9 * Test the Isso plugin (comment system).
11 class PluginIssoTest
extends PHPUnit_Framework_TestCase
16 public function setUp()
18 PluginManager
::$PLUGINS_PATH = 'plugins';
22 * Test Isso init without errors.
24 public function testWallabagInitNoError()
26 $conf = new ConfigManager('');
27 $conf->set('plugins.ISSO_SERVER', 'value');
28 $errors = isso_init($conf);
29 $this->assertEmpty($errors);
33 * Test Isso init with errors.
35 public function testWallabagInitError()
37 $conf = new ConfigManager('');
38 $errors = isso_init($conf);
39 $this->assertNotEmpty($errors);
43 * Test render_linklist hook with valid settings to display the comment form.
45 public function testIssoDisplayed()
47 $conf = new ConfigManager('');
48 $conf->set('plugins.ISSO_SERVER', 'value');
50 $str = 'http://randomstr.com/test';
51 $date = '20161118_100001';
58 'created' => DateTime
::createFromFormat(LinkDB
::LINK_DATE_FORMAT
, $date),
63 $data = hook_isso_render_linklist($data, $conf);
65 // data shouldn't be altered
66 $this->assertEquals($str, $data['title']);
67 $this->assertEquals($str, $data['links'][0]['url']);
70 $this->assertEquals(1, count($data['plugin_end_zone']));
71 $this->assertNotFalse(strpos(
72 $data['plugin_end_zone'][0],
73 'data-isso-id="'. $data['links'][0]['id'] .'"'
75 $this->assertNotFalse(strpos(
76 $data['plugin_end_zone'][0],
77 'data-title="'. $data['links'][0]['id'] .'"'
79 $this->assertNotFalse(strpos($data['plugin_end_zone'][0], 'embed.min.js'));
83 * Test isso plugin when multiple links are displayed (shouldn't be displayed).
85 public function testIssoMultipleLinks()
87 $conf = new ConfigManager('');
88 $conf->set('plugins.ISSO_SERVER', 'value');
90 $str = 'http://randomstr.com/test';
91 $date1 = '20161118_100001';
92 $date2 = '20161118_100002';
99 'created' => DateTime
::createFromFormat(LinkDB
::LINK_DATE_FORMAT
, $date1),
104 'created' => DateTime
::createFromFormat(LinkDB
::LINK_DATE_FORMAT
, $date2),
109 $processed = hook_isso_render_linklist($data, $conf);
110 // data shouldn't be altered
111 $this->assertEquals($data, $processed);
115 * Test isso plugin when using search (shouldn't be displayed).
117 public function testIssoNotDisplayedWhenSearch()
119 $conf = new ConfigManager('');
120 $conf->set('plugins.ISSO_SERVER', 'value');
122 $str = 'http://randomstr.com/test';
123 $date = '20161118_100001';
130 'created' => DateTime
::createFromFormat(LinkDB
::LINK_DATE_FORMAT
, $date),
133 'search_term' => $str
136 $processed = hook_isso_render_linklist($data, $conf);
138 // data shouldn't be altered
139 $this->assertEquals($data, $processed);
143 * Test isso plugin without server configuration (shouldn't be displayed).
145 public function testIssoWithoutConf()
148 $conf = new ConfigManager('');
149 $processed = hook_isso_render_linklist($data, $conf);
150 $this->assertEquals($data, $processed);