mrgoodbytes8667/test-common-faker

v0.4.5 2023-11-29 19:59 UTC

README

Packagist Version PHP from Packagist Packagist License
GitHub Workflow Status GitHub Workflow Status codecov
A Faker provider with some random miscellaneous helpers

Installation

Make sure Composer is installed globally, as explained in the installation chapter of the Composer documentation.

Open a command console, enter your project directory and execute:

$ composer require mrgoodbytes8667/test-common-faker

Usage

use Bytes\Common\Faker\Providers\MiscProvider;
use Faker\Factory;

/** @var Factory|MiscProvider $faker */
$faker = Factory::create();
$faker->addProvider(new MiscProvider($faker));

$faker->camelWords();
$faker->snakeWords();
$faker->oneOrMoreOf(['some', 'iterable', 'object']);
$faker->rangeBetween(4, 1, 2);
$faker->randomAlphanumericString();
$faker->paragraphsMinimumChars();

Note: @var is helpful for IDE autocompletion

With PHPUnit

If you are using $faker in every test, you can use TestFakerTrait to setup/teardown $this->faker before/after each test. Declare $this->providers as an array of additional providers beyond MiscProvider to auto-add them when using this trait.

License

License
discord-response-bundle by MrGoodBytes is licensed under a Creative Commons Attribution-NonCommercial 4.0 International License.
Based on a work at https://github.com/mrgoodbytes8667/discord-response-bundle.