1<?php 2 3/** 4 * @group plugin_bpmnio 5 * @group plugins 6 */ 7class action_plugin_bpmnio_toolbar_test extends DokuWikiTest 8{ 9 protected $pluginsEnabled = array('bpmnio'); 10 11 /** 12 * Test that the toolbar plugin can be loaded 13 */ 14 public function test_plugin_load() 15 { 16 $plugin = plugin_load('action', 'bpmnio_toolbar'); 17 $this->assertNotNull($plugin, 'Toolbar action plugin should be loadable'); 18 } 19 20 /** 21 * Test that the toolbar handler adds the picker to event data 22 */ 23 public function test_toolbar_handler_adds_picker() 24 { 25 $plugin = plugin_load('action', 'bpmnio_toolbar'); 26 27 $data = []; 28 $event = new \dokuwiki\Extension\Event('TOOLBAR_DEFINE', $data); 29 30 $plugin->handleToolbar($event); 31 32 $this->assertCount(1, $data, 'Should add one toolbar entry'); 33 $picker = $data[0]; 34 $this->assertEquals('picker', $picker['type']); 35 $this->assertArrayHasKey('list', $picker); 36 $this->assertCount(2, $picker['list'], 'Picker should have BPMN and DMN entries'); 37 38 // Check BPMN entry 39 $bpmn = $picker['list'][0]; 40 $this->assertEquals('format', $bpmn['type']); 41 $this->assertNotEmpty($bpmn['open'], 'BPMN open template should not be empty'); 42 $this->assertNotEmpty($bpmn['close'], 'BPMN close template should not be empty'); 43 $this->assertStringContainsString('bpmnio', $bpmn['open']); 44 45 // Check DMN entry 46 $dmn = $picker['list'][1]; 47 $this->assertEquals('format', $dmn['type']); 48 $this->assertNotEmpty($dmn['open'], 'DMN open template should not be empty'); 49 $this->assertNotEmpty($dmn['close'], 'DMN close template should not be empty'); 50 $this->assertStringContainsString('bpmnio', $dmn['open']); 51 } 52 53 /** 54 * Test that toolbar icons reference the correct directory 55 */ 56 public function test_toolbar_icon_paths() 57 { 58 $plugin = plugin_load('action', 'bpmnio_toolbar'); 59 60 $data = []; 61 $event = new \dokuwiki\Extension\Event('TOOLBAR_DEFINE', $data); 62 $plugin->handleToolbar($event); 63 64 $picker = $data[0]; 65 $this->assertStringContainsString('bpmnio/images/toolbar/', $picker['icon']); 66 $this->assertStringContainsString('bpmnio/images/toolbar/', $picker['list'][0]['icon']); 67 $this->assertStringContainsString('bpmnio/images/toolbar/', $picker['list'][1]['icon']); 68 } 69 70 /** 71 * Test that BPMN template contains valid XML structure 72 */ 73 public function test_bpmn_template_content() 74 { 75 $plugin = plugin_load('action', 'bpmnio_toolbar'); 76 77 $data = []; 78 $event = new \dokuwiki\Extension\Event('TOOLBAR_DEFINE', $data); 79 $plugin->handleToolbar($event); 80 81 $bpmn_open = $data[0]['list'][0]['open']; 82 $bpmn_close = $data[0]['list'][0]['close']; 83 84 $this->assertStringContainsString('<bpmnio type="bpmn">', $bpmn_open); 85 $this->assertStringContainsString('</bpmnio>', $bpmn_close); 86 } 87 88 /** 89 * Test that DMN template contains valid XML structure 90 */ 91 public function test_dmn_template_content() 92 { 93 $plugin = plugin_load('action', 'bpmnio_toolbar'); 94 95 $data = []; 96 $event = new \dokuwiki\Extension\Event('TOOLBAR_DEFINE', $data); 97 $plugin->handleToolbar($event); 98 99 $dmn_open = $data[0]['list'][1]['open']; 100 $dmn_close = $data[0]['list'][1]['close']; 101 102 $this->assertStringContainsString('<bpmnio type="dmn">', $dmn_open); 103 $this->assertStringContainsString('</bpmnio>', $dmn_close); 104 } 105} 106