Download the PHP package rector/mockstan without Composer
On this page you can find all versions of the php package rector/mockstan. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Informations about the package mockstan
PHPUnit Mocks Rules
[!WARNING] This package is deprecated. Use
symplify/phpstan-rulesinstead.
- Do you use extensive mocking in your PHPUnit tests?
- Do you want to keep your tests clean, maintainable and avoid upgrade hell in the future?
- Do you want to have test that actually test somthing?
This set is for you!
Install
Note: Make sure you use phpstan/extension-installer to load necessary service configs.
AvoidAnyExpectsRule
Disallow usage of any() expectation in mocks to ensure that all mock interactions are explicitly defined and verified.
:x:
:+1:
ExplicitExpectsMockMethodRule
Require explicit expects() usage when setting up mocks to avoid silent stubs. This is reuired since PHPUnit 12 to avoid silent stubs.
:x:
:+1:
ForbiddenClassToMockRule
Disallow mocking of forbidden/core classes (e.g. \DateTime, Symfony Request or RequestStack, Iterable, Symfony and Doctine event objects etc.).
:x:
:+1:
NoWithOnStubRule
Disallow with() on stubs (mocks without expects()). PHPUnit deprecates with*() on test stubs because they silently swallow argument mismatches.
:x:
:+1:
NoDocumentMockingRule
Prevent mocking of Doctrine ODM document classes. Use real instances instead.
:x:
:+1:
NoDoubleConsecutiveTestMockRule
Avoid creating multiple consecutive methods mocks, one for params and other for return. Use single instead.
:x:
:+1:
NoEntityMockingRule
Do not mock Doctrine entity classes. Use real object instance instead.
:x:
:+1:
NoMockObjectAndRealObjectPropertyRule
Disallow assigning a mock to a property while another test uses the real object on the same property.
:x:
:+1:
RequireAtLeastOneRule
Disallow atLeast(0) on mock expectations, as it matches any number of calls (including zero) and provides no real verification. Require a value of 1 or higher.
:x:
:+1:
NoMockOnlyTestRule
Avoid tests that only create mocks and never assert behavior. Require meaningful assertions with at least once real object to test.
:x:
:+1:
Happy coding!