xref: /plugin/publish/_test/helper.test.php (revision 8368b68d1d1f74518352022be89d32dc988b127e)
1<?php
2/**
3 * tests or the class helper_plugin_publish of the publish plugin
4 *
5 * @group plugin_publish
6 * @group plugins
7 */
8class helper_plugin_publish_test extends DokuWikiTest {
9
10    public function setUp() {
11        parent::setUp();
12    }
13
14    protected $pluginsEnabled = array('publish',);
15
16
17    /**
18     * Testdata for @see helper_plugin_publish_test::test_in_namespace
19     *
20     * @return array
21     */
22    public function in_namespace_testdata() {
23        return array(
24            array("de:sidebar en:sidebar", 'de:sidebar', true, ''),
25            array("de:sidebar en:sidebar", 'en:sidebar', true, ''),
26            array("de:sidebar en:sidebar", 'en:sidebar:', true, ''),
27            array("de:sidebar en:sidebar", 'en:sidebar:start', true, ''),
28            array("de:sidebar en:sidebar", 'en:sidebar:namespace:start', true, ''),
29            array("de:sidebar en:sidebar", 'en:', false, ''),
30            array("de:sidebar en:sidebar", '', false, ''),
31            array("", 'foo:bar', true, ''),
32        );
33    }
34
35    /**
36     * @dataProvider in_namespace_testdata
37     *
38     * @param $namespace_list
39     * @param $id
40     * @param $result
41     * @param $msg
42     */
43    public function test_in_namespace($namespace_list, $id, $result, $msg) {
44
45        /** @var helper_plugin_publish $helper */
46        $helper = plugin_load('helper', 'publish');
47        $this->assertSame($helper->in_namespace($namespace_list,$id),$result,$msg);
48    }
49
50    public function test_isActive() {
51        global $conf;
52
53        $conf['plugin']['publish']['no_apr_namespaces'] = 'de:sidebar en:sidebar';
54
55        /** @var helper_plugin_publish $helper */
56        $helper = plugin_load('helper', 'publish');
57
58        $this->assertFalse($helper->isActive('de:sidebar'), 'de:sidebar is still listed as active');
59        $this->assertFalse($helper->isActive('en:sidebar'), 'en:sidebar is still listed as active');
60    }
61
62}
63