diff --git a/composer.json b/composer.json index 96e66dbd..428ff91c 100644 --- a/composer.json +++ b/composer.json @@ -40,7 +40,7 @@ "require-dev": { "ext-json": "*", "laminas/laminas-coding-standard": "~2.5.0", - "phpunit/phpunit": "^10.5.15", + "phpunit/phpunit": "^10.5.18", "psalm/plugin-phpunit": "^0.19.0", "psr/http-message": "^2.0", "vimeo/psalm": "^5.23.1", diff --git a/composer.lock b/composer.lock index 21464466..846a2f8d 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "0393a5f8ad0e360dc3dc490cbd0d525e", + "content-hash": "2c6b09cd6a04ec06aefaf87de44e2d75", "packages": [ { "name": "laminas/laminas-filter", diff --git a/psalm-baseline.xml b/psalm-baseline.xml index 9ae5bafc..170b746b 100644 --- a/psalm-baseline.xml +++ b/psalm-baseline.xml @@ -498,9 +498,6 @@ - - - diff --git a/psalm.xml.dist b/psalm.xml.dist index 22355666..12c9f2ad 100644 --- a/psalm.xml.dist +++ b/psalm.xml.dist @@ -33,6 +33,11 @@ + + + + + diff --git a/test/CollectionInputFilterTest.php b/test/CollectionInputFilterTest.php index dcd49763..bbeffd6c 100644 --- a/test/CollectionInputFilterTest.php +++ b/test/CollectionInputFilterTest.php @@ -246,7 +246,7 @@ public static function dataNestingCollection(): array } #[DataProvider('dataNestingCollection')] - public function testNestingCollectionCountCached(?int $count, bool $expectedIsValid): void + public function testNestingCollectionCountCached(?int $count, bool $isValid): void { $firstInputFilter = new InputFilter(); @@ -291,7 +291,7 @@ public function testNestingCollectionCountCached(?int $count, bool $expectedIsVa ]; $mainInputFilter->setData($data); - self::assertSame($expectedIsValid, $mainInputFilter->isValid()); + self::assertSame($isValid, $mainInputFilter->isValid()); } /** diff --git a/test/FileInput/HttpServerFileInputDecoratorTest.php b/test/FileInput/HttpServerFileInputDecoratorTest.php index 348013c1..0f129bb2 100644 --- a/test/FileInput/HttpServerFileInputDecoratorTest.php +++ b/test/FileInput/HttpServerFileInputDecoratorTest.php @@ -9,6 +9,7 @@ use Laminas\Validator; use LaminasTest\InputFilter\InputTest; use PHPUnit\Framework\Attributes\CoversClass; +use PHPUnit\Framework\Attributes\DataProvider; use Webmozart\Assert\Assert; use function json_encode; @@ -214,14 +215,14 @@ public function testValidationsRunWithoutFileArrayIsSend(): void self::assertFalse($this->input->isValid()); } - /** @param mixed $value */ - public function testNotEmptyValidatorAddedWhenIsValidIsCalled($value = null): void + #[DataProvider('emptyValueProvider')] + public function testNotEmptyValidatorAddedWhenIsValidIsCalled(mixed $raw, mixed $filtered): void { self::markTestSkipped('Test is not enabled in FileInputTest'); } - /** @param mixed $value */ - public function testRequiredNotEmptyValidatorNotAddedWhenOneExists($value = null): void + #[DataProvider('emptyValueProvider')] + public function testRequiredNotEmptyValidatorNotAddedWhenOneExists(mixed $raw, mixed $filtered): void { self::markTestSkipped('Test is not enabled in FileInputTest'); } diff --git a/test/FileInput/PsrFileInputDecoratorTest.php b/test/FileInput/PsrFileInputDecoratorTest.php index 53825717..c972632e 100644 --- a/test/FileInput/PsrFileInputDecoratorTest.php +++ b/test/FileInput/PsrFileInputDecoratorTest.php @@ -11,6 +11,7 @@ use LaminasTest\InputFilter\InputTest; use LaminasTest\InputFilter\TestAsset\UploadedFileInterfaceStub; use PHPUnit\Framework\Attributes\CoversClass; +use PHPUnit\Framework\Attributes\DataProvider; use Psr\Http\Message\UploadedFileInterface; use function in_array; @@ -215,14 +216,14 @@ public function testRequiredUploadValidatorValidatorNotAddedWhenOneExists(): voi self::assertEquals($validator, $validators[0]['instance']); } - /** @param mixed $value */ - public function testNotEmptyValidatorAddedWhenIsValidIsCalled($value = null): void + #[DataProvider('emptyValueProvider')] + public function testNotEmptyValidatorAddedWhenIsValidIsCalled(mixed $raw, mixed $filtered): void { self::markTestSkipped('Test is not enabled in PsrFileInputTest'); } - /** @param mixed $value */ - public function testRequiredNotEmptyValidatorNotAddedWhenOneExists($value = null): void + #[DataProvider('emptyValueProvider')] + public function testRequiredNotEmptyValidatorNotAddedWhenOneExists(mixed $raw, mixed $filtered): void { self::markTestSkipped('Test is not enabled in PsrFileInputTest'); } diff --git a/test/InputTest.php b/test/InputTest.php index ac554262..3da5cdfe 100644 --- a/test/InputTest.php +++ b/test/InputTest.php @@ -142,29 +142,23 @@ public function testContinueIfEmptyFlagIsMutable(): void self::assertTrue($input->continueIfEmpty()); } - /** - * @param mixed $fallbackValue - */ #[DataProvider('setValueProvider')] - public function testSetFallbackValue($fallbackValue): void + public function testSetFallbackValue(mixed $raw, mixed $filtered): void { $input = $this->input; - $return = $input->setFallbackValue($fallbackValue); + $return = $input->setFallbackValue($raw); self::assertSame($input, $return, 'setFallbackValue() must return it self'); - self::assertEquals($fallbackValue, $input->getFallbackValue(), 'getFallbackValue() value not match'); + self::assertEquals($raw, $input->getFallbackValue(), 'getFallbackValue() value not match'); self::assertTrue($input->hasFallback(), 'hasFallback() value not match'); } - /** - * @param mixed $fallbackValue - */ #[DataProvider('setValueProvider')] - public function testClearFallbackValue($fallbackValue): void + public function testClearFallbackValue(mixed $raw, mixed $filtered): void { $input = $this->input; - $input->setFallbackValue($fallbackValue); + $input->setFallbackValue($raw); $input->clearFallbackValue(); self::assertNull($input->getFallbackValue(), 'getFallbackValue() value not match'); self::assertFalse($input->hasFallback(), 'hasFallback() value not match'); @@ -322,15 +316,12 @@ public function testNotRequiredWithoutFallbackAndValueNotSetThenIsValid(): void self::assertEquals([], $input->getMessages(), 'getMessages() should be empty because the input is valid'); } - /** - * @param mixed $value - */ #[DataProvider('emptyValueProvider')] - public function testNotEmptyValidatorNotInjectedIfContinueIfEmptyIsTrue($value): void + public function testNotEmptyValidatorNotInjectedIfContinueIfEmptyIsTrue(mixed $raw, mixed $filtered): void { $input = $this->input; $input->setContinueIfEmpty(true); - $input->setValue($value); + $input->setValue($raw); $input->isValid(); $validators = $input->getValidatorChain() ->getValidators(); @@ -406,14 +397,11 @@ public function testBreakOnFailureFlagIsMutable(): void self::assertTrue($this->input->breakOnFailure()); } - /** - * @param mixed $value - */ #[DataProvider('emptyValueProvider')] - public function testNotEmptyValidatorAddedWhenIsValidIsCalled($value): void + public function testNotEmptyValidatorAddedWhenIsValidIsCalled(mixed $raw, mixed $filtered): void { self::assertTrue($this->input->isRequired()); - $this->input->setValue($value); + $this->input->setValue($raw); $validatorChain = $this->input->getValidatorChain(); self::assertEquals(0, count($validatorChain->getValidators())); @@ -427,16 +415,13 @@ public function testNotEmptyValidatorAddedWhenIsValidIsCalled($value): void self::assertEquals(1, count($validatorChain->getValidators())); } - /** - * @param mixed $value - */ #[DataProvider('emptyValueProvider')] - public function testRequiredNotEmptyValidatorNotAddedWhenOneExists($value): void + public function testRequiredNotEmptyValidatorNotAddedWhenOneExists(mixed $raw, mixed $filtered): void { $this->input->setRequired(true); - $this->input->setValue($value); + $this->input->setValue($raw); - $notEmptyMock = $this->createNonEmptyValidatorMock(false, $value); + $notEmptyMock = $this->createNonEmptyValidatorMock(false, $raw); $validatorChain = $this->input->getValidatorChain(); $validatorChain->prependValidator($notEmptyMock); @@ -447,21 +432,17 @@ public function testRequiredNotEmptyValidatorNotAddedWhenOneExists($value): void self::assertEquals($notEmptyMock, $validators[0]['instance']); } - /** - * @param mixed $valueRaw - * @param mixed $valueFiltered - */ #[DataProvider('emptyValueProvider')] - public function testDoNotInjectNotEmptyValidatorIfAnywhereInChain($valueRaw, $valueFiltered): void + public function testDoNotInjectNotEmptyValidatorIfAnywhereInChain(mixed $raw, mixed $filtered): void { - $filterChain = $this->createFilterChainMock([[$valueRaw, $valueFiltered]]); + $filterChain = $this->createFilterChainMock([[$raw, $filtered]]); $validatorChain = $this->input->getValidatorChain(); $this->input->setRequired(true); $this->input->setFilterChain($filterChain); - $this->input->setValue($valueRaw); + $this->input->setValue($raw); - $notEmptyMock = $this->createNonEmptyValidatorMock(false, $valueFiltered); + $notEmptyMock = $this->createNonEmptyValidatorMock(false, $filtered); $validatorChain->attach(self::createValidatorMock(true)); $validatorChain->attach($notEmptyMock); @@ -501,30 +482,24 @@ public function testIsRequiredVsAllowEmptyVsContinueIfEmptyVsIsValid( self::assertEquals($value, $this->input->getValue(), 'getValue() must return the filtered value always'); } - /** - * @param mixed $value - */ #[DataProvider('setValueProvider')] - public function testSetValuePutInputInTheDesiredState($value): void + public function testSetValuePutInputInTheDesiredState(mixed $raw, mixed $filtered): void { $input = $this->input; self::assertFalse($input->hasValue(), 'Input should not have value by default'); - $input->setValue($value); + $input->setValue($raw); self::assertTrue($input->hasValue(), "hasValue() didn't return true when value was set"); } - /** - * @param mixed $value - */ #[DataProvider('setValueProvider')] - public function testResetValueReturnsInputValueToDefaultValue($value): void + public function testResetValueReturnsInputValueToDefaultValue(mixed $raw, mixed $filtered): void { $input = $this->input; $originalInput = clone $input; self::assertFalse($input->hasValue(), 'Input should not have value by default'); - $input->setValue($value); + $input->setValue($raw); self::assertTrue($input->hasValue(), "hasValue() didn't return true when value was set"); $return = $input->resetValue();