public function testSimpleMessageFromArray() { $simple = Simple::fromArray(['bool' => true, 'string' => "foo", 'bytes' => "bar", 'float' => 12345.123, 'fixed32' => 123456789, 'uint32' => 123456789, 'sfixed32' => -123456789, 'sint32' => -123456789, 'int32' => -123456789, 'double' => 123456789.12345, 'int64' => -123456789123456789, 'uint64' => 123456789123456789, 'fixed64' => 123456789123456789, 'sfixed64' => -123456789123456789, 'sint64' => -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 = Simple::fromArray([]); $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()); }