aboutsummaryrefslogtreecommitdiffhomepage
path: root/tests/plugins/WallabagInstanceTest.php
blob: 2c46687100c13495408e80ac68dc31523283fd78 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
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
     */
    public function setUp()
    {
        $this->instance = 'http://some.url';
    }

    /**
     * Test WallabagInstance with API V1.
     */
    public function testWallabagInstanceV1()
    {
        $instance = new WallabagInstance($this->instance, 1);
        $expected = $this->instance . '/?plainurl=';
        $result = $instance->getWallabagUrl();
        $this->assertEquals($expected, $result);
    }

    /**
     * Test WallabagInstance with API V2.
     */
    public 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.
     */
    public 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);
    }
}