Roll back change to allow creating API keys with custom value

This commit is contained in:
Alejandro Celaya
2023-09-21 08:58:05 +02:00
parent f6b1cc7556
commit 6db46b50e9
8 changed files with 38 additions and 62 deletions

View File

@@ -9,7 +9,7 @@ use PHPUnit\Framework\Attributes\Test;
use PHPUnit\Framework\MockObject\MockObject;
use PHPUnit\Framework\TestCase;
use Shlinkio\Shlink\CLI\ApiKey\RoleResolverInterface;
use Shlinkio\Shlink\CLI\Command\Api\CreateKeyCommand;
use Shlinkio\Shlink\CLI\Command\Api\GenerateKeyCommand;
use Shlinkio\Shlink\Rest\ApiKey\Model\ApiKeyMeta;
use Shlinkio\Shlink\Rest\Entity\ApiKey;
use Shlinkio\Shlink\Rest\Service\ApiKeyServiceInterface;
@@ -17,7 +17,7 @@ use ShlinkioTest\Shlink\CLI\CliTestUtilsTrait;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Tester\CommandTester;
class CreateKeyCommandTest extends TestCase
class GenerateKeyCommandTest extends TestCase
{
use CliTestUtilsTrait;
@@ -30,7 +30,7 @@ class CreateKeyCommandTest extends TestCase
$roleResolver = $this->createMock(RoleResolverInterface::class);
$roleResolver->method('determineRoles')->with($this->isInstanceOf(InputInterface::class))->willReturn([]);
$command = new CreateKeyCommand($this->apiKeyService, $roleResolver);
$command = new GenerateKeyCommand($this->apiKeyService, $roleResolver);
$this->commandTester = $this->testerForCommand($command);
}
@@ -70,14 +70,4 @@ class CreateKeyCommandTest extends TestCase
'--name' => 'Alice',
]);
}
#[Test]
public function createsCustomApiKeyWhenProvided(): void
{
$this->apiKeyService->expects($this->once())->method('create')->with(
$this->callback(fn (ApiKeyMeta $meta) => $meta->key === 'my_custom_key'),
)->willReturn(ApiKey::create());
$this->commandTester->execute(['key' => 'my_custom_key']);
}
}