[ Index ]

PHP Cross Reference of DokuWiki

title

Body

[close]

/_test/tests/inc/ -> XmlRpcServer.test.php (source)

   1  <?php
   2  
   3  use dokuwiki\Remote\XmlRpcServer;
   4  
   5  class XmlRpcServerTestWrapper extends XmlRpcServer
   6  {
   7      public $output;
   8  
   9      public function output($xml) {
  10          $this->output = $xml;
  11      }
  12  }
  13  
  14  class XmlRpcServerTest extends DokuWikiTest
  15  {
  16      protected $server;
  17  
  18      function setUp()
  19      {
  20          parent::setUp();
  21          global $conf;
  22  
  23          $conf['remote'] = 1;
  24          $conf['remoteuser'] = '';
  25          $conf['useacl'] = 0;
  26  
  27          $this->server = new XmlRpcServerTestWrapper(true);
  28      }
  29  
  30  
  31      function testDateFormat()
  32      {
  33          $pageName = ":wiki:dokuwiki";
  34          $file = wikiFN($pageName);
  35          $timestamp = filemtime($file);
  36          $ixrModifiedTime = (new DateTime('@' . $timestamp))->format(IXR_Date::XMLRPC_ISO8601);
  37  
  38          $request = <<<EOD
  39  <?xml version="1.0"?>
  40     <methodCall>
  41       <methodName>wiki.getPageInfo</methodName>
  42               <param> 
  43              <value>
  44                  <string>$pageName</string>
  45              </value>
  46          </param>
  47     </methodCall>
  48  EOD;
  49          $expected = <<<EOD
  50  <methodResponse>
  51    <params>
  52      <param>
  53        <value>
  54          <struct>
  55    <member><name>name</name><value><string>wiki:dokuwiki</string></value></member>
  56    <member><name>lastModified</name><value><dateTime.iso8601>$ixrModifiedTime</dateTime.iso8601></value></member>
  57    <member><name>author</name><value><string></string></value></member>
  58    <member><name>version</name><value><int>$timestamp</int></value></member>
  59  </struct>
  60        </value>
  61      </param>
  62    </params>
  63  </methodResponse>
  64  EOD;
  65  
  66          $this->server->serve($request);
  67          $this->assertEquals(trim($expected), trim($this->server->output));
  68      }
  69  }