Lumped tweets

Just marks

I prefer to add case name for each data providers in PHP Unit

Conclusion

This example is too easy, so you don't have to do it actually.

<?php

// Please do not
public function dataProvider(): array
{
    return [
        [1, 2, 3],
        [-1, 1, 0]
    ];
}

/**
 * @dataProvider dataProvider
 */
public function testSum(int $left, int $right, int $expected): void
{
    self::assertSome($expected, $left + $right);
}

// Please do it
public function dataProvider(): array
{
    return [
        'normal' => ['left' => 1, 'right' => 2, 'expected' => 3],
        'anomaly' => ['left' => -1, 'right' =>1, 'expected' => 0]
    ];
}

/**
 * @dataProvider dataProvider
 */
public function testSum(int $left, int $right, int $expected): void
{
    self::assertSome($expected, $left + $right);
}

Why

when the test fail, you got the following message on your terminal.

1) AwesomeTest::testSum with data set #2 (-1, 1, 0)

If you write the my proposal way, you got the following message too.

1) AwesomeTest::testSum with data set "anomaly" (-1, 1, 0)

I prefer to the my proposal way because I can detect where I should looking quickly.

How about?