1*12b99753SAndreas Gohr<?php 2*12b99753SAndreas Gohr 3*12b99753SAndreas Gohrnamespace dokuwiki\test\Remote; 4*12b99753SAndreas Gohr 5*12b99753SAndreas Gohr 6*12b99753SAndreas Gohruse dokuwiki\test\Remote\Mock\XmlRpcServer; 7*12b99753SAndreas Gohr 8*12b99753SAndreas Gohrclass XmlRpcServerTest extends \DokuWikiTest 9*12b99753SAndreas Gohr{ 10*12b99753SAndreas Gohr protected $server; 11*12b99753SAndreas Gohr 12*12b99753SAndreas Gohr function setUp(): void 13*12b99753SAndreas Gohr { 14*12b99753SAndreas Gohr parent::setUp(); 15*12b99753SAndreas Gohr global $conf; 16*12b99753SAndreas Gohr 17*12b99753SAndreas Gohr $conf['remote'] = 1; 18*12b99753SAndreas Gohr $conf['remoteuser'] = ''; 19*12b99753SAndreas Gohr $conf['useacl'] = 0; 20*12b99753SAndreas Gohr 21*12b99753SAndreas Gohr $this->server = new XmlRpcServer(true); 22*12b99753SAndreas Gohr } 23*12b99753SAndreas Gohr 24*12b99753SAndreas Gohr 25*12b99753SAndreas Gohr function testFullArgs() 26*12b99753SAndreas Gohr { 27*12b99753SAndreas Gohr $request = <<<EOD 28*12b99753SAndreas Gohr<?xml version="1.0"?> 29*12b99753SAndreas Gohr<methodCall> 30*12b99753SAndreas Gohr <methodName>wiki.twoArgWithDefaultArg</methodName> 31*12b99753SAndreas Gohr <param> 32*12b99753SAndreas Gohr <value> 33*12b99753SAndreas Gohr <string>arg1</string> 34*12b99753SAndreas Gohr </value> 35*12b99753SAndreas Gohr </param> 36*12b99753SAndreas Gohr <param> 37*12b99753SAndreas Gohr <value> 38*12b99753SAndreas Gohr <string>arg2</string> 39*12b99753SAndreas Gohr </value> 40*12b99753SAndreas Gohr </param> 41*12b99753SAndreas Gohr</methodCall> 42*12b99753SAndreas GohrEOD; 43*12b99753SAndreas Gohr 44*12b99753SAndreas Gohr $expected = <<<EOD 45*12b99753SAndreas Gohr<methodResponse> 46*12b99753SAndreas Gohr <params> 47*12b99753SAndreas Gohr <param> 48*12b99753SAndreas Gohr <value> 49*12b99753SAndreas Gohr <array> 50*12b99753SAndreas Gohr <data> 51*12b99753SAndreas Gohr <value> 52*12b99753SAndreas Gohr <string>arg1</string> 53*12b99753SAndreas Gohr </value> 54*12b99753SAndreas Gohr <value> 55*12b99753SAndreas Gohr <string>arg2</string> 56*12b99753SAndreas Gohr </value> 57*12b99753SAndreas Gohr </data> 58*12b99753SAndreas Gohr </array> 59*12b99753SAndreas Gohr </value> 60*12b99753SAndreas Gohr </param> 61*12b99753SAndreas Gohr </params> 62*12b99753SAndreas Gohr</methodResponse> 63*12b99753SAndreas GohrEOD; 64*12b99753SAndreas Gohr 65*12b99753SAndreas Gohr $_SERVER['CONTENT_TYPE'] = 'text/xml'; 66*12b99753SAndreas Gohr $this->server->serve($request); 67*12b99753SAndreas Gohr $this->assertXmlStringEqualsXmlString(trim($expected), trim($this->server->output)); 68*12b99753SAndreas Gohr } 69*12b99753SAndreas Gohr 70*12b99753SAndreas Gohr function testDefaultArgs() 71*12b99753SAndreas Gohr { 72*12b99753SAndreas Gohr $request = <<<EOD 73*12b99753SAndreas Gohr<?xml version="1.0"?> 74*12b99753SAndreas Gohr<methodCall> 75*12b99753SAndreas Gohr <methodName>wiki.twoArgWithDefaultArg</methodName> 76*12b99753SAndreas Gohr <param> 77*12b99753SAndreas Gohr <value> 78*12b99753SAndreas Gohr <string>arg1</string> 79*12b99753SAndreas Gohr </value> 80*12b99753SAndreas Gohr </param> 81*12b99753SAndreas Gohr</methodCall> 82*12b99753SAndreas GohrEOD; 83*12b99753SAndreas Gohr 84*12b99753SAndreas Gohr $expected = <<<EOD 85*12b99753SAndreas Gohr<methodResponse> 86*12b99753SAndreas Gohr <params> 87*12b99753SAndreas Gohr <param> 88*12b99753SAndreas Gohr <value> 89*12b99753SAndreas Gohr <array> 90*12b99753SAndreas Gohr <data> 91*12b99753SAndreas Gohr <value> 92*12b99753SAndreas Gohr <string>arg1</string> 93*12b99753SAndreas Gohr </value> 94*12b99753SAndreas Gohr <value> 95*12b99753SAndreas Gohr <string>default</string> 96*12b99753SAndreas Gohr </value> 97*12b99753SAndreas Gohr </data> 98*12b99753SAndreas Gohr </array> 99*12b99753SAndreas Gohr </value> 100*12b99753SAndreas Gohr </param> 101*12b99753SAndreas Gohr </params> 102*12b99753SAndreas Gohr</methodResponse> 103*12b99753SAndreas GohrEOD; 104*12b99753SAndreas Gohr 105*12b99753SAndreas Gohr $_SERVER['CONTENT_TYPE'] = 'text/xml'; 106*12b99753SAndreas Gohr $this->server->serve($request); 107*12b99753SAndreas Gohr $this->assertXmlStringEqualsXmlString(trim($expected), trim($this->server->output)); 108*12b99753SAndreas Gohr } 109*12b99753SAndreas Gohr 110*12b99753SAndreas Gohr function testStructResponse() 111*12b99753SAndreas Gohr { 112*12b99753SAndreas Gohr $request = <<<EOD 113*12b99753SAndreas Gohr<?xml version="1.0"?> 114*12b99753SAndreas Gohr <methodCall> 115*12b99753SAndreas Gohr <methodName>wiki.getStructuredData</methodName> 116*12b99753SAndreas Gohr </methodCall> 117*12b99753SAndreas GohrEOD; 118*12b99753SAndreas Gohr $expected = <<<EOD 119*12b99753SAndreas Gohr<methodResponse> 120*12b99753SAndreas Gohr <params> 121*12b99753SAndreas Gohr <param> 122*12b99753SAndreas Gohr <value> 123*12b99753SAndreas Gohr <struct> 124*12b99753SAndreas Gohr <member> 125*12b99753SAndreas Gohr <name>type</name> 126*12b99753SAndreas Gohr <value><string>internal</string></value> 127*12b99753SAndreas Gohr </member> 128*12b99753SAndreas Gohr <member> 129*12b99753SAndreas Gohr <name>page</name> 130*12b99753SAndreas Gohr <value><string>wiki:dokuwiki</string></value> 131*12b99753SAndreas Gohr </member> 132*12b99753SAndreas Gohr <member> 133*12b99753SAndreas Gohr <name>href</name> 134*12b99753SAndreas Gohr <value><string>https://www.dokuwiki.org/wiki:dokuwiki</string></value> 135*12b99753SAndreas Gohr </member> 136*12b99753SAndreas Gohr </struct> 137*12b99753SAndreas Gohr </value> 138*12b99753SAndreas Gohr </param> 139*12b99753SAndreas Gohr </params> 140*12b99753SAndreas Gohr</methodResponse> 141*12b99753SAndreas GohrEOD; 142*12b99753SAndreas Gohr 143*12b99753SAndreas Gohr $_SERVER['CONTENT_TYPE'] = 'text/xml'; 144*12b99753SAndreas Gohr $this->server->serve($request); 145*12b99753SAndreas Gohr $this->assertXmlStringEqualsXmlString(trim($expected), trim($this->server->output)); 146*12b99753SAndreas Gohr } 147*12b99753SAndreas Gohr} 148