Download the PHP package ekvedaras/laravel-test-helpers without Composer
On this page you can find all versions of the php package ekvedaras/laravel-test-helpers. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Informations about the package laravel-test-helpers
laravel-test-helpers
When writing tests daily, some actions might get frustrating to repeat. This package offers a solution to some of those problems and helps to write tests faster and make them more clean. It does not enforce anything. The main way of building mocks and expectations can still be used where it makes sense to.
Changelog
- v1.*
Installation
composer require ekvedaras/laravel-test-helpers --dev
Usage
Just use TestHelpers
trait (or any of others provided if you want to be explicit) in your test class.
Helpers
TestHelpersMock
Providers helper methods for defining PhpUnit mock expectations more quickly.
NOTE: To create this mock
BuildsMocks@mock
has to be used
once
twice
times
any
consecutiveTwice
consecutive
never
fail
BuildsMocks
trait
Creates mocks and injects them into Laravel, so mocks would be resolve instead of real instances
using app(My::class)
and when container auto resolves injector(s) constructor arguments.
NOTE: Only the first parameter is required
ChecksSingletons
trait
Checks if given class is marked as a singleton.
TestsCommands
trait
Creates command tester for a given command class.
TestsHelpers
trait
Just a convenient trait which includes all traits mentioned above.
Examples
More examples can be found in packages tests.
Mock expectations with TestHelpersMock
All versions of laravel-test-helpers with dependencies
illuminate/support Version 5.6.* | 5.7.*
mockery/mockery Version ^1.0
phpunit/phpunit Version ^7.0