@@ -368,14 +368,42 @@ public function testExportSchema()
368
368
->willReturn ('{"name": "test"} ' );
369
369
$ schemaRegistry = $ this ->getMockForAbstractClass (SchemaRegistryInterface::class);
370
370
371
-
372
371
$ merger = new SchemaMerger ($ schemaRegistry );
373
372
$ merger ->exportSchema ($ schemaTemplate );
374
373
375
374
self ::assertFileExists ('/tmp/test.avsc ' );
376
375
unlink ('/tmp/test.avsc ' );
377
376
}
378
377
378
+ public function testExportSchemaWithExcludingNamespaces ()
379
+ {
380
+ $ mergedSchema = '{"type":"record","name":"schema","namespace":"root.level.entity","schema_level":"root","fields":[{"name":"rootField1","type":{"type":"record","name":"embeddedSchema","fields":[{"name":"embeddedField","type":["null","string"],"default":null}]}},{"name":"rootField2","type":["null","root.level.entity.embeddedSchema"],"default":null}]} ' ;
381
+
382
+ $ expectedSchema = '{"type":"record","name":"schema","namespace":"root.level.entity","fields":[{"name":"rootField1","type":{"type":"record","name":"embeddedSchema","fields":[{"name":"embeddedField","type":["null","string"],"default":null}]}},{"name":"rootField2","type":["null","embeddedSchema"],"default":null}]} ' ;
383
+
384
+ $ schemaTemplate = $ this ->getMockForAbstractClass (SchemaTemplateInterface::class);
385
+ $ schemaTemplate
386
+ ->expects (self ::once ())
387
+ ->method ('getSchemaDefinition ' )
388
+ ->willReturn ($ mergedSchema );
389
+
390
+ $ schemaTemplate
391
+ ->expects (self ::once ())
392
+ ->method ('getFilename ' )
393
+ ->willReturn ('test.avsc ' );
394
+
395
+ $ schemaRegistry = $ this ->getMockForAbstractClass (SchemaRegistryInterface::class);
396
+
397
+ $ merger = new SchemaMerger ($ schemaRegistry );
398
+ $ merger ->exportSchema ($ schemaTemplate , false , true , true );
399
+ file_put_contents ('/tmp/test_expected_schema.avsc ' , $ expectedSchema );
400
+
401
+ self ::assertFileExists ('/tmp/test.avsc ' );
402
+ self ::assertFileEquals ('/tmp/test_expected_schema.avsc ' , '/tmp/test.avsc ' );
403
+ unlink ('/tmp/test_expected_schema.avsc ' );
404
+ unlink ('/tmp/test.avsc ' );
405
+ }
406
+
379
407
public function testExportSchemaPrimitiveWithWrongOptions ()
380
408
{
381
409
$ schemaTemplate = $ this ->getMockForAbstractClass (SchemaTemplateInterface::class);
0 commit comments