Wallabag plugin improvement
* Fixes a bug where URL weren't properly encoded. * Adds Wallabag V2 support. * Adds a URL function to handle trailing slash. * UT. * README updated.
This commit is contained in:
parent
79851b4890
commit
938d9cce77
9 changed files with 194 additions and 11 deletions
tests
|
@ -145,4 +145,15 @@ class UrlTest extends PHPUnit_Framework_TestCase
|
|||
$url = new Url('git://domain.tld/push?pull=clone#checkout');
|
||||
$this->assertEquals('git', $url->getScheme());
|
||||
}
|
||||
|
||||
/**
|
||||
* Test add trailing slash.
|
||||
*/
|
||||
function testAddTrailingSlash()
|
||||
{
|
||||
$strOn = 'http://randomstr.com/test/';
|
||||
$strOff = 'http://randomstr.com/test';
|
||||
$this->assertEquals($strOn, add_trailing_slash($strOn));
|
||||
$this->assertEquals($strOn, add_trailing_slash($strOff));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -44,6 +44,8 @@ class PluginWallabagTest extends PHPUnit_Framework_TestCase
|
|||
|
||||
// plugin data
|
||||
$this->assertEquals(1, count($link['link_plugin']));
|
||||
$this->assertNotFalse(strpos($link['link_plugin'][0], $str));
|
||||
$this->assertNotFalse(strpos($link['link_plugin'][0], urlencode($str)));
|
||||
$this->assertNotFalse(strpos($link['link_plugin'][0], $GLOBALS['plugins']['WALLABAG_URL']));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
60
tests/plugins/WallabagInstanceTest.php
Normal file
60
tests/plugins/WallabagInstanceTest.php
Normal file
|
@ -0,0 +1,60 @@
|
|||
<?php
|
||||
|
||||
require_once 'plugins/wallabag/WallabagInstance.php';
|
||||
|
||||
/**
|
||||
* Class WallabagInstanceTest
|
||||
*/
|
||||
class WallabagInstanceTest extends PHPUnit_Framework_TestCase
|
||||
{
|
||||
/**
|
||||
* @var string wallabag url.
|
||||
*/
|
||||
private $instance;
|
||||
|
||||
/**
|
||||
* Reset plugin path
|
||||
*/
|
||||
function setUp()
|
||||
{
|
||||
$this->instance = 'http://some.url';
|
||||
}
|
||||
|
||||
/**
|
||||
* Test WallabagInstance with API V1.
|
||||
*/
|
||||
function testWallabagInstanceV1()
|
||||
{
|
||||
$instance = new WallabagInstance($this->instance, 1);
|
||||
$expected = $this->instance . '/?plainurl=';
|
||||
$result = $instance->getWallabagUrl();
|
||||
$this->assertEquals($expected, $result);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test WallabagInstance with API V2.
|
||||
*/
|
||||
function testWallabagInstanceV2()
|
||||
{
|
||||
$instance = new WallabagInstance($this->instance, 2);
|
||||
$expected = $this->instance . '/bookmarklet?url=';
|
||||
$result = $instance->getWallabagUrl();
|
||||
$this->assertEquals($expected, $result);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test WallabagInstance with an invalid API version.
|
||||
*/
|
||||
function testWallabagInstanceInvalidVersion()
|
||||
{
|
||||
$instance = new WallabagInstance($this->instance, false);
|
||||
$expected = $this->instance . '/?plainurl=';
|
||||
$result = $instance->getWallabagUrl();
|
||||
$this->assertEquals($expected, $result);
|
||||
|
||||
$instance = new WallabagInstance($this->instance, 3);
|
||||
$expected = $this->instance . '/?plainurl=';
|
||||
$result = $instance->getWallabagUrl();
|
||||
$this->assertEquals($expected, $result);
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue