Repository navigation
1.0.0
Upgrading from 0.2X
- Requirements: PHP 8.2, PHPUnit 11 and Psalm 7.2 or newer. Projects on PHP 8.1, PHPUnit 10 or Psalm 6 keep using 0.22, which still gets bug fixes.
- PHPUnit 12 and newer ignore metadata in docblocks, and so does the plugin:
@test,@dataProvider,@coversand the other tags are reported asIgnoredDocblockMetadata, which names the attribute to use (#[Test],#[DataProvider],#[CoversClass], ...). They no longer make a method a test or a data provider. - Data providers are checked more closely:
- string-keyed datasets are matched to the test parameters by name (
InvalidNamedArgument,TooFewArguments); - providers with only a native return type (
: iterable,: array,: \Generator) have their datasets checked against the type Psalm infers from the provider's body. Where that is not possible they are reported asMixedReturnStatement, asking for a@returntype.
- string-keyed datasets are matched to the test parameters by name (
- New issues:
UnspecificEqualsAssertion,UnspecificNullAssertion,UnspecificBooleanAssertionandUnspecificCountAssertion(errorLevel="1"only) suggestassertSame()overassertEquals()for two values of one scalar type, andassertNull(),assertTrue()/assertFalse()andassertCount()overassertSame();MissingParentCallreportssetUp(),tearDown()and the other hook overrides that never callparent::;InvalidPhpUnitAnnotationreports docblock tags that PHPUnit drops (/** @dataProvider*/,@group(slow));UndefinedClass,UndefinedMethodandUndefinedFunctionreport missing#[Covers*]/@coverstargets and->method('typo')on mocks.
UnspecificEqualsAssertion can be numerous in older test suites. Rector's AssertEqualsToSameRector fixes it, or it can be turned off:
<issueHandlers>
<PluginIssue name="UnspecificEqualsAssertion" errorLevel="suppress"/>
</issueHandlers>What's Changed
Requirements
- Require PHP 8.2 and PHPUnit 11 (#202)
- Drop code for PHPUnit versions before 11 (#204)
- Report docblock metadata that PHPUnit 12 ignores (#210)
New checks
- Suggest
assertNull(),assertTrue()/assertFalse()andassertCount()overassertSame()(#198) - Suggest
assertSame()overassertEquals()for two values of one scalar type (#208) - Suggest
assertTrue()/assertFalse()overassertEquals(true|false, ...)(#233) - Type
createMockForIntersectionOfInterfaces()andcreateStubForIntersectionOfInterfaces()(#207) - Support
#[DataProviderExternal](#211) - Report undefined methods in
->method('...')on mocks (#212) - Report undefined methods in
->method('...')on unions of mocks (#231) - Report
setUp()andtearDown()overrides that don't call the parent (#215) - Report
assertPreConditions()andassertPostConditions()overrides that don't call the parent (#229) - Match string-keyed datasets to test parameters by name (#213)
- Report string-keyed datasets combined with a dependency that passes a value (#236)
- Report positional dataset entries after named ones (#238)
- Narrow test parameter types from data providers (#225)
- Check that
#[Covers*]and@coverstargets exist (#224) - Check datasets of
#[DataProviderClosure]providers (#242) - Check datasets of providers without a
@returntype (#275) - Report
prophesize()withoutProphecyTrait(#258) - Report
#[DataProvider('Other::method')]as an undefined provider, like PHPUnit (#235) - Report malformed PHPUnit annotations instead of a missing provider (#209)
- Report malformed PHPUnit annotations in the class docblocks of used traits (#234)
- Honour
@psalm-suppressfor data provider and dataset issues (#257) - Ignore the docblock of a method that has any PHPUnit attribute (#263)
Fixes
- Read PHPUnit tags in docblocks that also have an unknown
@psalmtag (#232) - Report non-static providers implemented by a child of an abstract test case (#241)
- Report assertion suggestions in either argument order (#253)
- Don't report methods PHPUnit runs as hooks as unused (#259)
- Honour
setUp()and#[Before]from traits forMissingConstructor(#260) - Don't check data providers of non-public test methods (#261)
- Check providers typed
iterable<V>orGenerator<V>(#262) - Fix
TooFewArgumentsforlist<T>datasets (#264) - Report provider arguments that need a coercion as
ArgumentTypeCoercion(#265) - Expand imported type aliases in provider checks (#266)
- Report
mixeddataset values asMixedArgument(#271) - Don't report
InvalidArgumentfor test parameters typed with the method's own templates (#270) - Don't report
MixedArgumentTypeCoercionfor closure parameters typed with the method's own templates (#277)
Development
- Move 1.x development to master (#228)
- Use
assertSame()in external provider fixtures (#230) - Bump prophecy-phpunit and php_codesniffer dev constraints (#237)
- Split
TestCase.featureinto one feature file per area (#243) - Build the Behat config in
Contextinstead of copying it into every scenario (#254) - Lint the Behat scenarios for checks that silently assert nothing (#255)
- Replace PHP_CodeSniffer with PHP-CS-Fixer (#273)
- Apply PHP-CS-Fixer (#276)
Full Changelog: 0.22.2...1.0.0