Skip to content

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

@jeremyquinton

Description

@jeremyquinton

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions