]> git.immae.eu Git - github/shaarli/Shaarli.git/blame - tests/plugins/PluginWallabagTest.php
doc: note about firefox share compatibility
[github/shaarli/Shaarli.git] / tests / plugins / PluginWallabagTest.php
CommitLineData
1696f6aa 1<?php
3c66e564 2use Shaarli\Config\ConfigManager;
1696f6aa
A
3
4/**
5 * PluginWallabagTest.php.php
6 */
7
8require_once 'plugins/wallabag/wallabag.php';
9
10/**
11 * Class PluginWallabagTest
12 * Unit test for the Wallabag plugin
13 */
14class PluginWallabagTest extends PHPUnit_Framework_TestCase
15{
16 /**
17 * Reset plugin path
18 */
93b1fe54 19 public function setUp()
1696f6aa
A
20 {
21 PluginManager::$PLUGINS_PATH = 'plugins';
22 }
23
7fde6de1
A
24 /**
25 * Test wallabag init without errors.
26 */
93b1fe54 27 public function testWallabagInitNoError()
7fde6de1
A
28 {
29 $conf = new ConfigManager('');
30 $conf->set('plugins.WALLABAG_URL', 'value');
31 $errors = wallabag_init($conf);
32 $this->assertEmpty($errors);
33 }
34
35 /**
36 * Test wallabag init with errors.
37 */
93b1fe54 38 public function testWallabagInitError()
7fde6de1
A
39 {
40 $conf = new ConfigManager('');
41 $errors = wallabag_init($conf);
42 $this->assertNotEmpty($errors);
43 }
44
1696f6aa
A
45 /**
46 * Test render_linklist hook.
47 */
93b1fe54 48 public function testWallabagLinklist()
1696f6aa 49 {
51def0d8 50 $conf = new ConfigManager('');
eeea1c3d 51 $conf->set('plugins.WALLABAG_URL', 'value');
1696f6aa
A
52 $str = 'http://randomstr.com/test';
53 $data = array(
54 'title' => $str,
55 'links' => array(
56 array(
57 'url' => $str,
58 )
59 )
60 );
61
51def0d8 62 $data = hook_wallabag_render_linklist($data, $conf);
1696f6aa
A
63 $link = $data['links'][0];
64 // data shouldn't be altered
65 $this->assertEquals($str, $data['title']);
66 $this->assertEquals($str, $link['url']);
67
68 // plugin data
69 $this->assertEquals(1, count($link['link_plugin']));
938d9cce 70 $this->assertNotFalse(strpos($link['link_plugin'][0], urlencode($str)));
eeea1c3d 71 $this->assertNotFalse(strpos($link['link_plugin'][0], $conf->get('plugins.WALLABAG_URL')));
1696f6aa
A
72 }
73}