File tree Expand file tree Collapse file tree 3 files changed +158
-0
lines changed Expand file tree Collapse file tree 3 files changed +158
-0
lines changed Original file line number Diff line number Diff line change
1
+ syntax = "proto3" ;
2
+
3
+ package foo.tester ;
4
+
5
+ import "google/protobuf/wrappers.proto" ;
6
+ import "google/protobuf/field_mask.proto" ;
7
+
8
+ message TestSuite {
9
+ repeated TestCase test_cases = 1 ;
10
+ }
11
+
12
+ message TestCase {
13
+ string description = 1 ;
14
+ Resource original_resource = 2 ;
15
+ Resource modified_resource = 3 ;
16
+ google.protobuf.FieldMask expected_mask = 4 ;
17
+ }
18
+
19
+ message Resource {
20
+ google.protobuf.StringValue wrapper = 1 ;
21
+ Foo foo = 2 ;
22
+ repeated Foo foos = 3 ;
23
+ }
24
+
25
+ message Foo {
26
+ int64 num = 1 ;
27
+ Bar bar = 2 ;
28
+ repeated Bar bars = 3 ;
29
+ }
30
+
31
+ message Bar {
32
+ int64 num = 1 ;
33
+ google.protobuf.BoolValue nested_wrapper = 2 ;
34
+ }
Original file line number Diff line number Diff line change 7
7
use Google \Protobuf \GPBType ;
8
8
use Foo \Errors \ErrorCode ;
9
9
use Foo \Errors \AuthenticationErrorEnum \AuthenticationError ;
10
+ use Foo \Tester \TestSuite ;
10
11
use Foo \TestInt32Value ;
11
12
use Foo \TestInt64Value ;
12
13
use Foo \TestUInt32Value ;
39
40
40
41
class EncodeDecodeTest extends TestBase
41
42
{
43
+ public function testIssue7 ()
44
+ {
45
+ $ ts = new TestSuite ();
46
+ $ ts ->mergeFromJsonString (file_get_contents (sprintf (
47
+ '%s%stest_cases.json ' ,
48
+ dirname (dirname (__FILE__ )),
49
+ DIRECTORY_SEPARATOR
50
+ )));
51
+ $ this ->assertEquals (9 , $ ts ->getTestCases ()->count ());
52
+ }
53
+
42
54
public function testIssue3 ()
43
55
{
44
56
$ m = new ErrorCode ([
Original file line number Diff line number Diff line change
1
+ {
2
+ "test_cases" : [{
3
+ "description" : " Modify scalar in a wrapper proto" ,
4
+ "original_resource" : {
5
+ "wrapper" : " a"
6
+ },
7
+ "modified_resource" : {
8
+ "wrapper" : " b"
9
+ },
10
+ "expected_mask" : " wrapper"
11
+ }, {
12
+ "description" : " Create wrapper proto" ,
13
+ "original_resource" : {
14
+ },
15
+ "modified_resource" : {
16
+ "wrapper" : " a"
17
+ },
18
+ "expected_mask" : " wrapper"
19
+ }, {
20
+ "description" : " Modify element in a repeated field" ,
21
+ "original_resource" : {
22
+ "foos" : [{
23
+ "num" : 1
24
+ }, {
25
+ "num" : 2
26
+ }]
27
+ },
28
+ "modified_resource" : {
29
+ "foos" : [{
30
+ "num" : 1
31
+ }, {
32
+ "num" : 3
33
+ }]
34
+ },
35
+ "expected_mask" : " foos"
36
+ }, {
37
+ "description" : " Modify element in a nested repeated field" ,
38
+ "original_resource" : {
39
+ "foos" : [{
40
+ "bars" : [{
41
+ "num" : 1
42
+ }]
43
+ }]
44
+ },
45
+ "modified_resource" : {
46
+ "foos" : [{
47
+ "bars" : [{
48
+ "num" : 2
49
+ }]
50
+ }]
51
+ },
52
+ "expected_mask" : " foos"
53
+ }, {
54
+ "description" : " Create submessage" ,
55
+ "original_resource" : {
56
+ },
57
+ "modified_resource" : {
58
+ "foo" : {
59
+ "num" : 1
60
+ }
61
+ },
62
+ "expected_mask" : " foo.num"
63
+ }, {
64
+ "description" : " Modify submessage" ,
65
+ "original_resource" : {
66
+ "foo" : {
67
+ }
68
+ },
69
+ "modified_resource" : {
70
+ "foo" : {
71
+ "num" : 1
72
+ }
73
+ },
74
+ "expected_mask" : " foo.num"
75
+ }, {
76
+ "description" : " Clear submessage" ,
77
+ "original_resource" : {
78
+ "foo" : {
79
+ }
80
+ },
81
+ "modified_resource" : {
82
+ },
83
+ "expected_mask" : " foo"
84
+ }, {
85
+ "description" : " No change" ,
86
+ "original_resource" : {
87
+ "wrapper" : " a" ,
88
+ "foos" : [{
89
+ "num" : 1
90
+ }]
91
+ },
92
+ "modified_resource" : {
93
+ "wrapper" : " a" ,
94
+ "foos" : [{
95
+ "num" : 1
96
+ }]
97
+ },
98
+ "expected_mask" : {}
99
+ }, {
100
+ "description" : " Create message with nested wrapper" ,
101
+ "original_resource" : {
102
+ },
103
+ "modified_resource" : {
104
+ "foo" : {
105
+ "bar" : {
106
+ "nested_wrapper" : true
107
+ }
108
+ }
109
+ },
110
+ "expected_mask" : " foo.bar.nested_wrapper"
111
+ }
112
+ ]}
You can’t perform that action at this time.
0 commit comments