diff options
Diffstat (limited to 'tests/plugins')
-rw-r--r-- | tests/plugins/PlugQrcodeTest.php | 4 | ||||
-rw-r--r-- | tests/plugins/PluginWallabagTest.php | 4 | ||||
-rw-r--r-- | tests/plugins/WallabagInstanceTest.php | 60 |
3 files changed, 65 insertions, 3 deletions
diff --git a/tests/plugins/PlugQrcodeTest.php b/tests/plugins/PlugQrcodeTest.php index c749fa86..86dc7f29 100644 --- a/tests/plugins/PlugQrcodeTest.php +++ b/tests/plugins/PlugQrcodeTest.php | |||
@@ -30,7 +30,7 @@ class PlugQrcodeTest extends PHPUnit_Framework_TestCase | |||
30 | 'title' => $str, | 30 | 'title' => $str, |
31 | 'links' => array( | 31 | 'links' => array( |
32 | array( | 32 | array( |
33 | 'real_url' => $str, | 33 | 'url' => $str, |
34 | ) | 34 | ) |
35 | ) | 35 | ) |
36 | ); | 36 | ); |
@@ -39,7 +39,7 @@ class PlugQrcodeTest extends PHPUnit_Framework_TestCase | |||
39 | $link = $data['links'][0]; | 39 | $link = $data['links'][0]; |
40 | // data shouldn't be altered | 40 | // data shouldn't be altered |
41 | $this->assertEquals($str, $data['title']); | 41 | $this->assertEquals($str, $data['title']); |
42 | $this->assertEquals($str, $link['real_url']); | 42 | $this->assertEquals($str, $link['url']); |
43 | 43 | ||
44 | // plugin data | 44 | // plugin data |
45 | $this->assertEquals(1, count($link['link_plugin'])); | 45 | $this->assertEquals(1, count($link['link_plugin'])); |
diff --git a/tests/plugins/PluginWallabagTest.php b/tests/plugins/PluginWallabagTest.php index 7cc83f4f..5d3a60e0 100644 --- a/tests/plugins/PluginWallabagTest.php +++ b/tests/plugins/PluginWallabagTest.php | |||
@@ -44,6 +44,8 @@ class PluginWallabagTest extends PHPUnit_Framework_TestCase | |||
44 | 44 | ||
45 | // plugin data | 45 | // plugin data |
46 | $this->assertEquals(1, count($link['link_plugin'])); | 46 | $this->assertEquals(1, count($link['link_plugin'])); |
47 | $this->assertNotFalse(strpos($link['link_plugin'][0], $str)); | 47 | $this->assertNotFalse(strpos($link['link_plugin'][0], urlencode($str))); |
48 | $this->assertNotFalse(strpos($link['link_plugin'][0], $GLOBALS['plugins']['WALLABAG_URL'])); | ||
48 | } | 49 | } |
49 | } | 50 | } |
51 | |||
diff --git a/tests/plugins/WallabagInstanceTest.php b/tests/plugins/WallabagInstanceTest.php new file mode 100644 index 00000000..7c14c1df --- /dev/null +++ b/tests/plugins/WallabagInstanceTest.php | |||
@@ -0,0 +1,60 @@ | |||
1 | <?php | ||
2 | |||
3 | require_once 'plugins/wallabag/WallabagInstance.php'; | ||
4 | |||
5 | /** | ||
6 | * Class WallabagInstanceTest | ||
7 | */ | ||
8 | class WallabagInstanceTest extends PHPUnit_Framework_TestCase | ||
9 | { | ||
10 | /** | ||
11 | * @var string wallabag url. | ||
12 | */ | ||
13 | private $instance; | ||
14 | |||
15 | /** | ||
16 | * Reset plugin path | ||
17 | */ | ||
18 | function setUp() | ||
19 | { | ||
20 | $this->instance = 'http://some.url'; | ||
21 | } | ||
22 | |||
23 | /** | ||
24 | * Test WallabagInstance with API V1. | ||
25 | */ | ||
26 | function testWallabagInstanceV1() | ||
27 | { | ||
28 | $instance = new WallabagInstance($this->instance, 1); | ||
29 | $expected = $this->instance . '/?plainurl='; | ||
30 | $result = $instance->getWallabagUrl(); | ||
31 | $this->assertEquals($expected, $result); | ||
32 | } | ||
33 | |||
34 | /** | ||
35 | * Test WallabagInstance with API V2. | ||
36 | */ | ||
37 | function testWallabagInstanceV2() | ||
38 | { | ||
39 | $instance = new WallabagInstance($this->instance, 2); | ||
40 | $expected = $this->instance . '/bookmarklet?url='; | ||
41 | $result = $instance->getWallabagUrl(); | ||
42 | $this->assertEquals($expected, $result); | ||
43 | } | ||
44 | |||
45 | /** | ||
46 | * Test WallabagInstance with an invalid API version. | ||
47 | */ | ||
48 | function testWallabagInstanceInvalidVersion() | ||
49 | { | ||
50 | $instance = new WallabagInstance($this->instance, false); | ||
51 | $expected = $this->instance . '/?plainurl='; | ||
52 | $result = $instance->getWallabagUrl(); | ||
53 | $this->assertEquals($expected, $result); | ||
54 | |||
55 | $instance = new WallabagInstance($this->instance, 3); | ||
56 | $expected = $this->instance . '/?plainurl='; | ||
57 | $result = $instance->getWallabagUrl(); | ||
58 | $this->assertEquals($expected, $result); | ||
59 | } | ||
60 | } | ||