Skip to content
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

[Console] increased code coverage of Output classes #21124

Conversation

FrancescoBorzi
Copy link
Contributor

Q A
Branch? 2.7
Bug fix? no
New feature? no
BC breaks? no
Deprecations? no
Tests pass? yes
License MIT

This PR increases the coverage of Output classes of the Console component from 80.81% to 94.95%

Copy link
Contributor

@linaori linaori left a comment

Choose a reason for hiding this comment

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

LGTM besides of my one remark

{
$output = new ConsoleOutput();
$output->setVerbosity(1);
$this->assertSame(1, $output->getVerbosity());
Copy link
Contributor

Choose a reason for hiding this comment

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

Not sure if you should use the constant instead, it might break if the constant value is changed

Copy link
Contributor Author

Choose a reason for hiding this comment

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

in this case it shouldn't matter, because the verbosity should be exactly the one set using the setter method

Copy link
Contributor

Choose a reason for hiding this comment

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

Well it does matter, because if the constant value would get changed to a string, lets say 'very verbose', 1 would not match anymore.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yes but here at unit test level we should only ensure that whatever value set by the setter is also returned by the getter, right?

Copy link
Contributor

Choose a reason for hiding this comment

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

In this particular case you could see it like an Enum, but php doesn't support Enums sadly.

You could probably compare it to:

public function setVerbosity(OutputVerbosityEnum $level);

When working with enum/constants, you should forget about the value and think in constant references only to prevent bugs in future versions.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

allright, changed 👍

@nicolas-grekas nicolas-grekas added this to the 2.7 milestone Jan 2, 2017
@Jean85
Copy link
Contributor

Jean85 commented Jan 3, 2017

LGTM too

Status: Reviewed

@nicolas-grekas
Copy link
Member

Thank you @ShinDarth.

nicolas-grekas added a commit that referenced this pull request Jan 6, 2017
…nDarth)

This PR was squashed before being merged into the 2.7 branch (closes #21124).

Discussion
----------

[Console] increased code coverage of Output classes

| Q             | A
| ------------- | ---
| Branch?       | 2.7
| Bug fix?      | no
| New feature?  | no
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| License       | MIT

This PR increases the coverage of Output classes of the Console component from 80.81% to 94.95%

Commits
-------

ab4ba23 [Console] increased code coverage of Output classes
@FrancescoBorzi FrancescoBorzi deleted the console_output_code_coverage_2.7 branch January 6, 2017 13:43
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.

None yet

5 participants