2015-12-22 10:20:27 +01:00
|
|
|
<?php
|
2018-12-04 23:17:23 +01:00
|
|
|
namespace Shaarli\Plugin\Wallabag;
|
2015-12-22 10:20:27 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Class WallabagInstanceTest
|
|
|
|
*/
|
2018-12-04 23:17:23 +01:00
|
|
|
class WallabagInstanceTest extends \PHPUnit\Framework\TestCase
|
2015-12-22 10:20:27 +01:00
|
|
|
{
|
|
|
|
/**
|
|
|
|
* @var string wallabag url.
|
|
|
|
*/
|
|
|
|
private $instance;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Reset plugin path
|
|
|
|
*/
|
2017-01-05 19:33:06 +01:00
|
|
|
public function setUp()
|
2015-12-22 10:20:27 +01:00
|
|
|
{
|
|
|
|
$this->instance = 'http://some.url';
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Test WallabagInstance with API V1.
|
|
|
|
*/
|
2017-01-05 19:33:06 +01:00
|
|
|
public function testWallabagInstanceV1()
|
2015-12-22 10:20:27 +01:00
|
|
|
{
|
|
|
|
$instance = new WallabagInstance($this->instance, 1);
|
|
|
|
$expected = $this->instance . '/?plainurl=';
|
|
|
|
$result = $instance->getWallabagUrl();
|
|
|
|
$this->assertEquals($expected, $result);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Test WallabagInstance with API V2.
|
|
|
|
*/
|
2017-01-05 19:33:06 +01:00
|
|
|
public function testWallabagInstanceV2()
|
2015-12-22 10:20:27 +01:00
|
|
|
{
|
|
|
|
$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.
|
|
|
|
*/
|
2017-01-05 19:33:06 +01:00
|
|
|
public function testWallabagInstanceInvalidVersion()
|
2015-12-22 10:20:27 +01:00
|
|
|
{
|
|
|
|
$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);
|
|
|
|
}
|
|
|
|
}
|