public function writeVariantMap(array $map) { $writer = new Writer(null, $this->types); // datastream protocol just uses list contents with UTF-8 keys // the list always starts with a key string, which can be used to tell apart from actual list contents // https://github.com/quassel/quassel/blob/master/src/common/protocols/datastream/datastreampeer.cpp#L80 $writer->writeQVariantList($this->mapToList($map)); return (string) $writer; }
public function testQVariantListSomeExplicit() { $in = array(new QVariant(-10, Types::TYPE_CHAR), 20, -300); $expected = array(-10, 20, -300); $writer = new Writer(); $writer->writeQVariantList($in); $data = (string) $writer; $reader = Reader::fromString($data); $this->assertEquals($expected, $reader->readQVariantList()); }
public function testReceiveHeartBeatRequestWithCorrectTimeZone() { date_default_timezone_set('Europe/Berlin'); $writer = new Writer(); $writer->writeQVariantList(array(Protocol::REQUEST_HEARTBEAT, new QVariant(new \DateTime('2016-09-24 14:20:00.123+00:00'), Types::TYPE_QDATETIME))); $packet = (string) $writer; $values = $this->protocol->readVariant($packet); $this->assertCount(2, $values); $this->assertEquals(Protocol::REQUEST_HEARTBEAT, $values[0]); $this->assertEquals(new \DateTime('2016-09-24 16:20:00.123', new \DateTimeZone('Europe/Berlin')), $values[1]); }