xref: /plugin/publish/_test/helper.test.php (revision a94f9b5fc3253bc3b4b600426e90c2935733c1e2)
191a2d0d1SMichael Große<?php
291a2d0d1SMichael Große/**
391a2d0d1SMichael Große * tests or the class helper_plugin_publish of the publish plugin
491a2d0d1SMichael Große *
591a2d0d1SMichael Große * @group plugin_publish
691a2d0d1SMichael Große * @group plugins
791a2d0d1SMichael Große */
891a2d0d1SMichael Großeclass helper_plugin_publish_test extends DokuWikiTest {
991a2d0d1SMichael Große
10*a94f9b5fSAnna Dabrowska    public function setUp(): void
11*a94f9b5fSAnna Dabrowska    {
1291a2d0d1SMichael Große        parent::setUp();
1391a2d0d1SMichael Große    }
1491a2d0d1SMichael Große
1591a2d0d1SMichael Große    protected $pluginsEnabled = array('publish',);
1691a2d0d1SMichael Große
178368b68dSMichael Große
1891a2d0d1SMichael Große    /**
198368b68dSMichael Große     * Testdata for @see helper_plugin_publish_test::test_in_namespace
2091a2d0d1SMichael Große     *
218368b68dSMichael Große     * @return array
2291a2d0d1SMichael Große     */
238368b68dSMichael Große    public function in_namespace_testdata() {
248368b68dSMichael Große        return array(
258368b68dSMichael Große            array("de:sidebar en:sidebar", 'de:sidebar', true, ''),
268368b68dSMichael Große            array("de:sidebar en:sidebar", 'en:sidebar', true, ''),
278368b68dSMichael Große            array("de:sidebar en:sidebar", 'en:sidebar:', true, ''),
288368b68dSMichael Große            array("de:sidebar en:sidebar", 'en:sidebar:start', true, ''),
298368b68dSMichael Große            array("de:sidebar en:sidebar", 'en:sidebar:namespace:start', true, ''),
308368b68dSMichael Große            array("de:sidebar en:sidebar", 'en:', false, ''),
318368b68dSMichael Große            array("de:sidebar en:sidebar", '', false, ''),
328368b68dSMichael Große            array("", 'foo:bar', true, ''),
338368b68dSMichael Große        );
348368b68dSMichael Große    }
358368b68dSMichael Große
368368b68dSMichael Große    /**
378368b68dSMichael Große     * @dataProvider in_namespace_testdata
388368b68dSMichael Große     *
398368b68dSMichael Große     * @param $namespace_list
408368b68dSMichael Große     * @param $id
418368b68dSMichael Große     * @param $result
428368b68dSMichael Große     * @param $msg
438368b68dSMichael Große     */
448368b68dSMichael Große    public function test_in_namespace($namespace_list, $id, $result, $msg) {
4591a2d0d1SMichael Große
4691a2d0d1SMichael Große        /** @var helper_plugin_publish $helper */
4791a2d0d1SMichael Große        $helper = plugin_load('helper', 'publish');
488368b68dSMichael Große        $this->assertSame($helper->in_namespace($namespace_list,$id),$result,$msg);
4991a2d0d1SMichael Große    }
5091a2d0d1SMichael Große
51889aa2d2SMichael Große    /**
52889aa2d2SMichael Große     * Testdata for @see helper_plugin_publish_test::test_in_sub_namespace
53889aa2d2SMichael Große     *
54889aa2d2SMichael Große     * @return array
55889aa2d2SMichael Große     */
56889aa2d2SMichael Große    public function in_sub_namespace_testdata() {
57889aa2d2SMichael Große        return array(
58889aa2d2SMichael Große            array("de:sidebar en:sidebar", 'de:sidebar', true, ''),
59889aa2d2SMichael Große            array("de:sidebar en:sidebar", 'en:sidebar', true, ''),
60889aa2d2SMichael Große            array("de:sidebar en:sidebar", 'en:sidebar:', true, ''),
61889aa2d2SMichael Große            array("de:sidebar en:sidebar", 'en:sidebar:start', true, ''),
62889aa2d2SMichael Große            array("de:sidebar en:sidebar", 'en:sidebar:namespace:start', true, ''),
63889aa2d2SMichael Große            array("de:sidebar en:sidebar", 'en:', true, ''),
64889aa2d2SMichael Große            array("de:sidebar en:sidebar", '', false, ''),
65889aa2d2SMichael Große            array("", 'foo:bar', true, ''),
66889aa2d2SMichael Große        );
67889aa2d2SMichael Große    }
68889aa2d2SMichael Große
69889aa2d2SMichael Große    /**
70889aa2d2SMichael Große     * @dataProvider in_sub_namespace_testdata
71889aa2d2SMichael Große     *
72889aa2d2SMichael Große     * @param $namespace_list
73889aa2d2SMichael Große     * @param $id
74889aa2d2SMichael Große     * @param $result
75889aa2d2SMichael Große     * @param $msg
76889aa2d2SMichael Große     */
77889aa2d2SMichael Große    public function test_in_sub_namespace($namespace_list, $id, $result, $msg) {
78889aa2d2SMichael Große
79889aa2d2SMichael Große        /** @var helper_plugin_publish $helper */
80889aa2d2SMichael Große        $helper = plugin_load('helper', 'publish');
81889aa2d2SMichael Große        $this->assertSame($helper->is_dir_valid($namespace_list,$id),$result,$msg);
82889aa2d2SMichael Große    }
83889aa2d2SMichael Große
8491a2d0d1SMichael Große    public function test_isActive() {
8591a2d0d1SMichael Große        global $conf;
8691a2d0d1SMichael Große
8791a2d0d1SMichael Große        $conf['plugin']['publish']['no_apr_namespaces'] = 'de:sidebar en:sidebar';
8891a2d0d1SMichael Große
8991a2d0d1SMichael Große        /** @var helper_plugin_publish $helper */
9091a2d0d1SMichael Große        $helper = plugin_load('helper', 'publish');
9191a2d0d1SMichael Große
9291a2d0d1SMichael Große        $this->assertFalse($helper->isActive('de:sidebar'), 'de:sidebar is still listed as active');
9391a2d0d1SMichael Große        $this->assertFalse($helper->isActive('en:sidebar'), 'en:sidebar is still listed as active');
9491a2d0d1SMichael Große    }
9591a2d0d1SMichael Große
9691a2d0d1SMichael Große}
97