diff --git a/composer.json b/composer.json index a9b60f12..159d64bd 100644 --- a/composer.json +++ b/composer.json @@ -92,6 +92,7 @@ "ShlinkioCliTest\\Shlink\\CLI\\": "module/CLI/test-cli", "ShlinkioTest\\Shlink\\Rest\\": "module/Rest/test", "ShlinkioApiTest\\Shlink\\Rest\\": "module/Rest/test-api", + "ShlinkioDbTest\\Shlink\\Rest\\": "module/Rest/test-db", "ShlinkioTest\\Shlink\\Core\\": "module/Core/test", "ShlinkioDbTest\\Shlink\\Core\\": "module/Core/test-db" }, diff --git a/module/Rest/test-db/ApiKey/Repository/ApiKeyRepositoryTest.php b/module/Rest/test-db/ApiKey/Repository/ApiKeyRepositoryTest.php new file mode 100644 index 00000000..ae6ab0a0 --- /dev/null +++ b/module/Rest/test-db/ApiKey/Repository/ApiKeyRepositoryTest.php @@ -0,0 +1,31 @@ +repo = $this->getEntityManager()->getRepository(ApiKey::class); + } + + /** @test */ + public function initialApiKeyIsCreatedOnlyOfNoApiKeysExistYet(): void + { + self::assertCount(0, $this->repo->findAll()); + $this->repo->createInitialApiKey('initial_value'); + self::assertCount(1, $this->repo->findAll()); + self::assertCount(1, $this->repo->findBy(['key' => 'initial_value'])); + $this->repo->createInitialApiKey('another_one'); + self::assertCount(1, $this->repo->findAll()); + self::assertCount(0, $this->repo->findBy(['key' => 'another_one'])); + } +}