mirror of
https://github.com/shlinkio/shlink.git
synced 2024-11-25 02:10:18 -06:00
33 lines
1.1 KiB
PHP
33 lines
1.1 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace ShlinkioDbTest\Shlink\Rest\ApiKey\Repository;
|
|
|
|
use PHPUnit\Framework\Attributes\Test;
|
|
use Shlinkio\Shlink\Rest\ApiKey\Repository\ApiKeyRepository;
|
|
use Shlinkio\Shlink\Rest\Entity\ApiKey;
|
|
use Shlinkio\Shlink\TestUtils\DbTest\DatabaseTestCase;
|
|
|
|
class ApiKeyRepositoryTest extends DatabaseTestCase
|
|
{
|
|
private ApiKeyRepository $repo;
|
|
|
|
protected function setUp(): void
|
|
{
|
|
$this->repo = $this->getEntityManager()->getRepository(ApiKey::class);
|
|
}
|
|
|
|
#[Test]
|
|
public function initialApiKeyIsCreatedOnlyOfNoApiKeysExistYet(): void
|
|
{
|
|
self::assertCount(0, $this->repo->findAll());
|
|
self::assertNotNull($this->repo->createInitialApiKey('initial_value'));
|
|
self::assertCount(1, $this->repo->findAll());
|
|
self::assertCount(1, $this->repo->findBy(['key' => 'initial_value']));
|
|
self::assertNull($this->repo->createInitialApiKey('another_one'));
|
|
self::assertCount(1, $this->repo->findAll());
|
|
self::assertCount(0, $this->repo->findBy(['key' => 'another_one']));
|
|
}
|
|
}
|