2 use Shaarli\Config\ConfigManager
;
5 * PluginReadityourselfTest.php.php
8 require_once 'plugins/readityourself/readityourself.php';
11 * Class PluginWallabagTest
12 * Unit test for the Wallabag plugin
14 class PluginReadityourselfTest
extends PHPUnit_Framework_TestCase
19 public function setUp()
21 PluginManager
::$PLUGINS_PATH = 'plugins';
25 * Test Readityourself init without errors.
27 public function testReadityourselfInitNoError()
29 $conf = new ConfigManager('');
30 $conf->set('plugins.READITYOUSELF_URL', 'value');
31 $errors = readityourself_init($conf);
32 $this->assertEmpty($errors);
36 * Test Readityourself init with errors.
38 public function testReadityourselfInitError()
40 $conf = new ConfigManager('');
41 $errors = readityourself_init($conf);
42 $this->assertNotEmpty($errors);
46 * Test render_linklist hook.
48 public function testReadityourselfLinklist()
50 $conf = new ConfigManager('');
51 $conf->set('plugins.READITYOUSELF_URL', 'value');
52 $str = 'http://randomstr.com/test';
62 $data = hook_readityourself_render_linklist($data, $conf);
63 $link = $data['links'][0];
64 // data shouldn't be altered
65 $this->assertEquals($str, $data['title']);
66 $this->assertEquals($str, $link['url']);
69 $this->assertEquals(1, count($link['link_plugin']));
70 $this->assertNotFalse(strpos($link['link_plugin'][0], $str));
74 * Test without config: nothing should happened.
76 public function testReadityourselfLinklistWithoutConfig()
78 $conf = new ConfigManager('');
79 $conf->set('plugins.READITYOUSELF_URL', null);
80 $str = 'http://randomstr.com/test';
90 $data = hook_readityourself_render_linklist($data, $conf);
91 $link = $data['links'][0];
92 // data shouldn't be altered
93 $this->assertEquals($str, $data['title']);
94 $this->assertEquals($str, $link['url']);
97 $this->assertArrayNotHasKey('link_plugin', $link);