@@ -23,6 +23,9 @@ public function testDecodeTombstone()
2323 $ message ->expects (self ::once ())->method ('getBody ' )->willReturn (null );
2424
2525 $ registry = $ this ->getMockForAbstractClass (AvroSchemaRegistryInterface::class);
26+ $ registry ->expects (self ::never ())->method ('hasBodySchemaForTopic ' );
27+ $ registry ->expects (self ::never ())->method ('hasKeySchemaForTopic ' );
28+
2629 $ recordSerializer = $ this ->getMockBuilder (RecordSerializer::class)->disableOriginalConstructor ()->getMock ();
2730 $ recordSerializer ->expects (self ::never ())->method ('decodeMessage ' );
2831
@@ -53,7 +56,8 @@ public function testDecodeWithSchema()
5356 $ registry = $ this ->getMockForAbstractClass (AvroSchemaRegistryInterface::class);
5457 $ registry ->expects (self ::once ())->method ('getBodySchemaForTopic ' )->willReturn ($ avroSchema );
5558 $ 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 );
5761
5862 $ recordSerializer = $ this ->getMockBuilder (RecordSerializer::class)->disableOriginalConstructor ()->getMock ();
5963 $ recordSerializer ->expects (self ::at (0 ))->method ('decodeMessage ' )->with ($ message ->getKey (), $ schemaDefinition )->willReturn ('decoded-key ' );
@@ -77,7 +81,7 @@ public function testDecodeKeyMode()
7781 $ avroSchema ->expects (self ::once ())->method ('getDefinition ' )->willReturn ($ schemaDefinition );
7882
7983 $ 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 ' );
8185 $ message ->expects (self ::once ())->method ('getPartition ' )->willReturn (0 );
8286 $ message ->expects (self ::once ())->method ('getOffset ' )->willReturn (1 );
8387 $ message ->expects (self ::once ())->method ('getTimestamp ' )->willReturn (time ());
@@ -88,12 +92,14 @@ public function testDecodeKeyMode()
8892 $ registry = $ this ->getMockForAbstractClass (AvroSchemaRegistryInterface::class);
8993 $ registry ->expects (self ::never ())->method ('getBodySchemaForTopic ' );
9094 $ 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 );
9197
9298
9399 $ recordSerializer = $ this ->getMockBuilder (RecordSerializer::class)->disableOriginalConstructor ()->getMock ();
94100 $ recordSerializer ->expects (self ::once ())->method ('decodeMessage ' )->with ($ message ->getKey (), $ schemaDefinition )->willReturn ('decoded-key ' );
95101
96- $ decoder = new AvroDecoder ($ registry , $ recordSerializer, AvroDecoderInterface:: DECODE_KEY );
102+ $ decoder = new AvroDecoder ($ registry , $ recordSerializer );
97103
98104 $ result = $ decoder ->decode ($ message );
99105
@@ -111,7 +117,7 @@ public function testDecodeBodyMode()
111117 $ avroSchema ->expects (self ::once ())->method ('getDefinition ' )->willReturn ($ schemaDefinition );
112118
113119 $ 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 ' );
115121 $ message ->expects (self ::once ())->method ('getPartition ' )->willReturn (0 );
116122 $ message ->expects (self ::once ())->method ('getOffset ' )->willReturn (1 );
117123 $ message ->expects (self ::once ())->method ('getTimestamp ' )->willReturn (time ());
@@ -122,12 +128,13 @@ public function testDecodeBodyMode()
122128 $ registry = $ this ->getMockForAbstractClass (AvroSchemaRegistryInterface::class);
123129 $ registry ->expects (self ::once ())->method ('getBodySchemaForTopic ' )->willReturn ($ avroSchema );
124130 $ 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 );
126133
127134 $ recordSerializer = $ this ->getMockBuilder (RecordSerializer::class)->disableOriginalConstructor ()->getMock ();
128135 $ recordSerializer ->expects (self ::once ())->method ('decodeMessage ' )->with ($ message ->getBody (), $ schemaDefinition )->willReturn (['test ' ]);
129136
130- $ decoder = new AvroDecoder ($ registry , $ recordSerializer, AvroDecoderInterface:: DECODE_BODY );
137+ $ decoder = new AvroDecoder ($ registry , $ recordSerializer );
131138
132139 $ result = $ decoder ->decode ($ message );
133140
0 commit comments