-
-
Notifications
You must be signed in to change notification settings - Fork 122
/
Copy pathSecretsRemoveCommandTest.php
46 lines (41 loc) · 1.63 KB
/
SecretsRemoveCommandTest.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
<?php
/*
* This file is part of the Symfony package.
*
* (c) Fabien Potencier <[email protected]>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Symfony\Bundle\FrameworkBundle\Tests\Command;
use PHPUnit\Framework\TestCase;
use Symfony\Bundle\FrameworkBundle\Command\SecretsRemoveCommand;
use Symfony\Bundle\FrameworkBundle\Secrets\AbstractVault;
use Symfony\Component\Console\Tester\CommandCompletionTester;
class SecretsRemoveCommandTest extends TestCase
{
/**
* @dataProvider provideCompletionSuggestions
*/
public function testComplete(bool $withLocalVault, array $input, array $expectedSuggestions)
{
$vault = $this->createMock(AbstractVault::class);
$vault->method('list')->willReturn(['SECRET' => null, 'OTHER_SECRET' => null]);
if ($withLocalVault) {
$localVault = $this->createMock(AbstractVault::class);
$localVault->method('list')->willReturn(['SECRET' => null]);
} else {
$localVault = null;
}
$command = new SecretsRemoveCommand($vault, $localVault);
$tester = new CommandCompletionTester($command);
$suggestions = $tester->complete($input);
$this->assertSame($expectedSuggestions, $suggestions);
}
public static function provideCompletionSuggestions(): iterable
{
yield 'name' => [true, [''], ['SECRET', 'OTHER_SECRET']];
yield '--local name (with local vault)' => [true, ['--local', ''], ['SECRET']];
yield '--local name (without local vault)' => [false, ['--local', ''], []];
}
}