1<?php
2/**
3 * General tests for the feedback plugin
4 *
5 * @group plugin_feedback
6 * @group plugins
7 */
8class getFeedbackContact_plugin_feedback_test extends DokuWikiTest {
9
10    protected $pluginsEnabled = array('feedback', 'translation');
11
12    public static function setUpBeforeClass() {
13        parent::setUpBeforeClass();
14
15        $fn = DOKU_CONF . 'plugin_feedback.conf';
16
17        $text = "en	ignore@example.com\nplugin	ignoreB@example.com\n";
18
19        file_put_contents($fn, $text);
20    }
21
22    /**
23     * @inheritDoc
24     */
25    public function setUp() {
26        parent::setUp();
27    }
28
29
30    public static function getFeedbackContact_testdata() {
31        return array(
32            array(
33                'qwe',
34                array(),
35                false,
36                'return false for page w/o set contact'
37            ),
38            array(
39                'en:plugin:bar',
40                array(),
41                'ignore@example.com',
42                'return contact for page in configured namespace'
43            ),
44            array(
45                'fr:plugin:bar',
46                array(),
47                false,
48                'no contact in translated ns without activated span_translations option'
49            ),
50            array(
51                'fr:plugin:bar',
52                array('span_translations' => 1),
53                'ignoreB@example.com',
54                'return contact in translated ns with activated span_translations option'
55            ),
56            array(
57                'plugin',
58                array(),
59                false,
60                'return false for outside start-page without activated include_parent_startpage option'
61            ),
62            array(
63                'plugin',
64                array('include_parent_startpage' => 1),
65                'ignoreB@example.com',
66                'return contact for outside start-page with activated include_parent_startpage option'
67            ),
68
69        );
70    }
71
72
73    /**
74     * @dataProvider getFeedbackContact_testdata
75     */
76    public function test_getFeedbackContact ($input, $options, $expected_output, $message) {
77        /** @var action_plugin_feedback $action */
78        $action = plugin_load('action', 'feedback');
79        global $conf;
80        foreach ($options as $key => $value) {
81            $conf['plugin']['feedback'][$key] = $value;
82        }
83
84
85        global $conf;
86        $conf['plugin']['translation']['translations'] = 'en de fr es';
87        $trans = plugin_load('helper', 'translation', true);
88
89        $actual_output = $action->getFeedbackContact($input);
90
91        $this->assertEquals($expected_output, $actual_output, $message);
92    }
93}
94 // getFeedbackContact
95