7 require_once 'plugins/qrcode/qrcode.php';
8 require_once 'application/Router.php';
11 * Class PlugQrcodeTest
12 * Unit test for the QR-Code plugin
14 class PlugQrcodeTest
extends PHPUnit_Framework_TestCase
20 PluginManager
::$PLUGINS_PATH = 'plugins';
24 * Test render_linklist hook.
26 function testQrcodeLinklist()
28 $str = 'http://randomstr.com/test';
38 $data = hook_qrcode_render_linklist($data);
39 $link = $data['links'][0];
40 // data shouldn't be altered
41 $this->assertEquals($str, $data['title']);
42 $this->assertEquals($str, $link['url']);
45 $this->assertEquals(1, count($link['link_plugin']));
46 $this->assertNotFalse(strpos($link['link_plugin'][0], $str));
50 * Test render_footer hook.
52 function testQrcodeFooter()
55 $data = array($str => $str);
56 $data['_PAGE_'] = Router
::$PAGE_LINKLIST;
58 $data = hook_qrcode_render_footer($data);
59 $this->assertEquals($str, $data[$str]);
60 $this->assertEquals(1, count($data['js_files']));
62 $data = array($str => $str);
63 $data['_PAGE_'] = $str;
64 $this->assertEquals($str, $data[$str]);
65 $this->assertArrayNotHasKey('js_files', $data);