public function testSimpleMessageClear() { $simple = new Simple(); $simple->setBool(true); $simple->setString("foo"); $simple->setFloat(12345.123); $simple->setUint32(123456789); $simple->setInt32(-123456789); $simple->setFixed32(123456789); $simple->setSint32(-123456789); $simple->setSfixed32(-123456789); $simple->setDouble(123456789.12345); $simple->setInt64(-123456789123456789); $simple->setUint64(123456789123456789); $simple->setFixed64(123456789123456789); $simple->setSint64(-123456789123456789); $simple->setBytes(Stream::wrap("bar")); $simple->setSfixed64(-123456789123456789); $this->assertSame(true, $simple->getBool()); $this->assertSame("foo", $simple->getString()); $this->assertSame(12345.123, $simple->getFloat()); $this->assertSame(123456789, $simple->getUint32()); $this->assertSame(-123456789, $simple->getInt32()); $this->assertSame(123456789, $simple->getFixed32()); $this->assertSame(-123456789, $simple->getSint32()); $this->assertSame(-123456789, $simple->getSfixed32()); $this->assertSame(123456789.12345, $simple->getDouble()); $this->assertSame(-123456789123456789, $simple->getInt64()); $this->assertSame(123456789123456789, $simple->getUint64()); $this->assertSame(123456789123456789, $simple->getFixed64()); $this->assertSame(-123456789123456789, $simple->getSint64()); $this->assertSame(-123456789123456789, $simple->getSfixed64()); $this->assertInstanceOf('Protobuf\\Stream', $simple->getBytes()); $simple->clear(); $this->assertNull($simple->getBool()); $this->assertNull($simple->getString()); $this->assertNull($simple->getFloat()); $this->assertNull($simple->getUint32()); $this->assertNull($simple->getInt32()); $this->assertNull($simple->getFixed32()); $this->assertNull($simple->getSint32()); $this->assertNull($simple->getSfixed32()); $this->assertNull($simple->getDouble()); $this->assertNull($simple->getInt64()); $this->assertNull($simple->getUint64()); $this->assertNull($simple->getFixed64()); $this->assertNull($simple->getSint64()); $this->assertNull($simple->getSfixed64()); $this->assertNull($simple->getBytes()); }
public function testSimpleMessageMerge() { $simple1 = new Simple(); $simple2 = new Simple(); $bytes = Stream::wrap("bar"); $simple1->setBool(true); $simple1->setString("foo"); $simple1->setBytes($bytes); $simple1->setFloat(12345.123); $simple1->setUint32(123456789); $simple1->setInt32(-123456789); $simple1->setFixed32(123456789); $simple1->setSint32(-123456789); $simple1->setSfixed32(-123456789); $simple1->setDouble(123456789.12345); $simple1->setInt64(-123456789123456789); $simple1->setUint64(123456789123456789); $simple1->setFixed64(123456789123456789); $simple1->setSint64(-123456789123456789); $simple1->setSfixed64(-123456789123456789); $simple2->merge($simple1); $this->assertSame(true, $simple2->getBool()); $this->assertSame("foo", $simple2->getString()); $this->assertSame($bytes, $simple2->getBytes()); $this->assertSame(12345.123, $simple2->getFloat()); $this->assertSame(123456789, $simple2->getUint32()); $this->assertSame(-123456789, $simple2->getInt32()); $this->assertSame(123456789, $simple2->getFixed32()); $this->assertSame(-123456789, $simple2->getSint32()); $this->assertSame(-123456789, $simple2->getSfixed32()); $this->assertSame(123456789.12345, $simple2->getDouble()); $this->assertSame(-123456789123456789, $simple2->getInt64()); $this->assertSame(123456789123456789, $simple2->getUint64()); $this->assertSame(123456789123456789, $simple2->getFixed64()); $this->assertSame(-123456789123456789, $simple2->getSint64()); $this->assertSame(-123456789123456789, $simple2->getSfixed64()); }