Skip to content

fix unused variable warning #16498

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

Closed
wants to merge 4 commits into from
Closed

fix unused variable warning #16498

wants to merge 4 commits into from

Conversation

eventhorizonpl
Copy link

Hi,

This PR fixes a bug in ClockMock class.

Best regards,
Michal

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

PhpUnit tests coverage p2

PhpUnit tests coverage p3

PhpUnit tests coverage p4

PhpUnit tests coverage p5

PhpUnit tests coverage p6

PhpUnit tests coverage p7
*/
public function testRegisterFalse($mode)
{
$this->assertNull(DeprecationErrorHandler::register($mode));
Copy link
Member

Choose a reason for hiding this comment

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

this doesn't test anything. I don't think we should add tests to make test coverage higher, test coverage should not be the goal.

Copy link
Author

Choose a reason for hiding this comment

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

It tests that this method works. For example - there was use of not defined variable in ClockMock::microtime. Such cases can be spotted with such tests.

Copy link
Member

Choose a reason for hiding this comment

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

this creates global side effects (changing the error handler)
I'd remove this test entirely: DeprecationErrorHandler can't be unit tested but only functionally tested, which is already the case (because we use it quite extensively on the travis matrix, and it works)

$this->assertEquals(0, ClockMock::sleep($sleep));
$t2 = ClockMock::time();

$this->assertLessThanOrEqual($sleep, $t2 - $t1);
Copy link
Member

Choose a reason for hiding this comment

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

assertSame should work and is more strict thus better, isn't it?

@eventhorizonpl eventhorizonpl changed the title PhpUnit tests coverage p1 fix unused variable warning Nov 24, 2015
@eventhorizonpl
Copy link
Author

@nicolas-grekas

Thanks for review. For now I decided to just fix one bug.

@fabpot
Copy link
Member

fabpot commented Nov 25, 2015

Thank you @eventhorizonpl.

@fabpot fabpot closed this in 3ed092e Nov 25, 2015
This was referenced Nov 30, 2015
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.

7 participants