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