Testing
This module adds auto-filling to your resource create forms.
Installation
To install this module
composer require qore/testing
Usage
To use this module
Register the service provider in your AppServiceProvider
, for example:
if ($this->app->environment('local', 'staging') && config('telescope.enabled')) {
$this->app->register(\Laravel\Telescope\TelescopeServiceProvider::class);
$this->app->register(TelescopeServiceProvider::class);
// Here:
$this->app->register(TestingServiceProvider::class);
}
Then after, you can enable this module to set it active.
Upgrade Guide
To upgrade this module
composer update qore/testing
Configuration
You can disable autofill on a field using:
->disableAutofill()
When creating your own fields, you can configure auto filling:
public function autoFill(Generator $faker): string
{
return $faker->name;
}
Optionally, you can programmatically decide if auto filling should be enabled:
public function shouldAutoFill(mixed $value): bool
{
return $this->autoFillEnabled && empty($value);
}
Autofill resources
When working on your project it might be cumbersome to create seeders for every resource or manually create resources. The testing module comes with a command that lets you create resources automatically. Optionally you can give the amount and the relation of a resource. The amount creates that many instances of a resource. The relation option gives the possibility to create the relation(s) of the resource. The command is constructed as follows:
qore:autofill {resource} {--count=} {--relation=*}
Note: in order to use the command you must activate the modules and plugins.
Release notes
All notable changes will be documented here.
0.8.0 (March 24, 2022)
Features
- Add initial release