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

Idea around the controller tests for improvement I thought worth sharing. #671

Open
jeremyquinton opened this issue Jul 9, 2017 · 0 comments

Comments

@jeremyquinton
Copy link

jeremyquinton commented Jul 9, 2017

When putting together this issue #670 I was looking at the test cases and come up with an idea on how the tests cases could potentially be improved. Just an idea or opinion I'm sharing not trying to be critical :-)

https://github.com/ZF-Commons/ZfcUser/blob/3.x/tests/ZfcUserTest/Controller/UserControllerTest.php#L154

A data provider is used for the test case but potentially break the test out and making each test case explicit will help with maintainability.

For example when validation fails and the user is redirected the test case name could be as follows.

testLoginActionInvalidFormRedirectTrue()

The test takes no arguments and its clear what it does.

Another idea might just be to change the test name. I feel with the current test name is not clear as to what its testing. The current data arguments are (true, false) or (true, true) etc but the test name has the words Valid and False in the name.
testLoginActionValidFormRedirectFalse($isValid, $wantRedirect). In the scenario I was looking at
testLoginActionValidFormRedirectFalse(false, true) is a little confusing.

The test name could perhaps be a bit more abstract.
testLoginActionFormAndRedirect or testLoginActionFormStatusRedirectStatus as the arguments then from the data provider (true, true),(true,false) etc make more sense.

Just an idea feel free to close the issue if you think its not worthwhile.

@jeremyquinton jeremyquinton changed the title Idea around the controller tests thought worth sharing. Idea around the controller tests for improvement I thought worth sharing. Jul 9, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant