Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Add various fixers for PHPUnit tests #16

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
OndraM merged 1 commit into alma-oss:master from OndraM:feature/phpunit-fixers
May 5, 2018

Conversation

@OndraM
Copy link
Contributor

@OndraM OndraM commented Apr 16, 2018

  • PhpUnitMockFixer: Ensure dedicated helper methods createMock() and createPartialMock() are used where possible instead of ->getMock().
  • PhpUnitNoExpectationAnnotationFixer: Use setExpectedException() instead of @expectedException annotation (see https://thephp.cc/news/2016/02/questioning-phpunit-best-practices)
  • PhpUnitSetUpTearDownVisibilityFixer: Visibility of setUp() and tearDown() method should be kept protected as defined in PHPUnit TestCase.

## Unreleased
- Add PHPUnit fixers:
- `PhpUnitMockFixer`: Ensure dedicated helper methods `createMock()` and `createPartialMock()` are used where possible instead of `->getMock()`.
- `PhpUnitNoExpectationAnnotationFixer`: Use `setExpectedException()` instead of `@expectedException` annotation.
Copy link
Contributor

@MortalFlesh MortalFlesh Apr 16, 2018

Choose a reason for hiding this comment

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

Is this one really necessary? I guess you are adding this because of older version of PHPUnit.. but since it is deprecated and there is more than this what should be fixed before upgrading to new PHPUnit version, I see this redundant.

Copy link
Contributor Author

@OndraM OndraM Apr 16, 2018
edited
Loading

Choose a reason for hiding this comment

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

What was deprecated and later removed in PHPUnit 6.0 was expectException(). The annotation is still supported (and not deprecated by PHPUnit) - https://github.com/sebastianbergmann/phpunit/blob/master/src/Util/Test.php#L353

Copy link

@TomasVotruba TomasVotruba May 4, 2018

Choose a reason for hiding this comment

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

@MortalFlesh What do you mean by "there is more than this what should be fixed before upgrading to new PHPUnit version"?

Copy link
Contributor

@MortalFlesh MortalFlesh May 4, 2018
edited
Loading

Choose a reason for hiding this comment

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

@TomasVotruba well I dont remember exactly, but for example namespaces of TestCase and of Mocks..

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@MortalFlesh Mocks are handled by the other fixer, and namespaced PHPUnit could be done using php_unit_namespaced fix pro php-cs-fixer or via Rector :)). But I don't think we need to enforce it here, right?

Copy link

@TomasVotruba TomasVotruba May 4, 2018

Choose a reason for hiding this comment

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

I see. So "add other PHPUnit fixers as well, not just these"?

Copy link

What need to be done here?

Copy link
Contributor Author

OndraM commented May 4, 2018
edited
Loading

@TomasVotruba I was off for two weeks, so I just need to get back to it :).

TomasVotruba reacted with thumbs up emoji

@OndraM OndraM merged commit 1ebd020 into alma-oss:master May 5, 2018
Copy link

👍

Btw, for more PHUnit polishments check out phpunit sets at @Rector

@carusogabriel took I really great job in covering them

Copy link
Contributor Author

OndraM commented May 5, 2018

Copy link

OndraM reacted with thumbs up emoji

@OndraM OndraM deleted the feature/phpunit-fixers branch May 5, 2018 22:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@MortalFlesh MortalFlesh MortalFlesh left review comments

@kubasimon kubasimon Awaiting requested review from kubasimon

@davidkmenta davidkmenta Awaiting requested review from davidkmenta

@dudla dudla Awaiting requested review from dudla

@kdosiodjinud kdosiodjinud Awaiting requested review from kdosiodjinud

@hokypierce hokypierce Awaiting requested review from hokypierce

@MarketaSebkova MarketaSebkova Awaiting requested review from MarketaSebkova

@florianjiri florianjiri Awaiting requested review from florianjiri

+3 more reviewers

@TomasVotruba TomasVotruba TomasVotruba left review comments

@jirinovak jirinovak jirinovak approved these changes

@legendik legendik legendik approved these changes

Reviewers whose approvals may not affect merge requirements

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

AltStyle によって変換されたページ (->オリジナル) /