diff --git a/module/CLI/config/cli.config.php b/module/CLI/config/cli.config.php
index a7a4fb9b..a1a34c16 100644
--- a/module/CLI/config/cli.config.php
+++ b/module/CLI/config/cli.config.php
@@ -21,6 +21,7 @@ return [
Command\Tag\ListTagsCommand::class,
Command\Tag\CreateTagCommand::class,
Command\Tag\RenameTagCommand::class,
+ Command\Tag\DeleteTagsCommand::class,
]
],
diff --git a/module/CLI/config/dependencies.config.php b/module/CLI/config/dependencies.config.php
index b02fa1c6..565ab8bc 100644
--- a/module/CLI/config/dependencies.config.php
+++ b/module/CLI/config/dependencies.config.php
@@ -24,6 +24,7 @@ return [
Command\Tag\ListTagsCommand::class => AnnotatedFactory::class,
Command\Tag\CreateTagCommand::class => AnnotatedFactory::class,
Command\Tag\RenameTagCommand::class => AnnotatedFactory::class,
+ Command\Tag\DeleteTagsCommand::class => AnnotatedFactory::class,
],
],
diff --git a/module/CLI/src/Command/Tag/DeleteTagsCommand.php b/module/CLI/src/Command/Tag/DeleteTagsCommand.php
new file mode 100644
index 00000000..0a4e271b
--- /dev/null
+++ b/module/CLI/src/Command/Tag/DeleteTagsCommand.php
@@ -0,0 +1,69 @@
+tagService = $tagService;
+ $this->translator = $translator;
+ parent::__construct();
+ }
+
+ protected function configure()
+ {
+ $this
+ ->setName('tag:delete')
+ ->setDescription($this->translator->translate('Deletes one or more tags.'))
+ ->addOption(
+ 'name',
+ 't',
+ InputOption::VALUE_REQUIRED | InputOption::VALUE_IS_ARRAY,
+ $this->translator->translate('The name of the tags to delete')
+ );
+ }
+
+ protected function execute(InputInterface $input, OutputInterface $output)
+ {
+ $tagNames = $input->getOption('name');
+ if (empty($tagNames)) {
+ $output->writeln(sprintf(
+ '%s',
+ $this->translator->translate('You have to provide at least one tag name')
+ ));
+ return;
+ }
+
+ $this->tagService->deleteTags($tagNames);
+ $output->writeln($this->translator->translate('Deleted tags') . sprintf(': ["%s"]', implode(
+ '", "',
+ $tagNames
+ )));
+ }
+}
diff --git a/module/CLI/test/Command/Tag/DeleteTagsCommandTest.php b/module/CLI/test/Command/Tag/DeleteTagsCommandTest.php
new file mode 100644
index 00000000..9498a450
--- /dev/null
+++ b/module/CLI/test/Command/Tag/DeleteTagsCommandTest.php
@@ -0,0 +1,68 @@
+tagService = $this->prophesize(TagServiceInterface::class);
+
+ $command = new DeleteTagsCommand($this->tagService->reveal(), Translator::factory([]));
+ $app = new Application();
+ $app->add($command);
+
+ $this->commandTester = new CommandTester($command);
+ }
+
+ /**
+ * @test
+ */
+ public function errorIsReturnedWhenNoTagsAreProvided()
+ {
+ $this->commandTester->execute([]);
+
+ $output = $this->commandTester->getDisplay();
+ $this->assertContains('You have to provide at least one tag name', $output);
+ }
+
+ /**
+ * @test
+ */
+ public function serviceIsInvokedOnSuccess()
+ {
+ $tagNames = ['foo', 'bar'];
+ /** @var MethodProphecy $deleteTags */
+ $deleteTags = $this->tagService->deleteTags($tagNames)->will(function () {
+ });
+
+ $this->commandTester->execute([
+ '--name' => $tagNames,
+ ]);
+ $output = $this->commandTester->getDisplay();
+
+ $this->assertContains(sprintf('Deleted tags: ["%s"]', implode('", "', $tagNames)), $output);
+ $deleteTags->shouldHaveBeenCalled();
+ }
+}