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