@@ -16,8 +16,8 @@ class RegisterChangedSchemasCommandTest extends AbstractSchemaRegistryTestCase
1616 protected const DUMMY_SCHEMA = <<<EOF
1717 {
1818 "type": "record",
19- "name": "evolution ",
20- "namespace": "com.landoop ",
19+ "name": "test ",
20+ "namespace": "ch.jobcloud ",
2121 "doc": "This is a sample Avro schema to get you started. Please edit",
2222 "fields": [
2323 {
@@ -72,6 +72,11 @@ protected function generateFiles(int $numberOfFiles, string $contents = self::DU
7272 $ contents
7373 );
7474 });
75+
76+ file_put_contents (
77+ sprintf ('%s/test.txt ' , self ::SCHEMA_DIRECTORY ),
78+ 'bla '
79+ );
7580 }
7681
7782 public function testOutputWhenCommandRegisterWithSuccess ():void
@@ -113,7 +118,7 @@ public function testOutputWhenCommandSuccessWithSkipping():void
113118 /** @var MockObject|SchemaRegistryApi $schemaRegistryApi */
114119 $ schemaRegistryApi = $ this ->makeMock (SchemaRegistryApi::class, [
115120 'checkSchemaCompatibilityForVersion ' => TRUE ,
116- 'getSchemaByVersion ' => json_encode ( json_decode ( self :: DUMMY_SCHEMA )) ,
121+ 'getVersionForSchema ' => 1 ,
117122 'createNewSchemaVersion ' ,
118123 'getLatestSchemaVersion ' => '1 '
119124 ]);
@@ -138,6 +143,34 @@ public function testOutputWhenCommandSuccessWithSkipping():void
138143 self ::assertEquals (0 , $ commandTester ->getStatusCode ());
139144 }
140145
146+ public function testOutputWhenCommandFailsRegisteringASchema ():void
147+ {
148+ $ this ->generateFiles (1 , 'asdf ' );
149+
150+ /** @var MockObject|SchemaRegistryApi $schemaRegistryApi */
151+ $ schemaRegistryApi = $ this ->makeMock (SchemaRegistryApi::class, [
152+ 'checkSchemaCompatibilityForVersion ' => TRUE ,
153+ 'getVersionForSchema ' => null ,
154+ 'createNewSchemaVersion ' ,
155+ 'getLatestSchemaVersion ' => '1 '
156+ ]);
157+
158+ $ application = new Application ();
159+ $ application ->add (new RegisterChangedSchemasCommand ($ schemaRegistryApi ));
160+ $ command = $ application ->find ('kafka-schema-registry:register:changed ' );
161+ $ commandTester = new CommandTester ($ command );
162+
163+ $ commandTester ->execute ([
164+ 'schemaDirectory ' => self ::SCHEMA_DIRECTORY
165+ ]);
166+
167+ $ commandOutput = trim ($ commandTester ->getDisplay ());
168+
169+ self ::assertStringContainsString ('Skipping test.schema.1 for now because is not a schema we know about. ' , $ commandOutput );
170+
171+ self ::assertEquals (1 , $ commandTester ->getStatusCode ());
172+ }
173+
141174 public function testOutputTotalFailDueToIncompatibility ():void
142175 {
143176 $ this ->generateFiles (5 );
@@ -165,4 +198,4 @@ public function testOutputTotalFailDueToIncompatibility():void
165198
166199 self ::assertEquals (1 , $ commandTester ->getStatusCode ());
167200 }
168- }
201+ }
0 commit comments