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