MyShaarli/tests/plugins/WallabagInstanceTest.php
ArthurHoaro 938d9cce77 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.
2015-12-27 15:30:34 +01:00

60 lines
1.5 KiB
PHP

<?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);
}
}