Skip to content

Commit

Permalink
Merge branch '6.4' into 7.0
Browse files Browse the repository at this point in the history
* 6.4:
  [Filesystem][Mime] Fix transient tests
  Test convert CompletionInput into string
  • Loading branch information
nicolas-grekas committed Jun 28, 2024
2 parents 725da15 + 6edb536 commit 6de397c
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
2 changes: 1 addition & 1 deletion Completion/CompletionInput.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ public static function fromString(string $inputStr, int $currentIndex): self
* Create an input based on an COMP_WORDS token list.
*
* @param string[] $tokens the set of split tokens (e.g. COMP_WORDS or argv)
* @param $currentIndex the index of the cursor (e.g. COMP_CWORD)
* @param int $currentIndex the index of the cursor (e.g. COMP_CWORD)
*/
public static function fromTokens(array $tokens, int $currentIndex): self
{
Expand Down
15 changes: 15 additions & 0 deletions Tests/Completion/CompletionInputTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -132,4 +132,19 @@ public static function provideFromStringData()
yield ['bin/console cache:clear "multi word string"', ['bin/console', 'cache:clear', '"multi word string"']];
yield ['bin/console cache:clear \'multi word string\'', ['bin/console', 'cache:clear', '\'multi word string\'']];
}

public function testToString()
{
$input = CompletionInput::fromTokens(['foo', 'bar', 'baz'], 0);
$this->assertSame('foo| bar baz', (string) $input);

$input = CompletionInput::fromTokens(['foo', 'bar', 'baz'], 1);
$this->assertSame('foo bar| baz', (string) $input);

$input = CompletionInput::fromTokens(['foo', 'bar', 'baz'], 2);
$this->assertSame('foo bar baz|', (string) $input);

$input = CompletionInput::fromTokens(['foo', 'bar', 'baz'], 11);
$this->assertSame('foo bar baz |', (string) $input);
}
}

0 comments on commit 6de397c

Please sign in to comment.