Skip to content

Commit 6473d44

Browse files
committed
Test convert CompletionInput into string
1 parent aa73115 commit 6473d44

File tree

2 files changed

+16
-1
lines changed

2 files changed

+16
-1
lines changed

Diff for: Completion/CompletionInput.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ public static function fromString(string $inputStr, int $currentIndex): self
5353
* Create an input based on an COMP_WORDS token list.
5454
*
5555
* @param string[] $tokens the set of split tokens (e.g. COMP_WORDS or argv)
56-
* @param $currentIndex the index of the cursor (e.g. COMP_CWORD)
56+
* @param int $currentIndex the index of the cursor (e.g. COMP_CWORD)
5757
*/
5858
public static function fromTokens(array $tokens, int $currentIndex): self
5959
{

Diff for: Tests/Completion/CompletionInputTest.php

+15
Original file line numberDiff line numberDiff line change
@@ -133,4 +133,19 @@ public static function provideFromStringData()
133133
yield ['bin/console cache:clear "multi word string"', ['bin/console', 'cache:clear', '"multi word string"']];
134134
yield ['bin/console cache:clear \'multi word string\'', ['bin/console', 'cache:clear', '\'multi word string\'']];
135135
}
136+
137+
public function testToString()
138+
{
139+
$input = CompletionInput::fromTokens(['foo', 'bar', 'baz'], 0);
140+
$this->assertSame('foo| bar baz', (string) $input);
141+
142+
$input = CompletionInput::fromTokens(['foo', 'bar', 'baz'], 1);
143+
$this->assertSame('foo bar| baz', (string) $input);
144+
145+
$input = CompletionInput::fromTokens(['foo', 'bar', 'baz'], 2);
146+
$this->assertSame('foo bar baz|', (string) $input);
147+
148+
$input = CompletionInput::fromTokens(['foo', 'bar', 'baz'], 11);
149+
$this->assertSame('foo bar baz |', (string) $input);
150+
}
136151
}

0 commit comments

Comments
 (0)