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

Add option to allow having an undercore in test methods #257

Merged
merged 1 commit into from Sep 21, 2015

Conversation

JeroenDeDauw
Copy link
Contributor

This addresses #251.

The first commit can be merged on its own via #255

@JeroenDeDauw
Copy link
Contributor Author

@JanZerebecki I invoke your great regex wizard skills to enhance this PR and be closer to the rules described in #251 :)

Then I just need to find a git wizard as well to get rid of the ant-task.rst file of doom.

private function isValid($methodName)
{
if ($this->getBooleanProperty('allow-underscore-test') && strpos($methodName, 'test') === 0) {
return preg_match('/^test[a-zA-Z0-9]*([_][a-z][a-zA-Z0-9]*)?$/', $methodName);

Choose a reason for hiding this comment

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

Modified to only allow:
3 or more words (including "test") before the _
2 or more words after the _
or 1 or more words but no underscore
A word starts with an uper case A-Z, then zero or more lower case a-z, then zero or more numbers 0-9 are allowed.
/^test(([A-Z][a-z][0-9])+|([A-Z][a-z][0-9]){3,}_{2,}))$/
Tests not included. Wielding this regexp is unsafe without first properly testing it.

@JanZerebecki
Copy link

Then I just need to find a git wizard as well to get rid of the ant-task.rst file of doom.

I don't get how this survived for so long. (The .gitattributes rules in this repository to convert text files from LF to the systems preferred line endings on checkout and internally to LF before diff/commit was added after this file was added; this file was added with CRLF, internally files are now stored with LF line endings.) The proper fix is to commit the converted ant-task.rst in a different commit, which I assume was the intention when adding the .gitattributes .

To get rid of it from this commit do:
$ git checkout HEAD~1 src/site/rst/documentation/ant-task.rst
$ git commit --amend

@JeroenDeDauw
Copy link
Contributor Author

/^test(([A-Z][a-z][0-9])+|([A-Z][a-z][0-9]){3,}_{2,}))$/

Thnx!

To get rid of it from this commit do:
$ git checkout HEAD~1 src/site/rst/documentation/ant-task.rst
$ git commit --amend

Tried that and several other things. It always re-appears.

@JanZerebecki
Copy link

Yes it only gets rid of it from your commit. That it reappears as modified in your working copy is what the .gitattributes in the repo tells git to do. Also see above what I said about a proper fix.

@JeroenDeDauw
Copy link
Contributor Author

@manuelpichler @ravage84 are you fine with this change? If so, I'll amend it with the latest regex

@addshore
Copy link

addshore commented Aug 7, 2015

@manuelpichler @ravage84 any progress here?

manuelpichler pushed a commit that referenced this pull request Sep 21, 2015
Add option to allow having an undercore in test methods
@manuelpichler manuelpichler merged commit af47957 into phpmd:master Sep 21, 2015
@manuelpichler manuelpichler added this to the 2.3.0 milestone Sep 21, 2015
@manuelpichler manuelpichler self-assigned this Sep 21, 2015
@JeroenDeDauw JeroenDeDauw deleted the CamelTest branch September 21, 2015 20:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

Successfully merging this pull request may close these issues.

None yet

4 participants