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