PHP code example of yuraplohov / test-data-provider
1. Go to this page and download the library: Download yuraplohov/test-data-provider library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
yuraplohov / test-data-provider example snippets
php
return [
// some large array
];
php
/**
* @test
* @dataProvider someProvider
*/
public function it_gets_some_result(array $case)
{
$sut = new SomeClass;
$this->assertEquals($case['expected'], $sut->someMethod($case['input']));
}
/**
* @return array
*/
public function someProvider(): array
{
return (new Provider)->getPHPUnitCases([
'case_1',
'case_2',
]);
}
php
/**
* @param UnitTester $I
* @param \Codeception\Example $example
* @dataProvider someProvider
*/
public function it_gets_some_result(UnitTester $I, \Codeception\Example $example)
{
$sut = new SomeClass;
$I->assertEquals($example['expected'], $sut->someMethod($example['input']));
}
/**
* @return array
*/
protected function someProvider()
{
return (new Provider)->getCodeceptionCases([
'case_1',
'case_2',
]);
}
php
/** @test */
public function it_gets_some_result()
{
$dp = new Provider;
$sut = new SomeClass($dp->get('service/settings'));
$this->assertEquals($dp->get('expected'), $sut->someMethod($dp->get('service/input')));
}
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.