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