18fed17f3SAndreas Gohr<?php 28fed17f3SAndreas Gohr 38fed17f3SAndreas Gohrnamespace dokuwiki\plugin\struct\test; 48fed17f3SAndreas Gohr 58fed17f3SAndreas Gohr/** 68fed17f3SAndreas Gohr * @group plugin_struct 78fed17f3SAndreas Gohr * @group plugins 88fed17f3SAndreas Gohr */ 98fed17f3SAndreas Gohrclass helper_db_struct_test extends StructTest 108fed17f3SAndreas Gohr{ 118fed17f3SAndreas Gohr 128fed17f3SAndreas Gohr public function setUp(): void 138fed17f3SAndreas Gohr { 148fed17f3SAndreas Gohr parent::setUp(); 158fed17f3SAndreas Gohr 168fed17f3SAndreas Gohr $this->loadSchemaJSON('schema1'); 178fed17f3SAndreas Gohr $this->loadSchemaJSON('schema2'); 188fed17f3SAndreas Gohr } 198fed17f3SAndreas Gohr 208fed17f3SAndreas Gohr /** 218fed17f3SAndreas Gohr * @noinspection SqlDialectInspection 228fed17f3SAndreas Gohr * @noinspection SqlNoDataSourceInspection 238fed17f3SAndreas Gohr */ 248fed17f3SAndreas Gohr public function test_json() 258fed17f3SAndreas Gohr { 268fed17f3SAndreas Gohr /** @var \helper_plugin_struct_db $helper */ 278fed17f3SAndreas Gohr $helper = plugin_load('helper', 'struct_db'); 288fed17f3SAndreas Gohr $sqlite = $helper->getDB(); 298fed17f3SAndreas Gohr 30*79b29326SAnna Dabrowska $result = $sqlite->queryValue("SELECT STRUCT_JSON('foo', 'bar') "); 318fed17f3SAndreas Gohr $expect = '["foo","bar"]'; 328fed17f3SAndreas Gohr $this->assertEquals($expect, $result); 338fed17f3SAndreas Gohr 34*79b29326SAnna Dabrowska $result = $sqlite->queryAll("SELECT STRUCT_JSON(id, tbl) AS col FROM schemas"); 358fed17f3SAndreas Gohr 368fed17f3SAndreas Gohr $expect = [ 378fed17f3SAndreas Gohr ['col' => '[1,"schema1"]'], 388fed17f3SAndreas Gohr ['col' => '[2,"schema2"]'], 398fed17f3SAndreas Gohr ]; 408fed17f3SAndreas Gohr $this->assertEquals($expect, $result); 418fed17f3SAndreas Gohr } 428fed17f3SAndreas Gohr 438fed17f3SAndreas Gohr} 44