@@ -23,6 +23,9 @@ public function testDecodeTombstone()
23
23
$ message ->expects (self ::once ())->method ('getBody ' )->willReturn (null );
24
24
25
25
$ registry = $ this ->getMockForAbstractClass (AvroSchemaRegistryInterface::class);
26
+ $ registry ->expects (self ::never ())->method ('hasBodySchemaForTopic ' );
27
+ $ registry ->expects (self ::never ())->method ('hasKeySchemaForTopic ' );
28
+
26
29
$ recordSerializer = $ this ->getMockBuilder (RecordSerializer::class)->disableOriginalConstructor ()->getMock ();
27
30
$ recordSerializer ->expects (self ::never ())->method ('decodeMessage ' );
28
31
@@ -53,7 +56,8 @@ public function testDecodeWithSchema()
53
56
$ registry = $ this ->getMockForAbstractClass (AvroSchemaRegistryInterface::class);
54
57
$ registry ->expects (self ::once ())->method ('getBodySchemaForTopic ' )->willReturn ($ avroSchema );
55
58
$ registry ->expects (self ::once ())->method ('getKeySchemaForTopic ' )->willReturn ($ avroSchema );
56
-
59
+ $ registry ->expects (self ::once ())->method ('hasBodySchemaForTopic ' )->willReturn (true );
60
+ $ registry ->expects (self ::once ())->method ('hasKeySchemaForTopic ' )->willReturn (true );
57
61
58
62
$ recordSerializer = $ this ->getMockBuilder (RecordSerializer::class)->disableOriginalConstructor ()->getMock ();
59
63
$ recordSerializer ->expects (self ::at (0 ))->method ('decodeMessage ' )->with ($ message ->getKey (), $ schemaDefinition )->willReturn ('decoded-key ' );
@@ -77,7 +81,7 @@ public function testDecodeKeyMode()
77
81
$ avroSchema ->expects (self ::once ())->method ('getDefinition ' )->willReturn ($ schemaDefinition );
78
82
79
83
$ message = $ this ->getMockForAbstractClass (KafkaConsumerMessageInterface::class);
80
- $ message ->expects (self ::exactly (2 ))->method ('getTopicName ' )->willReturn ('test-topic ' );
84
+ $ message ->expects (self ::exactly (3 ))->method ('getTopicName ' )->willReturn ('test-topic ' );
81
85
$ message ->expects (self ::once ())->method ('getPartition ' )->willReturn (0 );
82
86
$ message ->expects (self ::once ())->method ('getOffset ' )->willReturn (1 );
83
87
$ message ->expects (self ::once ())->method ('getTimestamp ' )->willReturn (time ());
@@ -88,12 +92,14 @@ public function testDecodeKeyMode()
88
92
$ registry = $ this ->getMockForAbstractClass (AvroSchemaRegistryInterface::class);
89
93
$ registry ->expects (self ::never ())->method ('getBodySchemaForTopic ' );
90
94
$ registry ->expects (self ::once ())->method ('getKeySchemaForTopic ' )->willReturn ($ avroSchema );
95
+ $ registry ->expects (self ::once ())->method ('hasBodySchemaForTopic ' )->willReturn (false );
96
+ $ registry ->expects (self ::once ())->method ('hasKeySchemaForTopic ' )->willReturn (true );
91
97
92
98
93
99
$ recordSerializer = $ this ->getMockBuilder (RecordSerializer::class)->disableOriginalConstructor ()->getMock ();
94
100
$ recordSerializer ->expects (self ::once ())->method ('decodeMessage ' )->with ($ message ->getKey (), $ schemaDefinition )->willReturn ('decoded-key ' );
95
101
96
- $ decoder = new AvroDecoder ($ registry , $ recordSerializer, AvroDecoderInterface:: DECODE_KEY );
102
+ $ decoder = new AvroDecoder ($ registry , $ recordSerializer );
97
103
98
104
$ result = $ decoder ->decode ($ message );
99
105
@@ -111,7 +117,7 @@ public function testDecodeBodyMode()
111
117
$ avroSchema ->expects (self ::once ())->method ('getDefinition ' )->willReturn ($ schemaDefinition );
112
118
113
119
$ message = $ this ->getMockForAbstractClass (KafkaConsumerMessageInterface::class);
114
- $ message ->expects (self ::exactly (2 ))->method ('getTopicName ' )->willReturn ('test-topic ' );
120
+ $ message ->expects (self ::exactly (3 ))->method ('getTopicName ' )->willReturn ('test-topic ' );
115
121
$ message ->expects (self ::once ())->method ('getPartition ' )->willReturn (0 );
116
122
$ message ->expects (self ::once ())->method ('getOffset ' )->willReturn (1 );
117
123
$ message ->expects (self ::once ())->method ('getTimestamp ' )->willReturn (time ());
@@ -122,12 +128,13 @@ public function testDecodeBodyMode()
122
128
$ registry = $ this ->getMockForAbstractClass (AvroSchemaRegistryInterface::class);
123
129
$ registry ->expects (self ::once ())->method ('getBodySchemaForTopic ' )->willReturn ($ avroSchema );
124
130
$ registry ->expects (self ::never ())->method ('getKeySchemaForTopic ' );
125
-
131
+ $ registry ->expects (self ::once ())->method ('hasBodySchemaForTopic ' )->willReturn (true );
132
+ $ registry ->expects (self ::once ())->method ('hasKeySchemaForTopic ' )->willReturn (false );
126
133
127
134
$ recordSerializer = $ this ->getMockBuilder (RecordSerializer::class)->disableOriginalConstructor ()->getMock ();
128
135
$ recordSerializer ->expects (self ::once ())->method ('decodeMessage ' )->with ($ message ->getBody (), $ schemaDefinition )->willReturn (['test ' ]);
129
136
130
- $ decoder = new AvroDecoder ($ registry , $ recordSerializer, AvroDecoderInterface:: DECODE_BODY );
137
+ $ decoder = new AvroDecoder ($ registry , $ recordSerializer );
131
138
132
139
$ result = $ decoder ->decode ($ message );
133
140
0 commit comments