re: Keeping (large) data providers organized in PHPUnit VIEW POST

FULL DISCUSSION
 

Fun fact an alternate way to set the test case name -- instead of using setName in the test -- is to put the name of the test as the key value in the data provider. For example:

public function sessionDataProvider(): array
{
    return [
        'Fresh Session' => [
            'session' => [],
            'showLogin' => true,
            'showUpgrade' => false,
            'showPrimaryButton' => true,
        ]
    ];
}

Failing tests should output 'Fresh Session' instead of 'data set #0'

 

You're absolutely right, I didn't realize that before and also didn't notice it when writing up the code samples 🤦‍♂️ I've updated the post to reflect this. Thanks!

code of conduct - report abuse