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