6 require_once 'plugins/qrcode/qrcode.php';
7 require_once 'application/Router.php';
10 * Class PluginQrcodeTest
11 * Unit test for the QR-Code plugin
13 class PluginQrcodeTest
extends PHPUnit_Framework_TestCase
18 public function setUp() {
19 PluginManager
::$PLUGINS_PATH = 'plugins';
23 * Test render_linklist hook.
25 public function testQrcodeLinklist()
27 $str = 'http://randomstr.com/test';
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']);
44 $this->assertEquals(1, count($link['link_plugin']));
45 $this->assertNotFalse(strpos($link['link_plugin'][0], $str));
49 * Test render_footer hook.
51 public function testQrcodeFooter()
54 $data = array($str => $str);
55 $data['_PAGE_'] = Router
::$PAGE_LINKLIST;
57 $data = hook_qrcode_render_footer($data);
58 $this->assertEquals($str, $data[$str]);
59 $this->assertEquals(1, count($data['js_files']));
61 $data = array($str => $str);
62 $data['_PAGE_'] = $str;
63 $this->assertEquals($str, $data[$str]);
64 $this->assertArrayNotHasKey('js_files', $data);