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