Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitc3522c4

Browse files
committed
feature#43653 [PasswordHasher] Add autocompletion for security commands (noniagriconomie)
This PR was merged into the 5.4 branch.Discussion----------[PasswordHasher] Add autocompletion for security commands| Q | A| ------------- | ---| Branch? | 5.4| Bug fix? | no| New feature? | yes| Deprecations? | no| Tickets | Ref#43594| License | MIT| Doc PR |Related to#43594 (comment)I have a question regarding `@wouterj` 's comment on the issueAlso, the `password` is the first argument right now, should we swap it to be after `user-class`?Still WIP, I am using `fish` and want to test as well#43641Commits-------49f45a9 [Console] Add autocompletion for security commands
2 parents375a89a +49f45a9 commitc3522c4

File tree

2 files changed

+40
-0
lines changed

2 files changed

+40
-0
lines changed

‎src/Symfony/Component/PasswordHasher/Command/UserPasswordHashCommand.php‎

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@
1212
namespaceSymfony\Component\PasswordHasher\Command;
1313

1414
useSymfony\Component\Console\Command\Command;
15+
useSymfony\Component\Console\Completion\CompletionInput;
16+
useSymfony\Component\Console\Completion\CompletionSuggestions;
1517
useSymfony\Component\Console\Exception\InvalidArgumentException;
1618
useSymfony\Component\Console\Exception\RuntimeException;
1719
useSymfony\Component\Console\Input\InputArgument;
@@ -168,6 +170,15 @@ protected function execute(InputInterface $input, OutputInterface $output): int
168170
return0;
169171
}
170172

173+
publicfunctioncomplete(CompletionInput$input,CompletionSuggestions$suggestions):void
174+
{
175+
if ($input->mustSuggestArgumentValuesFor('user-class')) {
176+
$suggestions->suggestValues($this->userClasses);
177+
178+
return;
179+
}
180+
}
181+
171182
/**
172183
* Create the password question to ask the user for the password to be hashed.
173184
*/

‎src/Symfony/Component/PasswordHasher/Tests/Command/UserPasswordHashCommandTest.php‎

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
namespaceSymfony\Component\PasswordHasher\Tests\Command;
1313

1414
usePHPUnit\Framework\TestCase;
15+
useSymfony\Component\Console\Tester\CommandCompletionTester;
1516
useSymfony\Component\Console\Tester\CommandTester;
1617
useSymfony\Component\PasswordHasher\Command\UserPasswordHashCommand;
1718
useSymfony\Component\PasswordHasher\Hasher\NativePasswordHasher;
@@ -286,6 +287,34 @@ public function testThrowsExceptionOnNoConfiguredHashers()
286287
], ['interactive' =>false]);
287288
}
288289

290+
/**
291+
* @dataProvider provideCompletionSuggestions
292+
*/
293+
publicfunctiontestCompletionSuggestions(array$input,array$expectedSuggestions)
294+
{
295+
if (!class_exists(CommandCompletionTester::class)) {
296+
$this->markTestSkipped('Test command completion requires symfony/console 5.4+.');
297+
}
298+
299+
$command =newUserPasswordHashCommand($this->createMock(PasswordHasherFactoryInterface::class), ['App\Entity\User']);
300+
$tester =newCommandCompletionTester($command);
301+
302+
$this->assertSame($expectedSuggestions,$tester->complete($input));
303+
}
304+
305+
publicfunctionprovideCompletionSuggestions()
306+
{
307+
yield'user_class_empty' => [
308+
[''],
309+
['App\Entity\User'],
310+
];
311+
312+
yield'user_class_given' => [
313+
['App'],
314+
['App\Entity\User'],
315+
];
316+
}
317+
289318
protectedfunctionsetUp():void
290319
{
291320
$this->colSize =getenv('COLUMNS');

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp