This library provides several wrappers and helper classes for the package phpunit/phpunit
.
Install the latest version with
$ composer require --dev codekandis/phpunit
Create a new test case and inherit it from the wrapper TestCase
.
class FooTest extends TestCase
{
}
Create a new data provider and implement the interface DataProviderInterface
.
class ImportantStuffDataProvider implements DataProviderInterface
{
#[Override]
public static function provideData(): iterable
{
return [
0 => [
23,
42
],
1 => [
'foo',
'bar'
]
];
}
}
Use the data provider in your test case.
<?php declare( strict_types = 1 );
use CodeKandis\PhpUnit\TestCase;
class FooTest extends TestCase
{
#[DataProviderExternal( ImportantStuffDataProvider::class, 'provideData' )]
testImportantStuff( string $value1, string $value2 )
{
}
}