1717 */
1818class DeleteAllSchemasCommandTest extends TestCase
1919{
20- public function testCommand (): void
20+ public function testCommandSoftDelete (): void
2121 {
2222 /** @var MockObject|KafkaSchemaRegistryApiClient $schemaRegistryApi */
2323 $ schemaRegistryApi = $ this ->getMockBuilder (KafkaSchemaRegistryApiClient::class)
@@ -41,4 +41,41 @@ public function testCommand(): void
4141 self ::assertEquals ('All schemas deleted. ' , $ commandOutput );
4242 self ::assertEquals (0 , $ commandTester ->getStatusCode ());
4343 }
44+
45+ public function testCommandHardDelete (): void
46+ {
47+ /** @var MockObject|KafkaSchemaRegistryApiClient $schemaRegistryApi */
48+ $ schemaRegistryApi = $ this ->getMockBuilder (KafkaSchemaRegistryApiClient::class)
49+ ->disableOriginalConstructor ()
50+ ->onlyMethods (['getSubjects ' , 'deleteSubject ' ])
51+ ->getMock ();
52+
53+ $ schemaRegistryApi ->expects (self ::once ())
54+ ->method ('getSubjects ' )
55+ ->willReturn (['schema1 ' ]);
56+
57+ $ schemaRegistryApi ->expects (self ::exactly (2 ))
58+ ->method ('deleteSubject ' )
59+ ->with (self ::callback (function ($ inputArgument ) {
60+ static $ input = 'schema1 ' ;
61+ if ($ inputArgument === $ input ) {
62+ $ input = $ input . '?permanent=true ' ;
63+ return true ;
64+ }
65+ return false ;
66+ }))
67+ ->willReturn ([]);
68+
69+ $ application = new Application ();
70+ $ application ->add (new DeleteAllSchemasCommand ($ schemaRegistryApi ));
71+ $ command = $ application ->find ('kafka-schema-registry:delete:all ' );
72+ $ commandTester = new CommandTester ($ command );
73+
74+ $ commandTester ->execute (['--hard ' => true ]);
75+
76+ $ commandOutput = trim ($ commandTester ->getDisplay ());
77+
78+ self ::assertEquals ('All schemas deleted. ' , $ commandOutput );
79+ self ::assertEquals (0 , $ commandTester ->getStatusCode ());
80+ }
4481}
0 commit comments