2 use Shaarli\Config\ConfigManager
;
3 use Shaarli\Plugin\PluginManager
;
6 * PluginWallabagTest.php.php
9 require_once 'plugins/wallabag/wallabag.php';
12 * Class PluginWallabagTest
13 * Unit test for the Wallabag plugin
15 class PluginWallabagTest
extends \PHPUnit\Framework\TestCase
20 public function setUp()
22 PluginManager
::$PLUGINS_PATH = 'plugins';
26 * Test wallabag init without errors.
28 public function testWallabagInitNoError()
30 $conf = new ConfigManager('');
31 $conf->set('plugins.WALLABAG_URL', 'value');
32 $errors = wallabag_init($conf);
33 $this->assertEmpty($errors);
37 * Test wallabag init with errors.
39 public function testWallabagInitError()
41 $conf = new ConfigManager('');
42 $errors = wallabag_init($conf);
43 $this->assertNotEmpty($errors);
47 * Test render_linklist hook.
49 public function testWallabagLinklist()
51 $conf = new ConfigManager('');
52 $conf->set('plugins.WALLABAG_URL', 'value');
53 $str = 'http://randomstr.com/test';
63 $data = hook_wallabag_render_linklist($data, $conf);
64 $link = $data['links'][0];
65 // data shouldn't be altered
66 $this->assertEquals($str, $data['title']);
67 $this->assertEquals($str, $link['url']);
70 $this->assertEquals(1, count($link['link_plugin']));
71 $this->assertNotFalse(strpos($link['link_plugin'][0], urlencode($str)));
72 $this->assertNotFalse(strpos($link['link_plugin'][0], $conf->get('plugins.WALLABAG_URL')));