]> git.immae.eu Git - github/shaarli/Shaarli.git/blame - tests/plugins/PluginAddlinkTest.php
Fix identation
[github/shaarli/Shaarli.git] / tests / plugins / PluginAddlinkTest.php
CommitLineData
ff5bda82 1<?php
95854417 2namespace Shaarli\Plugin\Addlink;
ff5bda82 3
e1850388 4use Shaarli\Plugin\PluginManager;
1a8ac737 5use Shaarli\Render\TemplatePage;
a932f486 6
ff5bda82 7require_once 'plugins/addlink_toolbar/addlink_toolbar.php';
ff5bda82
A
8
9/**
ff5bda82
A
10 * Unit test for the Addlink toolbar plugin
11 */
e1850388 12class PluginAddlinkTest extends \PHPUnit\Framework\TestCase
ff5bda82
A
13{
14 /**
15 * Reset plugin path.
16 */
8f60e120 17 protected function setUp(): void
ff5bda82
A
18 {
19 PluginManager::$PLUGINS_PATH = 'plugins';
20 }
21
22 /**
23 * Test render_header hook while logged in.
24 */
93b1fe54 25 public function testAddlinkHeaderLoggedIn()
ff5bda82
A
26 {
27 $str = 'stuff';
28 $data = array($str => $str);
1a8ac737 29 $data['_PAGE_'] = TemplatePage::LINKLIST;
ff5bda82 30 $data['_LOGGEDIN_'] = true;
9fbc4229 31 $data['_BASE_PATH_'] = '/subfolder';
ff5bda82
A
32
33 $data = hook_addlink_toolbar_render_header($data);
34 $this->assertEquals($str, $data[$str]);
35 $this->assertEquals(1, count($data['fields_toolbar']));
36
37 $data = array($str => $str);
38 $data['_PAGE_'] = $str;
39 $data['_LOGGEDIN_'] = true;
9fbc4229
A
40 $data['_BASE_PATH_'] = '/subfolder';
41
ff5bda82
A
42 $data = hook_addlink_toolbar_render_header($data);
43 $this->assertEquals($str, $data[$str]);
44 $this->assertArrayNotHasKey('fields_toolbar', $data);
45 }
46
47 /**
48 * Test render_header hook while logged out.
49 */
93b1fe54 50 public function testAddlinkHeaderLoggedOut()
ff5bda82
A
51 {
52 $str = 'stuff';
53 $data = array($str => $str);
1a8ac737 54 $data['_PAGE_'] = TemplatePage::LINKLIST;
ff5bda82 55 $data['_LOGGEDIN_'] = false;
9fbc4229 56 $data['_BASE_PATH_'] = '/subfolder';
ff5bda82
A
57
58 $data = hook_addlink_toolbar_render_header($data);
59 $this->assertEquals($str, $data[$str]);
60 $this->assertArrayNotHasKey('fields_toolbar', $data);
61 }
ff5bda82 62}