mrgoodbytes8667 / test-common-faker
Faker providers
Installs: 17 703
Dependents: 14
Suggesters: 0
Security: 0
Stars: 0
Watchers: 1
Forks: 0
Open Issues: 0
Requires
- php: ^8.1
- fakerphp/faker: ^1.13
- mmo/faker-images: ^0.8 | ^0.9
- symfony/deprecation-contracts: ^2.1 | ^3
- symfony/string: ^5.2 | ^6.0 | ^7.0
Requires (Dev)
- symfony/test-pack: ^1.0.9
Conflicts
- phpunit/phpunit: <9.5
README
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
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.