Unverified Commit f50204da authored by Paul Yang's avatar Paul Yang Committed by GitHub

Initialize well known type values (#6713) (#6714)

* Initialize well known type values

Also fixes #6667

* Revert unwanted change
parent 3f323c5b
This diff is collapsed.
...@@ -5,6 +5,7 @@ require_once('test_util.php'); ...@@ -5,6 +5,7 @@ require_once('test_util.php');
use Google\Protobuf\RepeatedField; use Google\Protobuf\RepeatedField;
use Google\Protobuf\GPBType; use Google\Protobuf\GPBType;
use Foo\TestStringValue;
use Foo\TestAny; use Foo\TestAny;
use Foo\TestEnum; use Foo\TestEnum;
use Foo\TestMessage; use Foo\TestMessage;
...@@ -167,6 +168,14 @@ class EncodeDecodeTest extends TestBase ...@@ -167,6 +168,14 @@ class EncodeDecodeTest extends TestBase
$this->assertSame("\"a\"", $m->serializeToJsonString()); $this->assertSame("\"a\"", $m->serializeToJsonString());
} }
public function testEncodeStringValue()
{
$m = new TestStringValue(['field' => new StringValue(['value' => ''])]);
var_dump($m->getField());
var_dump($m->serializeToJsonString());
$this->assertSame("{\"field\":\"\"}", $m->serializeToJsonString());
}
public function testDecodeTopLevelBytesValue() public function testDecodeTopLevelBytesValue()
{ {
$m = new BytesValue(); $m = new BytesValue();
......
...@@ -31,6 +31,7 @@ require_once('generated/Foo/TestPackedMessage.php'); ...@@ -31,6 +31,7 @@ require_once('generated/Foo/TestPackedMessage.php');
require_once('generated/Foo/TestPhpDoc.php'); require_once('generated/Foo/TestPhpDoc.php');
require_once('generated/Foo/TestRandomFieldOrder.php'); require_once('generated/Foo/TestRandomFieldOrder.php');
require_once('generated/Foo/TestReverseFieldOrder.php'); require_once('generated/Foo/TestReverseFieldOrder.php');
require_once('generated/Foo/TestStringValue.php');
require_once('generated/Foo/TestUnpackedMessage.php'); require_once('generated/Foo/TestUnpackedMessage.php');
require_once('generated/Foo/testLowerCaseMessage.php'); require_once('generated/Foo/testLowerCaseMessage.php');
require_once('generated/Foo/testLowerCaseEnum.php'); require_once('generated/Foo/testLowerCaseEnum.php');
......
syntax = "proto3"; syntax = "proto3";
import 'google/protobuf/any.proto'; import 'google/protobuf/any.proto';
import 'google/protobuf/wrappers.proto';
import 'google/protobuf/struct.proto'; import 'google/protobuf/struct.proto';
import 'proto/test_include.proto'; import 'proto/test_include.proto';
import 'proto/test_no_namespace.proto'; import 'proto/test_no_namespace.proto';
...@@ -207,3 +208,7 @@ enum testLowerCaseEnum { ...@@ -207,3 +208,7 @@ enum testLowerCaseEnum {
message TestAny { message TestAny {
google.protobuf.Any any = 1; google.protobuf.Any any = 1;
} }
message TestStringValue {
google.protobuf.StringValue field = 1;
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment