visuallazza / fixture-generator
There is no license information available for the latest version (v0.0.1) of this package.
events/interfaces
v0.0.1
2023-03-22 21:05 UTC
Requires
- php: >=8.1
- ext-intl: *
- psr/http-message: ^1.0
- spatie/data-transfer-object: ^3.9
- symfony/http-foundation: ^6.2
Requires (Dev)
- friendsofphp/php-cs-fixer: ^3.12
- phpunit/phpunit: ^9.5
This package is auto-updated.
Last update: 2024-10-15 16:49:46 UTC
README
This package helps you to generate fixtures out of your DTO's. To be able to use the fixture-generator
your DTO's has to extend the DataTransferObject
of Spatie
use Spatie\DataTransferObject\DataTransferObject;
class YourDto extends DataTransferObject
{}
Add the generator to your deps
Link to packagist
composer require visuallazza/fixture-generator
How to use
The method will generate an object with either with placeholder values.
className
: Full qualified Name of the classisComplete
: By defaulttrue
all properties will be set, ifflase
only required properties will be set.dataSet
: Set each property as test case requires. The other properties will be set
use Fixture\Generator\Models\Primitive;
use PHPUnit\Framework\TestCase;
class TestCase extends TestCase
{
use HasFixtureGenerator;
public function test(): void
{
$dataSet = [
'int' => 5,
];
$generatedObject = $this->generate(
className: Primitive::class,
isComplete: false,
providedData: $dataSet
);
}
}
Dependencies
To generate the objects the spatie DTO
is in use.
"spatie/data-transfer-object": "^3.9",
Test
Run all test with the make command
make test
Lint
make lint