]>
Commit | Line | Data |
---|---|---|
b11c8f25 A |
1 | <?php |
2 | ||
3 | /** | |
4 | * PluginReadityourselfTest.php.php | |
5 | */ | |
6 | ||
7 | require_once 'plugins/readityourself/readityourself.php'; | |
8 | ||
9 | /** | |
10 | * Class PluginWallabagTest | |
11 | * Unit test for the Wallabag plugin | |
12 | */ | |
13 | class PluginReadityourselfTest extends PHPUnit_Framework_TestCase | |
14 | { | |
15 | /** | |
16 | * Reset plugin path | |
17 | */ | |
18 | function setUp() | |
19 | { | |
20 | PluginManager::$PLUGINS_PATH = 'plugins'; | |
21 | } | |
22 | ||
23 | /** | |
24 | * Test render_linklist hook. | |
25 | */ | |
26 | function testReadityourselfLinklist() | |
27 | { | |
eeea1c3d A |
28 | $conf = ConfigManager::getInstance(); |
29 | $conf->set('plugins.READITYOUSELF_URL', 'value'); | |
b11c8f25 A |
30 | $str = 'http://randomstr.com/test'; |
31 | $data = array( | |
32 | 'title' => $str, | |
33 | 'links' => array( | |
34 | array( | |
35 | 'url' => $str, | |
36 | ) | |
37 | ) | |
38 | ); | |
39 | ||
40 | $data = hook_readityourself_render_linklist($data); | |
41 | $link = $data['links'][0]; | |
42 | // data shouldn't be altered | |
43 | $this->assertEquals($str, $data['title']); | |
44 | $this->assertEquals($str, $link['url']); | |
45 | ||
46 | // plugin data | |
47 | $this->assertEquals(1, count($link['link_plugin'])); | |
48 | $this->assertNotFalse(strpos($link['link_plugin'][0], $str)); | |
49 | } | |
50 | ||
51 | /** | |
52 | * Test without config: nothing should happened. | |
53 | */ | |
54 | function testReadityourselfLinklistWithoutConfig() | |
55 | { | |
eeea1c3d A |
56 | $conf = ConfigManager::getInstance(); |
57 | $conf->set('plugins.READITYOUSELF_URL', null); | |
b11c8f25 A |
58 | $str = 'http://randomstr.com/test'; |
59 | $data = array( | |
60 | 'title' => $str, | |
61 | 'links' => array( | |
62 | array( | |
63 | 'url' => $str, | |
64 | ) | |
65 | ) | |
66 | ); | |
67 | ||
68 | $data = hook_readityourself_render_linklist($data); | |
69 | $link = $data['links'][0]; | |
70 | // data shouldn't be altered | |
71 | $this->assertEquals($str, $data['title']); | |
72 | $this->assertEquals($str, $link['url']); | |
73 | ||
74 | // plugin data | |
75 | $this->assertArrayNotHasKey('link_plugin', $link); | |
76 | } | |
77 | } |