aboutsummaryrefslogtreecommitdiffhomepage
path: root/tests/plugins/test/test.php
blob: 8dbb3f9464c8905fc5c5ed50f702102c1e3ec7a1 (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
<?php

use Shaarli\Bookmark\Bookmark;

/**
 * Hook for test.
 *
 * @param array $data - data passed to plugin.
 *
 * @return mixed altered data.
 */
function hook_test_random($data)
{
    if (isset($data['_PAGE_']) && $data['_PAGE_'] == 'test') {
        $data[1] = 'page test';
    } elseif (isset($data['_LOGGEDIN_']) && $data['_LOGGEDIN_'] === true) {
        $data[1] = 'loggedin';
    } elseif (array_key_exists('_LOGGEDIN_', $data)) {
        $data[1] = 'loggedin';
        $data[2] = $data['_LOGGEDIN_'];
    } else {
        $data[1] = $data[0];
    }

    return $data;
}

function hook_test_error()
{
    new Unknown();
}

function test_register_routes(): array
{
    return [
        [
            'method' => 'GET',
            'route' => '/test',
            'callable' => 'getFunction',
        ],
        [
            'method' => 'POST',
            'route' => '/custom',
            'callable' => 'postFunction',
        ],
    ];
}

function hook_test_filter_search_entry(Bookmark $bookmark, array $context): bool
{
    return $context['_result'];
}