@@ -123,18 +123,21 @@ public function testGetSchemaById(): void
123123 $ api ->getSchemaById (1 );
124124 }
125125
126- public function testRegisterNewSchemaVersion (): void
126+ /**
127+ * @dataProvider schemaDataProvider
128+ **/
129+ public function testRegisterNewSchemaVersion (string $ testSchema , string $ expectedSchema ): void
127130 {
128131 $ httpClientMock = $ this ->getHttpClientMock ();
129132
130133 $ httpClientMock
131134 ->expects (self ::once ())
132135 ->method ('call ' )
133- ->with ('POST ' , sprintf ('subjects/%s/versions ' , self ::TEST_SUBJECT_NAME ), ['schema ' => ' [] ' ])
136+ ->with ('POST ' , sprintf ('subjects/%s/versions ' , self ::TEST_SUBJECT_NAME ), ['schema ' => $ expectedSchema ])
134137 ->willReturn ([]);
135138
136139 $ api = new KafkaSchemaRegistryApiClient ($ httpClientMock );
137- $ api ->registerNewSchemaVersion (self ::TEST_SUBJECT_NAME , self :: TEST_SCHEMA );
140+ $ api ->registerNewSchemaVersion (self ::TEST_SUBJECT_NAME , $ testSchema );
138141 }
139142
140143 public function testCheckSchemaCompatibilityForVersionFalseOnEmptyResponse (): void
@@ -161,7 +164,10 @@ public function testCheckSchemaCompatibilityForVersionFalseOnEmptyResponse(): vo
161164 self ::assertFalse ($ result );
162165 }
163166
164- public function testCheckSchemaCompatibilityForVersionTrue (): void
167+ /**
168+ * @dataProvider schemaDataProvider
169+ **/
170+ public function testCheckSchemaCompatibilityForVersionTrue (string $ testSchema , string $ expectedSchema ): void
165171 {
166172 $ httpClientMock = $ this ->getHttpClientMock ();
167173
@@ -171,14 +177,14 @@ public function testCheckSchemaCompatibilityForVersionTrue(): void
171177 ->with (
172178 'POST ' ,
173179 sprintf ('compatibility/subjects/%s/versions/%s ' , self ::TEST_SUBJECT_NAME , self ::TEST_VERSION ),
174- ['schema ' => ' [] ' ]
180+ ['schema ' => $ expectedSchema ]
175181 )
176182 ->willReturn (['is_compatible ' => true ]);
177183
178184 $ api = new KafkaSchemaRegistryApiClient ($ httpClientMock );
179185 $ result = $ api ->checkSchemaCompatibilityForVersion (
180186 self ::TEST_SUBJECT_NAME ,
181- self :: TEST_SCHEMA ,
187+ $ testSchema ,
182188 self ::TEST_VERSION
183189 );
184190
@@ -378,7 +384,10 @@ public function testSetDefaultCompatibilityLeve(): void
378384 self ::assertTrue ($ result );
379385 }
380386
381- public function testGetVersionForSchema (): void
387+ /**
388+ * @dataProvider schemaDataProvider
389+ **/
390+ public function testGetVersionForSchema (string $ testSchema , string $ expectedSchema ): void
382391 {
383392 $ httpClientMock = $ this ->getHttpClientMock ();
384393
@@ -388,12 +397,12 @@ public function testGetVersionForSchema(): void
388397 ->with (
389398 'POST ' ,
390399 sprintf ('subjects/%s ' , self ::TEST_SUBJECT_NAME ),
391- ['schema ' => ' [] ' ]
400+ ['schema ' => $ expectedSchema ]
392401 )
393402 ->willReturn (['version ' => self ::TEST_VERSION ]);
394403
395404 $ api = new KafkaSchemaRegistryApiClient ($ httpClientMock );
396- $ result = $ api ->getVersionForSchema (self ::TEST_SUBJECT_NAME , self :: TEST_SCHEMA );
405+ $ result = $ api ->getVersionForSchema (self ::TEST_SUBJECT_NAME , $ testSchema );
397406
398407 self ::assertSame ((string ) self ::TEST_VERSION , $ result );
399408 }
@@ -560,4 +569,13 @@ private function getHttpClientMock(): MockObject
560569 ->onlyMethods (['call ' ])
561570 ->getMock ();
562571 }
572+
573+ public function schemaDataProvider (): array
574+ {
575+ return [
576+ 'empty schema ' => ['{} ' , '[] ' ],
577+ 'schema ' => ['{"id": "string"} ' , '{"id":"string"} ' ],
578+ 'preserves zero fraction ' => ['{"double":0.0} ' , '{"double":0.0} ' ],
579+ ];
580+ }
563581}
0 commit comments