Download the PHP package sebastianknott/test-utils without Composer
On this page you can find all versions of the php package sebastianknott/test-utils. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download sebastianknott/test-utils
More information about sebastianknott/test-utils
Files in sebastianknott/test-utils
Package test-utils
Short Description Some classes i like to use for testing
License GPL-3.0-only
Informations about the package test-utils
test-utils
Some classes i like to use for testing purposes
System Under Test (SUT) Factory
I don't like to do tedious work, so I created a factory that creates the System Under Test (SUT) for me. The factory creates a new instance of the SUT and mocks its constructor dependencies as good as it can.
It returns a Bundle
object that contains the SUT and the mocks.
Type of Mocks
It supports two types of mocking libraries (Mockery,
Phake) and can be configured to use one of them by passing the respective
MockTypeEnum
to BundleFactory::build
.
Prebuild Parameters
If the SUT has dependencies that are not mockable, you can pass them as a prebuild parameter to the factory. The prebuild parameter is an associative array where the key is the name of the parameter in the suts constructor and the value is the instance.
TestToolsCase
I found myself writing the same boilerplate code over and over again. So I condensed it into a base class that I can extend from.
It does the following:
- Make a sut factory available
self::$bundleFactory
- Make faker available
self::$faker
- Require hamcrest and Mockery
So instead of writing this:
I write that:
All versions of test-utils with dependencies
phake/phake Version ^v4.5
mockery/mockery Version ^1.6
phpunit/phpunit Version ^9.5|^10.0|^11.1.3
hamcrest/hamcrest-php Version ^2.0
sebastianknott/hamcrest-object-accessor Version ^2.0
fakerphp/faker Version ^v1.23.1
infection/infection Version >0.28.0
phpspec/prophecy Version ^v1.19
brianium/paratest Version ^v7.4