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

Conversation

seriquynh
Copy link
Contributor

@seriquynh seriquynh commented Jun 28, 2024

Q A
Branch? 5.4
Bug fix? no
New feature? no
Deprecations? no
Issues N/A
License MIT

CompletionInput can be converted into string but there are no tests for it. So, I a simple test here based on it's current behavior.

@@ -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.

@seriquynh
Copy link
Contributor Author

seriquynh commented Jun 28, 2024

It's weird. I think the CI error might not be related to this test. Am I right?

Copy link
Member

@nicolas-grekas nicolas-grekas left a comment

Choose a reason for hiding this comment

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

Failures unrelated indeed.

@@ -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.

@nicolas-grekas
Copy link
Member

Thank you @seriquynh.

@nicolas-grekas nicolas-grekas merged commit 7beff57 into symfony:5.4 Jun 28, 2024
10 of 12 checks passed
@seriquynh seriquynh deleted the add-test branch June 28, 2024 09:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants