]>
Commit | Line | Data |
---|---|---|
938d9cce | 1 | <?php |
95854417 | 2 | namespace Shaarli\Plugin\Wallabag; |
938d9cce | 3 | |
95854417 | 4 | use Shaarli\Plugin\Wallabag\WallabagInstance; |
938d9cce A |
5 | |
6 | /** | |
7 | * Class WallabagInstanceTest | |
8 | */ | |
95854417 | 9 | class WallabagInstanceTest extends \PHPUnit\Framework\TestCase |
938d9cce A |
10 | { |
11 | /** | |
12 | * @var string wallabag url. | |
13 | */ | |
14 | private $instance; | |
15 | ||
16 | /** | |
17 | * Reset plugin path | |
18 | */ | |
93b1fe54 | 19 | public function setUp() |
938d9cce A |
20 | { |
21 | $this->instance = 'http://some.url'; | |
22 | } | |
23 | ||
24 | /** | |
25 | * Test WallabagInstance with API V1. | |
26 | */ | |
93b1fe54 | 27 | public function testWallabagInstanceV1() |
938d9cce A |
28 | { |
29 | $instance = new WallabagInstance($this->instance, 1); | |
30 | $expected = $this->instance . '/?plainurl='; | |
31 | $result = $instance->getWallabagUrl(); | |
32 | $this->assertEquals($expected, $result); | |
33 | } | |
34 | ||
35 | /** | |
36 | * Test WallabagInstance with API V2. | |
37 | */ | |
93b1fe54 | 38 | public function testWallabagInstanceV2() |
938d9cce A |
39 | { |
40 | $instance = new WallabagInstance($this->instance, 2); | |
41 | $expected = $this->instance . '/bookmarklet?url='; | |
42 | $result = $instance->getWallabagUrl(); | |
43 | $this->assertEquals($expected, $result); | |
44 | } | |
45 | ||
46 | /** | |
47 | * Test WallabagInstance with an invalid API version. | |
48 | */ | |
93b1fe54 | 49 | public function testWallabagInstanceInvalidVersion() |
938d9cce A |
50 | { |
51 | $instance = new WallabagInstance($this->instance, false); | |
52 | $expected = $this->instance . '/?plainurl='; | |
53 | $result = $instance->getWallabagUrl(); | |
54 | $this->assertEquals($expected, $result); | |
55 | ||
56 | $instance = new WallabagInstance($this->instance, 3); | |
57 | $expected = $this->instance . '/?plainurl='; | |
58 | $result = $instance->getWallabagUrl(); | |
59 | $this->assertEquals($expected, $result); | |
60 | } | |
61 | } |