xref: /plugin/bpmnio/_test/action_plugin_bpmnio_editor.test.php (revision 9ff8d41c7727ff9fa896ee8f49e170f6b8272716)
1<?php
2
3/**
4 * @group plugin_bpmnio
5 * @group plugins
6 */
7class action_plugin_bpmnio_editor_test extends DokuWikiTest
8{
9    protected $pluginsEnabled = array('bpmnio');
10
11    /**
12     * Test that the editor plugin can be loaded
13     */
14    public function test_plugin_load()
15    {
16        $plugin = plugin_load('action', 'bpmnio_editor');
17        $this->assertNotNull($plugin, 'Editor action plugin should be loadable');
18    }
19
20    /**
21     * Test section edit button for BPMN target
22     */
23    public function test_section_edit_button_bpmn()
24    {
25        $plugin = plugin_load('action', 'bpmnio_editor');
26
27        $data = ['target' => 'plugin_bpmnio_bpmn', 'name' => ''];
28        $event = new \dokuwiki\Extension\Event('HTML_SECEDIT_BUTTON', $data);
29
30        $plugin->sectionEditButton($event);
31
32        $this->assertNotEmpty($data['name'], 'Button name should be set for BPMN target');
33    }
34
35    /**
36     * Test section edit button for DMN target
37     */
38    public function test_section_edit_button_dmn()
39    {
40        $plugin = plugin_load('action', 'bpmnio_editor');
41
42        $data = ['target' => 'plugin_bpmnio_dmn', 'name' => ''];
43        $event = new \dokuwiki\Extension\Event('HTML_SECEDIT_BUTTON', $data);
44
45        $plugin->sectionEditButton($event);
46
47        $this->assertNotEmpty($data['name'], 'Button name should be set for DMN target');
48    }
49
50    /**
51     * Test section edit button ignores non-bpmnio targets
52     */
53    public function test_section_edit_button_ignores_other()
54    {
55        $plugin = plugin_load('action', 'bpmnio_editor');
56
57        $data = ['target' => 'section', 'name' => ''];
58        $event = new \dokuwiki\Extension\Event('HTML_SECEDIT_BUTTON', $data);
59
60        $plugin->sectionEditButton($event);
61
62        $this->assertEmpty($data['name'], 'Button name should not be set for non-bpmnio targets');
63    }
64
65    /**
66     * Test handlePost does nothing when plugin data not in POST
67     */
68    public function test_handle_post_noop_without_data()
69    {
70        $plugin = plugin_load('action', 'bpmnio_editor');
71
72        global $TEXT;
73        $TEXT = 'original';
74        global $INPUT;
75
76        $data = 'edit';
77        $event = new \dokuwiki\Extension\Event('ACTION_ACT_PREPROCESS', $data);
78
79        $plugin->handlePost($event);
80
81        $this->assertEquals('original', $TEXT, '$TEXT should not change when plugin data is not posted');
82    }
83}
84