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