]> git.immae.eu Git - github/shaarli/Shaarli.git/blame - tests/plugins/PluginReadityourselfTest.php
New init function for plugins, supports errors reporting
[github/shaarli/Shaarli.git] / tests / plugins / PluginReadityourselfTest.php
CommitLineData
b11c8f25
A
1<?php
2
3/**
4 * PluginReadityourselfTest.php.php
5 */
6
7require_once 'plugins/readityourself/readityourself.php';
8
9/**
10 * Class PluginWallabagTest
11 * Unit test for the Wallabag plugin
12 */
13class PluginReadityourselfTest extends PHPUnit_Framework_TestCase
14{
15 /**
16 * Reset plugin path
17 */
18 function setUp()
19 {
20 PluginManager::$PLUGINS_PATH = 'plugins';
21 }
22
7fde6de1
A
23 /**
24 * Test Readityourself init without errors.
25 */
26 function testReadityourselfInitNoError()
27 {
28 $conf = new ConfigManager('');
29 $conf->set('plugins.READITYOUSELF_URL', 'value');
30 $errors = readityourself_init($conf);
31 $this->assertEmpty($errors);
32 }
33
34 /**
35 * Test Readityourself init with errors.
36 */
37 function testReadityourselfInitError()
38 {
39 $conf = new ConfigManager('');
40 $errors = readityourself_init($conf);
41 $this->assertNotEmpty($errors);
42 }
43
b11c8f25
A
44 /**
45 * Test render_linklist hook.
46 */
47 function testReadityourselfLinklist()
48 {
51def0d8 49 $conf = new ConfigManager('');
eeea1c3d 50 $conf->set('plugins.READITYOUSELF_URL', 'value');
b11c8f25
A
51 $str = 'http://randomstr.com/test';
52 $data = array(
53 'title' => $str,
54 'links' => array(
55 array(
56 'url' => $str,
57 )
58 )
59 );
60
51def0d8 61 $data = hook_readityourself_render_linklist($data, $conf);
b11c8f25
A
62 $link = $data['links'][0];
63 // data shouldn't be altered
64 $this->assertEquals($str, $data['title']);
65 $this->assertEquals($str, $link['url']);
66
67 // plugin data
68 $this->assertEquals(1, count($link['link_plugin']));
69 $this->assertNotFalse(strpos($link['link_plugin'][0], $str));
70 }
71
72 /**
73 * Test without config: nothing should happened.
74 */
75 function testReadityourselfLinklistWithoutConfig()
76 {
51def0d8 77 $conf = new ConfigManager('');
eeea1c3d 78 $conf->set('plugins.READITYOUSELF_URL', null);
b11c8f25
A
79 $str = 'http://randomstr.com/test';
80 $data = array(
81 'title' => $str,
82 'links' => array(
83 array(
84 'url' => $str,
85 )
86 )
87 );
88
51def0d8 89 $data = hook_readityourself_render_linklist($data, $conf);
b11c8f25
A
90 $link = $data['links'][0];
91 // data shouldn't be altered
92 $this->assertEquals($str, $data['title']);
93 $this->assertEquals($str, $link['url']);
94
95 // plugin data
96 $this->assertArrayNotHasKey('link_plugin', $link);
97 }
98}