Skip to content

[Console] Improve code coverage #19328

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

Conversation

geoffrey-brier
Copy link
Contributor

@geoffrey-brier geoffrey-brier commented Jul 10, 2016

Q A
Branch? master
Bug fix? no
New feature? no
BC breaks? no
Deprecations? no
Tests pass? yes
Fixed tickets
License MIT
Doc PR

Hello,

I've added a few tests to improve the console component code coverage (around 3%).

What do you think ?

@geoffrey-brier geoffrey-brier force-pushed the improve-console-component-code-coverage branch 3 times, most recently from 689e2e4 to b122d36 Compare July 10, 2016 12:46
@@ -594,6 +594,8 @@ public function all($namespace = null)
*/
public static function getAbbreviations($names)
{
@trigger_error(sprintf('%s is deprecated as of 3.2 and will be removed in 4.0.', __METHOD__), E_USER_DEPRECATED);
Copy link
Contributor

Choose a reason for hiding this comment

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

Missing deprecation in the phpdoc.

Copy link
Member

Choose a reason for hiding this comment

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

what's the rationale for this deprecation?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@nicolas-grekas While looking for code not covered I noticed that this method wasn't used anywhere so I thought that it should be removed. What's your opinion ?

Copy link
Member

Choose a reason for hiding this comment

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

@geoffrey-brier in any case, this has nothing to do in a PR adding more code coverage

Copy link
Member

Choose a reason for hiding this comment

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

I'd say it's not related to this PR, and if this is the only reason, let's wait for a better reason before deprecating it

Copy link
Contributor Author

Choose a reason for hiding this comment

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

All right, I'm gonna remove it then :)

@geoffrey-brier geoffrey-brier force-pushed the improve-console-component-code-coverage branch from b122d36 to 366c69d Compare July 10, 2016 14:52
@xabbuh
Copy link
Member

xabbuh commented Jul 10, 2016

Test improvements should be done on the 2.7 branch.

{
$application = new CustomDefaultCommandApplication();

$this->assertNull($application->add(new \DisabledCommand()));
Copy link
Contributor

Choose a reason for hiding this comment

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

Here $application is always new object so it will null and you assert it should be null. I think it is not helpful testcase.

Copy link
Contributor Author

@geoffrey-brier geoffrey-brier Jul 11, 2016

Choose a reason for hiding this comment

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

Should I remove the test then ?

Copy link
Contributor

Choose a reason for hiding this comment

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

I think change the logic of test case otherwise you can remove this test

Copy link
Contributor

Choose a reason for hiding this comment

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

Here $application is always new object so it will null and you assert it should be null. I think it is not helpful testcase.

No the assert is on the return value of the call to add(), which passes while it shouldn't.
The PHPDoc states it will always return the command:
https://github.com/symfony/symfony/blob/master/src/Symfony/Component/Console/Application.php#L379

but it doesn't:
https://github.com/symfony/symfony/blob/master/src/Symfony/Component/Console/Application.php#L388

I've opened a PR to correct it; #19389

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ok, I'll remove the test case then

@stof
Copy link
Member

stof commented Jul 11, 2016

Deprecations? no

This is wrong. Your PR is adding a deprecation (which looks wrong to me)

@fabpot
Copy link
Member

fabpot commented Jul 18, 2016

@geoffrey-brier What's the status of your work here?

@geoffrey-brier geoffrey-brier force-pushed the improve-console-component-code-coverage branch from 366c69d to a9e4ff5 Compare July 19, 2016 16:20
@geoffrey-brier
Copy link
Contributor Author

@fabpot I believe I fixed everyone's comment. But as stated by @xabbuh I should reopen the PR against the 2.7 branch. What do you think ?

@geoffrey-brier geoffrey-brier force-pushed the improve-console-component-code-coverage branch 3 times, most recently from 0f2b435 to ebb2770 Compare July 26, 2016 08:54
@nicolas-grekas
Copy link
Member

👍

public function formatMemoryProvider()
{
return array(
array(0, '0 B'),
Copy link
Contributor

Choose a reason for hiding this comment

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

Is this kind of alignment allowed by the CS standards?

Copy link
Contributor

Choose a reason for hiding this comment

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

array_element_white_space_after_comma [symfony]
In array declaration, there MUST be a whitespace after each comma.

(https://github.com/FriendsOfPHP/PHP-CS-Fixer/blob/1.11/README.rst)
so no rule about how much whitespace other than something ^_^

Copy link
Contributor

Choose a reason for hiding this comment

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

I know there are many implicit rules that aren't yet declared @SpacePossum, that's why I'm asking. The reasons I have in mind are the very same that moved us to unalign = and => in the past (#14438), given the code maintainability turns harder when any update to this "structures" is required.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@phansys I formatted the array this way to be consistent with what's already in this file (take a look at the formatTimeProvider function).

Copy link
Contributor

Choose a reason for hiding this comment

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

Sure @geoffrey-brier, thanks for pointing and putting the sight on this.

@geoffrey-brier geoffrey-brier force-pushed the improve-console-component-code-coverage branch from ebb2770 to 38d3b27 Compare July 27, 2016 11:37
@geoffrey-brier geoffrey-brier force-pushed the improve-console-component-code-coverage branch from 38d3b27 to a4a3302 Compare July 27, 2016 11:47
@@ -572,6 +572,8 @@ public function getSynopsis($short = false)
* Add a command usage example.
*
* @param string $usage The usage, it'll be prefixed with the command name
*
* @return Command
Copy link
Member

Choose a reason for hiding this comment

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

should be @return self (as in other places in the code base where fluent interface are in defined)

Copy link
Contributor

@SpacePossum SpacePossum Jul 28, 2016

Choose a reason for hiding this comment

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

it could be even more strict and state @return $this as not only a Command class instance is returned but the instance itself is always returned (for ref. https://github.com/php-fig/fig-standards/blob/master/proposed/phpdoc.md#keyword point 13 vs. 15).

Copy link
Member

Choose a reason for hiding this comment

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

ok for me

@geoffrey-brier geoffrey-brier force-pushed the improve-console-component-code-coverage branch from a4a3302 to c17be71 Compare July 28, 2016 11:52
@nicolas-grekas
Copy link
Member

Status: reviewed

@nicolas-grekas
Copy link
Member

Reminder: for 2.7

@geoffrey-brier
Copy link
Contributor Author

@nicolas-grekas Should I close the PR, rebase it againt the 2.7 branch and reopen a new one ?

@@ -572,6 +572,8 @@ public function getSynopsis($short = false)
* Add a command usage example.
*
* @param string $usage The usage, it'll be prefixed with the command name
*
* @return $this
Copy link
Member

Choose a reason for hiding this comment

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

we are using @return self everywhere else. Not sure which one is the right one, but I didn't find any occurrence of @return $this in Symfony codebase.

Copy link
Contributor

Choose a reason for hiding this comment

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

that is because of my suggestion I'm afraid
#19328 (comment)
sorry if misleading the pr!

@fabpot
Copy link
Member

fabpot commented Jul 28, 2016

This one is not mergeable as is. As it contains some small fixes, it should be split. If possible, I would prefer a PR on 2.7 first.

@fabpot
Copy link
Member

fabpot commented Aug 15, 2016

@geoffrey-brier I'm closing this one as it cannot be merge as is. Feel free to reopen smaller and targeted PR. Thanks for your understanding.

@fabpot fabpot closed this Aug 15, 2016
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.

10 participants