1*8fed17f3SAndreas Gohr<?php 2*8fed17f3SAndreas Gohr 3*8fed17f3SAndreas Gohrnamespace dokuwiki\plugin\struct\test\action; 4*8fed17f3SAndreas Gohr 5*8fed17f3SAndreas Gohruse dokuwiki\plugin\struct\meta\AccessTable; 6*8fed17f3SAndreas Gohruse dokuwiki\plugin\struct\test\StructTest; 7*8fed17f3SAndreas Gohr 8*8fed17f3SAndreas Gohr/** 9*8fed17f3SAndreas Gohr * @covers action_plugin_struct_aggregationeditor 10*8fed17f3SAndreas Gohr * 11*8fed17f3SAndreas Gohr * @group plugin_struct 12*8fed17f3SAndreas Gohr * @group plugins 13*8fed17f3SAndreas Gohr * @group integration 14*8fed17f3SAndreas Gohr */ 15*8fed17f3SAndreas Gohrclass LookupAjaxTest extends StructTest 16*8fed17f3SAndreas Gohr{ 17*8fed17f3SAndreas Gohr public function setUp(): void 18*8fed17f3SAndreas Gohr { 19*8fed17f3SAndreas Gohr parent::setUp(); 20*8fed17f3SAndreas Gohr 21*8fed17f3SAndreas Gohr $this->loadSchemaJSON('wikilookup', '', 0); 22*8fed17f3SAndreas Gohr 23*8fed17f3SAndreas Gohr /** @var \helper_plugin_struct $helper */ 24*8fed17f3SAndreas Gohr $helper = plugin_load('helper', 'struct'); 25*8fed17f3SAndreas Gohr 26*8fed17f3SAndreas Gohr $saveDate = [ 27*8fed17f3SAndreas Gohr 'FirstFieldText' => 'abc def', 28*8fed17f3SAndreas Gohr 'SecondFieldLongText' => "abc\ndef\n", 29*8fed17f3SAndreas Gohr 'ThirdFieldWiki' => " * hi\n * ho", 30*8fed17f3SAndreas Gohr ]; 31*8fed17f3SAndreas Gohr $access = AccessTable::getGlobalAccess('wikilookup'); 32*8fed17f3SAndreas Gohr $helper->saveLookupData($access, $saveDate); 33*8fed17f3SAndreas Gohr } 34*8fed17f3SAndreas Gohr 35*8fed17f3SAndreas Gohr public function testSaveGlobalDataEvent() 36*8fed17f3SAndreas Gohr { 37*8fed17f3SAndreas Gohr $testLabel = 'testcontent'; 38*8fed17f3SAndreas Gohr global $INPUT; 39*8fed17f3SAndreas Gohr $INPUT->post->set('schema', 'wikilookup'); 40*8fed17f3SAndreas Gohr $INPUT->post->set('entry', ['FirstFieldText' => $testLabel]); 41*8fed17f3SAndreas Gohr $INPUT->post->set('searchconf', json_encode([ 42*8fed17f3SAndreas Gohr 'schemas' => [['wikilookup', '']], 43*8fed17f3SAndreas Gohr 'cols' => ['*'] 44*8fed17f3SAndreas Gohr ])); 45*8fed17f3SAndreas Gohr $call = 'plugin_struct_aggregationeditor_save'; 46*8fed17f3SAndreas Gohr $evt = new \Doku_Event('AJAX_CALL_UNKNOWN', $call); 47*8fed17f3SAndreas Gohr 48*8fed17f3SAndreas Gohr $this->expectOutputRegex('/\s*<tr.*' . $testLabel . '.*<\/td>\s*/'); 49*8fed17f3SAndreas Gohr 50*8fed17f3SAndreas Gohr $evt->advise_before(); 51*8fed17f3SAndreas Gohr } 52*8fed17f3SAndreas Gohr} 53