Skip to content

[Console] Test convert CompletionInput into string #57570

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

int is missing from this @param dockblock.

*/
public static function fromTokens(array $tokens, int $currentIndex): self
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -133,4 +133,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()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We could perhaps use a dataProvider for this test to avoid duplicating code ?

Copy link
Contributor Author

@seriquynh seriquynh Jun 28, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Before adding this, I read ArgvInputTest and ArrayInputTest. There both don't use a dataProvider. Personally, I think use or not use dataProvider here is fine because there are only 2-3 cases.

If it's neccessary, I will implement. And we should implement for ArgvInputTest and ArrayInputTest too, shouldn't we?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh no, it's not necessary, it's really just a matter of separating the test data from the test itself, but you're right, the code is simple and it's all detail.

{
$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);
}
}
Loading
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy