2 namespace Shaarli\Plugin\Qrcode
;
8 use Shaarli\Plugin\PluginManager
;
9 use Shaarli\Render\TemplatePage
;
11 require_once 'plugins/qrcode/qrcode.php';
14 * Class PluginQrcodeTest
15 * Unit test for the QR-Code plugin
17 class PluginQrcodeTest
extends \Shaarli\TestCase
22 protected function setUp(): void
24 PluginManager
::$PLUGINS_PATH = 'plugins';
28 * Test render_linklist hook.
30 public function testQrcodeLinklist()
32 $str = 'http://randomstr.com/test';
42 $data = hook_qrcode_render_linklist($data);
43 $link = $data['links'][0];
44 // data shouldn't be altered
45 $this->assertEquals($str, $data['title']);
46 $this->assertEquals($str, $link['url']);
49 $this->assertEquals(1, count($link['link_plugin']));
50 $this->assertNotFalse(strpos($link['link_plugin'][0], $str));
54 * Test render_footer hook.
56 public function testQrcodeFooter()
59 $data = array($str => $str);
60 $data['_PAGE_'] = TemplatePage
::LINKLIST
;
62 $data = hook_qrcode_render_footer($data);
63 $this->assertEquals($str, $data[$str]);
64 $this->assertEquals(1, count($data['js_files']));
66 $data = array($str => $str);
67 $data['_PAGE_'] = $str;
68 $this->assertEquals($str, $data[$str]);
69 $this->assertArrayNotHasKey('js_files', $data);