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    /**
51     * Testdata for @see helper_plugin_publish_test::test_in_sub_namespace
52     *
53     * @return array
54     */
55    public function in_sub_namespace_testdata() {
56        return array(
57            array("de:sidebar en:sidebar", 'de:sidebar', true, ''),
58            array("de:sidebar en:sidebar", 'en:sidebar', true, ''),
59            array("de:sidebar en:sidebar", 'en:sidebar:', true, ''),
60            array("de:sidebar en:sidebar", 'en:sidebar:start', true, ''),
61            array("de:sidebar en:sidebar", 'en:sidebar:namespace:start', true, ''),
62            array("de:sidebar en:sidebar", 'en:', true, ''),
63            array("de:sidebar en:sidebar", '', false, ''),
64            array("", 'foo:bar', true, ''),
65        );
66    }
67
68    /**
69     * @dataProvider in_sub_namespace_testdata
70     *
71     * @param $namespace_list
72     * @param $id
73     * @param $result
74     * @param $msg
75     */
76    public function test_in_sub_namespace($namespace_list, $id, $result, $msg) {
77
78        /** @var helper_plugin_publish $helper */
79        $helper = plugin_load('helper', 'publish');
80        $this->assertSame($helper->is_dir_valid($namespace_list,$id),$result,$msg);
81    }
82
83    public function test_isActive() {
84        global $conf;
85
86        $conf['plugin']['publish']['no_apr_namespaces'] = 'de:sidebar en:sidebar';
87
88        /** @var helper_plugin_publish $helper */
89        $helper = plugin_load('helper', 'publish');
90
91        $this->assertFalse($helper->isActive('de:sidebar'), 'de:sidebar is still listed as active');
92        $this->assertFalse($helper->isActive('en:sidebar'), 'en:sidebar is still listed as active');
93    }
94
95}
96