]> git.immae.eu Git - github/shaarli/Shaarli.git/blame - tests/plugins/PluginQrcodeTest.php
namespacing: \Shaarli\Router
[github/shaarli/Shaarli.git] / tests / plugins / PluginQrcodeTest.php
CommitLineData
abb3ff38 1<?php
abb3ff38 2/**
93b1fe54 3 * PluginQrcodeTest.php
abb3ff38
A
4 */
5
a932f486
V
6use Shaarli\Router;
7
abb3ff38
A
8require_once 'plugins/qrcode/qrcode.php';
9require_once 'application/Router.php';
10
11/**
93b1fe54 12 * Class PluginQrcodeTest
abb3ff38
A
13 * Unit test for the QR-Code plugin
14 */
93b1fe54 15class PluginQrcodeTest extends PHPUnit_Framework_TestCase
abb3ff38
A
16{
17 /**
18 * Reset plugin path
19 */
067c2dd8
V
20 public function setUp()
21 {
abb3ff38
A
22 PluginManager::$PLUGINS_PATH = 'plugins';
23 }
24
25 /**
26 * Test render_linklist hook.
27 */
93b1fe54 28 public function testQrcodeLinklist()
abb3ff38
A
29 {
30 $str = 'http://randomstr.com/test';
31 $data = array(
32 'title' => $str,
33 'links' => array(
34 array(
49e62f22 35 'url' => $str,
abb3ff38
A
36 )
37 )
38 );
39
40 $data = hook_qrcode_render_linklist($data);
41 $link = $data['links'][0];
42 // data shouldn't be altered
43 $this->assertEquals($str, $data['title']);
49e62f22 44 $this->assertEquals($str, $link['url']);
abb3ff38
A
45
46 // plugin data
47 $this->assertEquals(1, count($link['link_plugin']));
48 $this->assertNotFalse(strpos($link['link_plugin'][0], $str));
49 }
50
51 /**
52 * Test render_footer hook.
53 */
93b1fe54 54 public function testQrcodeFooter()
abb3ff38
A
55 {
56 $str = 'stuff';
57 $data = array($str => $str);
58 $data['_PAGE_'] = Router::$PAGE_LINKLIST;
59
60 $data = hook_qrcode_render_footer($data);
61 $this->assertEquals($str, $data[$str]);
62 $this->assertEquals(1, count($data['js_files']));
63
64 $data = array($str => $str);
65 $data['_PAGE_'] = $str;
66 $this->assertEquals($str, $data[$str]);
67 $this->assertArrayNotHasKey('js_files', $data);
68 }
69}