6 use Shaarli\Plugin\PluginManager
;
9 require_once 'plugins/qrcode/qrcode.php';
10 require_once 'application/Router.php';
13 * Class PluginQrcodeTest
14 * Unit test for the QR-Code plugin
16 class PluginQrcodeTest
extends PHPUnit_Framework_TestCase
21 public function setUp()
23 PluginManager
::$PLUGINS_PATH = 'plugins';
27 * Test render_linklist hook.
29 public function testQrcodeLinklist()
31 $str = 'http://randomstr.com/test';
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']);
48 $this->assertEquals(1, count($link['link_plugin']));
49 $this->assertNotFalse(strpos($link['link_plugin'][0], $str));
53 * Test render_footer hook.
55 public function testQrcodeFooter()
58 $data = array($str => $str);
59 $data['_PAGE_'] = Router
::$PAGE_LINKLIST;
61 $data = hook_qrcode_render_footer($data);
62 $this->assertEquals($str, $data[$str]);
63 $this->assertEquals(1, count($data['js_files']));
65 $data = array($str => $str);
66 $data['_PAGE_'] = $str;
67 $this->assertEquals($str, $data[$str]);
68 $this->assertArrayNotHasKey('js_files', $data);