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