2015-11-08 12:00:06 +01:00
|
|
|
<?php
|
|
|
|
|
|
|
|
/**
|
|
|
|
* PluginWallabagTest.php.php
|
|
|
|
*/
|
|
|
|
|
|
|
|
require_once 'plugins/wallabag/wallabag.php';
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Class PluginWallabagTest
|
|
|
|
* Unit test for the Wallabag plugin
|
|
|
|
*/
|
|
|
|
class PluginWallabagTest extends PHPUnit_Framework_TestCase
|
|
|
|
{
|
|
|
|
/**
|
|
|
|
* Reset plugin path
|
|
|
|
*/
|
2017-01-05 19:33:06 +01:00
|
|
|
public function setUp()
|
2015-11-08 12:00:06 +01:00
|
|
|
{
|
|
|
|
PluginManager::$PLUGINS_PATH = 'plugins';
|
|
|
|
}
|
|
|
|
|
2016-10-14 13:22:58 +02:00
|
|
|
/**
|
|
|
|
* Test wallabag init without errors.
|
|
|
|
*/
|
2017-01-05 19:33:06 +01:00
|
|
|
public function testWallabagInitNoError()
|
2016-10-14 13:22:58 +02:00
|
|
|
{
|
|
|
|
$conf = new ConfigManager('');
|
|
|
|
$conf->set('plugins.WALLABAG_URL', 'value');
|
|
|
|
$errors = wallabag_init($conf);
|
|
|
|
$this->assertEmpty($errors);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Test wallabag init with errors.
|
|
|
|
*/
|
2017-01-05 19:33:06 +01:00
|
|
|
public function testWallabagInitError()
|
2016-10-14 13:22:58 +02:00
|
|
|
{
|
|
|
|
$conf = new ConfigManager('');
|
|
|
|
$errors = wallabag_init($conf);
|
|
|
|
$this->assertNotEmpty($errors);
|
|
|
|
}
|
|
|
|
|
2015-11-08 12:00:06 +01:00
|
|
|
/**
|
|
|
|
* Test render_linklist hook.
|
|
|
|
*/
|
2017-01-05 19:33:06 +01:00
|
|
|
public function testWallabagLinklist()
|
2015-11-08 12:00:06 +01:00
|
|
|
{
|
2016-06-09 20:04:32 +02:00
|
|
|
$conf = new ConfigManager('');
|
2016-05-29 14:41:30 +02:00
|
|
|
$conf->set('plugins.WALLABAG_URL', 'value');
|
2015-11-08 12:00:06 +01:00
|
|
|
$str = 'http://randomstr.com/test';
|
|
|
|
$data = array(
|
|
|
|
'title' => $str,
|
|
|
|
'links' => array(
|
|
|
|
array(
|
|
|
|
'url' => $str,
|
|
|
|
)
|
|
|
|
)
|
|
|
|
);
|
|
|
|
|
2016-06-09 20:04:32 +02:00
|
|
|
$data = hook_wallabag_render_linklist($data, $conf);
|
2015-11-08 12:00:06 +01:00
|
|
|
$link = $data['links'][0];
|
|
|
|
// data shouldn't be altered
|
|
|
|
$this->assertEquals($str, $data['title']);
|
|
|
|
$this->assertEquals($str, $link['url']);
|
|
|
|
|
|
|
|
// plugin data
|
|
|
|
$this->assertEquals(1, count($link['link_plugin']));
|
2015-12-22 10:20:27 +01:00
|
|
|
$this->assertNotFalse(strpos($link['link_plugin'][0], urlencode($str)));
|
2016-05-29 14:41:30 +02:00
|
|
|
$this->assertNotFalse(strpos($link['link_plugin'][0], $conf->get('plugins.WALLABAG_URL')));
|
2015-11-08 12:00:06 +01:00
|
|
|
}
|
|
|
|
}
|