aboutsummaryrefslogtreecommitdiffhomepage
path: root/tests/plugins/PluginPlayvideosTest.php
blob: 51472617ad47cf21cd5fbc418ca2fd5d0982652c (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
<?php
namespace Shaarli\Plugin\Playvideos;

/**
 * PluginPlayvideosTest.php
 */

use Shaarli\Plugin\PluginManager;
use Shaarli\Router;

require_once 'plugins/playvideos/playvideos.php';

/**
 * Class PluginPlayvideosTest
 * Unit test for the PlayVideos plugin
 */
class PluginPlayvideosTest extends \PHPUnit\Framework\TestCase
{
    /**
     * Reset plugin path
     */
    public function setUp()
    {
        PluginManager::$PLUGINS_PATH = 'plugins';
    }

    /**
     * Test render_linklist hook.
     */
    public function testPlayvideosHeader()
    {
        $str = 'stuff';
        $data = array($str => $str);
        $data['_PAGE_'] = Router::$PAGE_LINKLIST;

        $data = hook_playvideos_render_header($data);
        $this->assertEquals($str, $data[$str]);
        $this->assertEquals(1, count($data['buttons_toolbar']));

        $data = array($str => $str);
        $data['_PAGE_'] = $str;
        $this->assertEquals($str, $data[$str]);
        $this->assertArrayNotHasKey('buttons_toolbar', $data);
    }

    /**
     * Test render_footer hook.
     */
    public function testPlayvideosFooter()
    {
        $str = 'stuff';
        $data = array($str => $str);
        $data['_PAGE_'] = Router::$PAGE_LINKLIST;

        $data = hook_playvideos_render_footer($data);
        $this->assertEquals($str, $data[$str]);
        $this->assertEquals(2, count($data['js_files']));

        $data = array($str => $str);
        $data['_PAGE_'] = $str;
        $this->assertEquals($str, $data[$str]);
        $this->assertArrayNotHasKey('js_files', $data);
    }
}