diff --git a/module/CLI/test/Command/Api/InitialApiKeyCommandTest.php b/module/CLI/test/Command/Api/InitialApiKeyCommandTest.php new file mode 100644 index 00000000..e0732aab --- /dev/null +++ b/module/CLI/test/Command/Api/InitialApiKeyCommandTest.php @@ -0,0 +1,56 @@ +apiKeyService = $this->createMock(ApiKeyServiceInterface::class); + $this->commandTester = $this->testerForCommand(new InitialApiKeyCommand($this->apiKeyService)); + } + + #[Test, DataProvider('provideParams')] + public function initialKeyIsCreatedWithProvidedValue(?ApiKey $result, bool $verbose, string $expectedOutput): void + { + $this->apiKeyService->expects($this->once())->method('createInitial')->with('the_key')->willReturn($result); + + $this->commandTester->execute( + ['apiKey' => 'the_key'], + ['verbosity' => $verbose ? OutputInterface::VERBOSITY_VERBOSE : OutputInterface::VERBOSITY_NORMAL], + ); + $output = $this->commandTester->getDisplay(); + + self::assertEquals($expectedOutput, $output); + } + + public static function provideParams(): iterable + { + yield 'api key created, no verbose' => [ApiKey::create(), false, '']; + yield 'api key created, verbose' => [ApiKey::create(), true, '']; + yield 'no api key created, no verbose' => [null, false, '']; + yield 'no api key created, verbose' => [null, true, <<