]> git.immae.eu Git - github/shaarli/Shaarli.git/blame_incremental - tests/plugins/PluginQrcodeTest.php
Fix: soft fail if the mutex is not working
[github/shaarli/Shaarli.git] / tests / plugins / PluginQrcodeTest.php
... / ...
CommitLineData
1<?php
2namespace Shaarli\Plugin\Qrcode;
3
4/**
5 * PluginQrcodeTest.php
6 */
7
8use Shaarli\Plugin\PluginManager;
9use Shaarli\Render\TemplatePage;
10
11require_once 'plugins/qrcode/qrcode.php';
12
13/**
14 * Class PluginQrcodeTest
15 * Unit test for the QR-Code plugin
16 */
17class PluginQrcodeTest extends \Shaarli\TestCase
18{
19 /**
20 * Reset plugin path
21 */
22 protected function setUp(): void
23 {
24 PluginManager::$PLUGINS_PATH = 'plugins';
25 }
26
27 /**
28 * Test render_linklist hook.
29 */
30 public function testQrcodeLinklist()
31 {
32 $str = 'http://randomstr.com/test';
33 $data = array(
34 'title' => $str,
35 'links' => array(
36 array(
37 'url' => $str,
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']);
46 $this->assertEquals($str, $link['url']);
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 */
56 public function testQrcodeFooter()
57 {
58 $str = 'stuff';
59 $data = array($str => $str);
60 $data['_PAGE_'] = TemplatePage::LINKLIST;
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}