Download the PHP package cdn77/test-utils without Composer
On this page you can find all versions of the php package cdn77/test-utils. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Informations about the package test-utils
Cdn77 TestUtils
Contents
- Installation
- Features
- Stub
- Test Checks
Installation
- Require this project as composer dev dependency:
Features
Stub
Factory to create object through Reflection in order to bypass the constructor.
When testing method salute()
, you only need the tested class to have property2
set, you don't want to worry about property1
.
Therefore in your test you can initialize MyEntity
using Stub::create()
like this:
It comes handy when class constructor has more arguments and most of them are not required for your test.
It is possible to extend stubs:
Test Checks
Test Checks are used to assert that tests comply with your suite's standards (are final, extend correct TestCaseBase etc.)
To run them, e.g. create a test case like in the following example:
Every test has group
Asserts that all tests have a #[Group('x')]
attribute
:x:
:heavy_check_mark:
Configured in test provider as
Every test has same namespace as covered class
Asserts that all test share same namespace with class they're testing.
Consider src namespace Ns
and test namespace Ns/Tests
then for test Ns/Tests/UnitTest
must exist class Ns/Unit
.
You can use #[CoversClass]
attribute to link test with tested class.
Use #[CoversNothing]
attribute to skip this check.
Don't forget to enable requireCoverageMetadata="true"
in phpunit config file.
:x:
:heavy_check_mark:
Configured in test provider as
Every test inherits from testcase base class
Consider you have a base for all tests and want each of them extend it.
:x:
:heavy_check_mark:
Configured in test provider as
Every test is final
Asserts all tests are final so they cannot be extended
:x:
:heavy_check_mark:
Configured in test provider as