Skip to content

Commit

Permalink
Merge branch '7.0' into 7.1
Browse files Browse the repository at this point in the history
* 7.0:
  Allow service locators to be ordered by priority.
  [Filesystem][Mime] Fix transient tests
  Test convert CompletionInput into string
  • Loading branch information
nicolas-grekas committed Jun 28, 2024
2 parents 9b008f2 + 6de397c commit 0aa29ca
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 0aa29ca

Please sign in to comment.