public function testToString() { $foo = md5(self::randomString(64)); $bar = md5(self::randomString(64)); $request = $this->getMockForAbstractClass('\\Zimbra\\Soap\\Request'); $request->setProperty('foo', $foo); $request->setChild('bar', $bar); $authToken = md5(self::randomString(64)); $xml = '<?xml version="1.0"?>' . "\n" . '<env:Envelope xmlns:env="http://www.w3.org/2003/05/soap-envelope" ' . 'xmlns:urn="urn:zimbra">' . '<env:Header>' . '<urn:context>' . '<urn:authToken>' . $authToken . '</urn:authToken>' . '</urn:context>' . '</env:Header>' . '<env:Body>' . '<urn:' . $request->requestName() . ' foo="' . $foo . '">' . '<urn:bar>' . $bar . '</urn:bar>' . '</urn:' . $request->requestName() . '>' . '</env:Body>' . '</env:Envelope>'; $message = new Message(); $message->addHeader('authToken', $authToken); $message->setRequest($request); $this->assertXmlStringEqualsXmlString($xml, (string) $message); $json = '{' . '"Header":{' . '"context":{' . '"_jsns":"urn:zimbra",' . '"authToken":"' . $authToken . '"' . '}' . '},' . '"Body":{' . '"' . $request->requestName() . '":{' . '"_jsns":"urn:zimbra",' . '"foo":"' . $foo . '",' . '"bar":"' . $bar . '"' . '}' . '}' . '}'; $this->assertEquals($json, $message->toJson()); }