]> git.immae.eu Git - github/shaarli/Shaarli.git/blame - tests/plugins/PluginWallabagTest.php
namespacing: add plugin tests to \Shaarli\Plugin\[...]
[github/shaarli/Shaarli.git] / tests / plugins / PluginWallabagTest.php
CommitLineData
1696f6aa 1<?php
95854417
V
2namespace Shaarli\Plugin\Wallabag;
3
3c66e564 4use Shaarli\Config\ConfigManager;
e1850388 5use Shaarli\Plugin\PluginManager;
1696f6aa 6
1696f6aa
A
7require_once 'plugins/wallabag/wallabag.php';
8
9/**
10 * Class PluginWallabagTest
11 * Unit test for the Wallabag plugin
12 */
e1850388 13class PluginWallabagTest extends \PHPUnit\Framework\TestCase
1696f6aa
A
14{
15 /**
16 * Reset plugin path
17 */
93b1fe54 18 public function setUp()
1696f6aa
A
19 {
20 PluginManager::$PLUGINS_PATH = 'plugins';
21 }
22
7fde6de1
A
23 /**
24 * Test wallabag init without errors.
25 */
93b1fe54 26 public function testWallabagInitNoError()
7fde6de1
A
27 {
28 $conf = new ConfigManager('');
29 $conf->set('plugins.WALLABAG_URL', 'value');
30 $errors = wallabag_init($conf);
31 $this->assertEmpty($errors);
32 }
33
34 /**
35 * Test wallabag init with errors.
36 */
93b1fe54 37 public function testWallabagInitError()
7fde6de1
A
38 {
39 $conf = new ConfigManager('');
40 $errors = wallabag_init($conf);
41 $this->assertNotEmpty($errors);
42 }
43
1696f6aa
A
44 /**
45 * Test render_linklist hook.
46 */
93b1fe54 47 public function testWallabagLinklist()
1696f6aa 48 {
51def0d8 49 $conf = new ConfigManager('');
eeea1c3d 50 $conf->set('plugins.WALLABAG_URL', 'value');
1696f6aa
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_wallabag_render_linklist($data, $conf);
1696f6aa
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']));
938d9cce 69 $this->assertNotFalse(strpos($link['link_plugin'][0], urlencode($str)));
eeea1c3d 70 $this->assertNotFalse(strpos($link['link_plugin'][0], $conf->get('plugins.WALLABAG_URL')));
1696f6aa
A
71 }
72}