ergebnis / test-util
Provides a helper trait and generic data providers for tests.
Fund package maintenance!
localheinz
Installs: 1 211 845
Dependents: 47
Suggesters: 0
Security: 0
Stars: 15
Watchers: 3
Forks: 2
Open Issues: 0
Requires
- php: ^7.4 || ^8.0
- ergebnis/classy: ^1.3.0
- fakerphp/faker: ^1.17.0
Requires (Dev)
- ergebnis/composer-normalize: ^2.22.0
- ergebnis/license: ^1.2.0
- ergebnis/php-cs-fixer-config: ^3.4.0
- ergebnis/phpstan-rules: ~0.15.3
- infection/infection: ~0.25.5
- phpstan/extension-installer: ^1.1.0
- phpstan/phpstan: ~0.12.84
- phpstan/phpstan-deprecation-rules: ~0.12.6
- phpstan/phpstan-phpunit: ~0.12.22
- phpstan/phpstan-strict-rules: ~0.12.11
- phpunit/phpunit: ^9.5.11
- psalm/plugin-phpunit: ~0.16.1
- vimeo/psalm: ^4.17.0
- dev-main
- 1.6.0
- 1.5.0
- 1.4.0
- 1.3.1
- 1.3.0
- 1.2.0
- 1.1.0
- 1.0.1
- 1.0.0
- 0.9.1
- 0.9.0
- 0.8.0
- 0.7.0
- 0.6.1
- 0.6.0
- 0.5.0
- 0.4.1
- 0.4.0
- 0.3.1
- 0.3.0
- 0.2.2
- 0.2.1
- 0.2.0
- 0.1.0
- dev-fix/archive
- dev-fix/changelog
- dev-fix/provide
- dev-fix/assertion
- dev-fix/data-provider
- dev-feature/php74
- dev-fix/deprecate
- dev-dependabot/composer/phpunit/phpunit-9.5.11
- dev-dependabot/composer/ergebnis/classy-1.3.0
- dev-dependabot/composer/ergebnis/composer-normalize-2.22.0
- dev-dependabot/composer/ergebnis/php-cs-fixer-config-3.4.0
- dev-dependabot/composer/ergebnis/license-1.2.0
- dev-dependabot/composer/infection/infection-0.25.5
- dev-fix/xdebug-mode
- dev-fix/pcov
- dev-fix/php73
- dev-dependabot/composer/infection/infection-0.18.2
- dev-fix/make
- dev-dependabot/composer/ergebnis/composer-normalize-2.20.0
- dev-fix/diff-format
- dev-fix/dry-run
- dev-fix/php-cs-fixer
- dev-fix/order
- dev-feature/php73
- dev-fix/php72
- dev-fix/integration
- dev-dependabot/composer/ergebnis/composer-normalize-2.19.0
- dev-fix/auto-review
- dev-dependabot/composer/fakerphp/faker-1.17.0
- dev-fix/cache
- dev-dependabot/composer/phpstan/phpstan-strict-rules-0.12.11
- dev-dependabot/composer/phpstan/phpstan-phpunit-0.12.22
- dev-dependabot/composer/phpstan/phpstan-0.12.99
- dev-fix/phpstan
- dev-fix/rename
- dev-dependabot/composer/ergebnis/classy-1.2.0
- dev-dependabot/github_actions/shivammathur/setup-php-2.16.0
- dev-dependabot/github_actions/actions/checkout-2.4.0
- dev-dependabot/github_actions/actions/cache-2.1.7
- dev-dependabot/composer/phpunit/phpunit-8.5.22
- dev-feature/php81
- dev-dependabot/composer/vimeo/psalm-4.17.0
- dev-fix/allow-plugins
- dev-fix/octokit
- dev-dependabot/composer/vimeo/psalm-4.16.1
This package is auto-updated.
Last update: 2022-01-03 19:14:17 UTC
README
Provides a helper trait for tests.
Installation
Run
$ composer require --dev ergebnis/test-util
Usage
Helper
Import the Ergebnis\Test\Util\Helper
trait into your test class:
<?php declare(strict_types=1); namespace Foo\Bar\Test\Unit; use Ergebnis\Test\Util; use PHPUnit\Framework; final class BazTest extends Framework\TestCase { use Util\Helper; }
Easy access to localized instances of Faker\Generator
The Helper
trait provides a method to fetch a localized instance of Faker\Generator
:
faker(string $locale = 'en_US') : \Faker\Generator
<?php declare(strict_types=1); namespace Example\Test\Unit; use Ergebnis\Test\Util; use Example\Player; use PHPUnit\Framework; final class PlayerTest extends Framework\TestCase { use Util\Helper; public function testConstructorSetsValues(): void { $name = self::faker()->firstName; $player = new Player($name); $this->assertSame($name, $player->firstName()); } }
For reference, see fzaninotto/faker
.
Changelog
Please have a look at CHANGELOG.md
.
Contributing
Please have a look at CONTRIBUTING.md
.
Code of Conduct
Please have a look at CODE_OF_CONDUCT.md
.
License
This package is licensed using the MIT License.
Please have a look at LICENSE.md
.
Curious what I am building?
📬 Subscribe to my list, and I will occasionally send you an email to let you know what I am working on.