From 045bd81fe0d86ce9fb439ef7536dd5ee8d972f55 Mon Sep 17 00:00:00 2001 From: Paul Water Date: Mon, 4 Dec 2023 05:35:26 +0100 Subject: [PATCH] Upgrade to PhpUnit 10.x and code clean up. --- .gitignore | 4 +- composer.json | 2 +- phpunit.xml | 41 ++++++++++--------- src/Validator/HttpValidator.php | 2 +- test/Cleaner/AmbiguityCleanerTest.php | 2 +- test/Cleaner/IntegerCleanerTest.php | 10 ++--- test/Cleaner/PruneWhitespaceCleanerTest.php | 24 +++++------ test/Cleaner/RemoveWhitespaceCleanerTest.php | 22 +++++----- test/Cleaner/TidyCleanerTest.php | 22 +++++----- test/Cleaner/Traits/StringCleaner.php | 6 +-- test/Cleaner/TrimWhitespaceCleanerTest.php | 22 +++++----- test/Control/ButtonControlTest.php | 2 +- test/Control/CheckboxControlTest.php | 4 +- test/Control/CheckboxesControlTest.php | 2 +- test/Control/DatabaseLabelControlTest.php | 2 +- test/Control/DateControlTest.php | 6 +-- test/Control/FileControlTest.php | 2 - test/Control/ForceSubmitControlTest.php | 2 +- test/Control/HiddenControlTest.php | 6 +-- test/Control/HiddenSubmitControlTest.php | 2 +- test/Control/HtmlControlTest.php | 2 +- test/Control/HttpControlTest.php | 4 +- test/Control/ImageControlTest.php | 2 - test/Control/NumberControlTest.php | 6 +-- test/Control/PasswordControlTest.php | 6 +-- ...ontrolTest.php => PushControlTestCase.php} | 6 +-- test/Control/RadioControlTest.php | 15 +++++-- test/Control/RadiosControlTest.php | 12 +++--- test/Control/SelectControlTest.php | 12 +++--- test/Control/SilentControlTest.php | 2 +- ...trolTest.php => SimpleControlTestCase.php} | 8 ++-- test/Control/SubmitControlTest.php | 2 +- test/Control/TelControlTest.php | 6 +-- test/Control/TextAreaControlTest.php | 22 +++++----- test/Control/TextControlTest.php | 6 +-- ...st.php => CommonSimpleControlTestCase.php} | 10 ++--- ...mmutableTest.php => ImmutableTestCase.php} | 2 +- test/Control/Traits/InputElementTest1.php | 6 ++- test/Control/UrlControlTest.php | 4 +- test/RawFormTest.php | 2 +- test/Validator/DateValidatorTest.php | 10 ++--- test/Validator/EmailValidatorTest.php | 12 +++--- test/Validator/HttpValidatorTest.php | 12 +++--- test/Validator/IntegerValidatorTest.php | 32 +++++++-------- test/Validator/LengthValidatorTest.php | 10 ++--- test/Validator/MandatoryValidatorTest.php | 10 ++--- test/Validator/ProxyCompoundValidatorTest.php | 4 +- test/Validator/ProxyValidatorTest.php | 6 +-- test/Validator/TestControl.php | 14 +++---- test/Walker/LoadWalkerTest.php | 3 +- test/Walker/TestControl.php | 2 +- 51 files changed, 220 insertions(+), 215 deletions(-) rename test/Control/{PushControlTest.php => PushControlTestCase.php} (98%) rename test/Control/{SimpleControlTest.php => SimpleControlTestCase.php} (96%) rename test/Control/Traits/{CommonSimpleControlTest.php => CommonSimpleControlTestCase.php} (94%) rename test/Control/Traits/{ImmutableTest.php => ImmutableTestCase.php} (99%) diff --git a/.gitignore b/.gitignore index cfee58a..0e96266 100644 --- a/.gitignore +++ b/.gitignore @@ -1,9 +1,7 @@ /.idea/ -/.phpunit.result.cache +/.phpunit.cache/ /bin/ /composer.lock -/custom.task.properties -/custom.type.properties /doc/ /node_modules/ /package-lock.json diff --git a/composer.json b/composer.json index 214f6cc..319cd3a 100644 --- a/composer.json +++ b/composer.json @@ -27,7 +27,7 @@ "require-dev": { "ext-dom": "*", "phing/phing": "^3.0.0-RC4", - "phpunit/phpunit": "^9.6.3", + "phpunit/phpunit": "^10.5.1", "plaisio/console-kernel": "^1.0.1", "plaisio/console-type-script": "^1.0.0", "plaisio/request-core": "^0.13.0" diff --git a/phpunit.xml b/phpunit.xml index 664d870..600e983 100644 --- a/phpunit.xml +++ b/phpunit.xml @@ -1,22 +1,23 @@ - - - - src - - - vendor/setbased - - - - - - - - - test - - - + + + + + + + + + + test + + + + + + src + + + vendor/setbased + + diff --git a/src/Validator/HttpValidator.php b/src/Validator/HttpValidator.php index d214bec..c6d2c25 100644 --- a/src/Validator/HttpValidator.php +++ b/src/Validator/HttpValidator.php @@ -59,7 +59,7 @@ public function validate(Control $control): bool // Test that the page actually exits. We consider all HTTP 200-399 responses as valid. try { - $headers = get_headers($url); + $headers = @get_headers($url); $valid = (is_array($headers) && preg_match('/^HTTP\\/\\d+\\.\\d+\\s+[23]\\d\\d\\s*.*$/', $headers[0])); } catch (\Exception $e) diff --git a/test/Cleaner/AmbiguityCleanerTest.php b/test/Cleaner/AmbiguityCleanerTest.php index 1fef3d0..e0558b3 100644 --- a/test/Cleaner/AmbiguityCleanerTest.php +++ b/test/Cleaner/AmbiguityCleanerTest.php @@ -87,7 +87,7 @@ public function testValidUtf8Ambiguities(): void $property->setAccessible(true); $unambiguities = $property->getValue($cleaner); - foreach ($unambiguities as $unambiguity => $ambiguities) + foreach ($unambiguities as $ambiguities) { foreach ($ambiguities as $ambiguity) { diff --git a/test/Cleaner/IntegerCleanerTest.php b/test/Cleaner/IntegerCleanerTest.php index dbe06a0..fdbfe0f 100644 --- a/test/Cleaner/IntegerCleanerTest.php +++ b/test/Cleaner/IntegerCleanerTest.php @@ -17,7 +17,7 @@ class IntegerCleanerTest extends TestCase * * @return string[][] */ - public function getCases(): array + public static function getCases(): array { return [[null, null], ['', null], @@ -35,10 +35,10 @@ public function getCases(): array * * @return array */ - public function getNonStrings(): array + public static function getNonStrings(): array { return [[[]], - [$this], + [new \stdClass()], [fopen('php://stdin', 'r')]]; } @@ -51,7 +51,7 @@ public function getNonStrings(): array * * @dataProvider getCases */ - public function testClean($value, $expected): void + public function testClean(mixed $value, mixed $expected): void { $cleaner = IntegerCleaner::get(); @@ -67,7 +67,7 @@ public function testClean($value, $expected): void * * @dataProvider getNonStrings */ - public function testNonString($value): void + public function testNonString(mixed $value): void { $this->expectException(\LogicException::class); diff --git a/test/Cleaner/PruneWhitespaceCleanerTest.php b/test/Cleaner/PruneWhitespaceCleanerTest.php index 06d0fc8..e49e53d 100644 --- a/test/Cleaner/PruneWhitespaceCleanerTest.php +++ b/test/Cleaner/PruneWhitespaceCleanerTest.php @@ -15,6 +15,17 @@ class PruneWhitespaceCleanerTest extends PlaisioTestCase //-------------------------------------------------------------------------------------------------------------------- use StringCleaner; + //-------------------------------------------------------------------------------------------------------------------- + /** + * Returns cases with spaces only. + * + * @return array + */ + public static function whitespaceOnly(): array + { + return [[''], [null], [' '], [' '], ["\n"], ["\n \n"], ["\n \t"], [" \t\n\r\0\x0B \t\n\r\0\x0B"]]; + } + //-------------------------------------------------------------------------------------------------------------------- /** * Returns an instance of PruneWhitespaceCleaner. @@ -39,6 +50,7 @@ public function testClean(): void self::assertEquals('Hello World!', $value); } + //-------------------------------------------------------------------------------------------------------------------- /** * Test with ambiguous whitespaceOnly only. @@ -52,7 +64,6 @@ public function testEmpty(): void self::assertNull($value); } - //-------------------------------------------------------------------------------------------------------------------- /** * Tests whitespaces only. @@ -69,17 +80,6 @@ public function testWhitSpaceOnly(?string $string): void self::assertNull($clean); } - //-------------------------------------------------------------------------------------------------------------------- - /** - * Returns cases with with spaces only. - * - * @return array - */ - public function whitespaceOnly(): array - { - return [[''], [null], [' '], [' '], ["\n"], ["\n \n"], ["\n \t"], [" \t\n\r\0\x0B \t\n\r\0\x0B"]]; - } - //-------------------------------------------------------------------------------------------------------------------- } diff --git a/test/Cleaner/RemoveWhitespaceCleanerTest.php b/test/Cleaner/RemoveWhitespaceCleanerTest.php index 3910b8a..125c2f6 100644 --- a/test/Cleaner/RemoveWhitespaceCleanerTest.php +++ b/test/Cleaner/RemoveWhitespaceCleanerTest.php @@ -16,6 +16,17 @@ class RemoveWhitespaceCleanerTest extends PlaisioTestCase //-------------------------------------------------------------------------------------------------------------------- use StringCleaner; + //-------------------------------------------------------------------------------------------------------------------- + /** + * Returns cases with spaces only. + * + * @return array + */ + public static function whitespaceOnly(): array + { + return [[''], [null], [' '], [' '], ["\n"], ["\n \n"], ["\n \t"], [" \t\n\r\0\x0B \t\n\r\0\x0B"]]; + } + //-------------------------------------------------------------------------------------------------------------------- /** * Returns an instance of RemoveWhitespaceCleaner. @@ -56,17 +67,6 @@ public function testWhitSpaceOnly(?string $string): void self::assertNull($clean); } - //-------------------------------------------------------------------------------------------------------------------- - /** - * Returns cases with with spaces only. - * - * @return array - */ - public function whitespaceOnly(): array - { - return [[''], [null], [' '], [' '], ["\n"], ["\n \n"], ["\n \t"], [" \t\n\r\0\x0B \t\n\r\0\x0B"]]; - } - //-------------------------------------------------------------------------------------------------------------------- } diff --git a/test/Cleaner/TidyCleanerTest.php b/test/Cleaner/TidyCleanerTest.php index faf563a..5f4af16 100644 --- a/test/Cleaner/TidyCleanerTest.php +++ b/test/Cleaner/TidyCleanerTest.php @@ -17,27 +17,27 @@ class TidyCleanerTest extends PlaisioTestCase //-------------------------------------------------------------------------------------------------------------------- /** - * Returns an instance of TidyCleaner. + * Return HTML snippet test cases. * - * @return TidyCleaner + * @return string[][] */ - public function createCleaner(): TidyCleaner + public static function snippets(): array { - return TidyCleaner::get(); + return [['

subheading

', '

subheading

'], + ['

heading', '

heading

'], + ['
', '
'], + ['

 

', null]]; } //-------------------------------------------------------------------------------------------------------------------- /** - * Return HTML snippet test cases. + * Returns an instance of TidyCleaner. * - * @return string[][] + * @return TidyCleaner */ - public function snippets(): array + public function createCleaner(): TidyCleaner { - return [['

subheading

', '

subheading

'], - ['

heading', '

heading

'], - ['
', '
'], - ['

 

', null]]; + return TidyCleaner::get(); } //-------------------------------------------------------------------------------------------------------------------- diff --git a/test/Cleaner/Traits/StringCleaner.php b/test/Cleaner/Traits/StringCleaner.php index eb87401..545833b 100644 --- a/test/Cleaner/Traits/StringCleaner.php +++ b/test/Cleaner/Traits/StringCleaner.php @@ -14,10 +14,10 @@ trait StringCleaner * * @return array */ - public function getNonStrings(): array + public static function getNonStrings(): array { return [[[]], - [$this], + [new \stdClass()], [fopen('php://stdin', 'r')]]; } @@ -29,7 +29,7 @@ public function getNonStrings(): array * * @dataProvider getNonStrings */ - public function testNonString($value): void + public function testNonString(mixed $value): void { $this->expectException(\LogicException::class); diff --git a/test/Cleaner/TrimWhitespaceCleanerTest.php b/test/Cleaner/TrimWhitespaceCleanerTest.php index 3dd1293..942082b 100644 --- a/test/Cleaner/TrimWhitespaceCleanerTest.php +++ b/test/Cleaner/TrimWhitespaceCleanerTest.php @@ -15,6 +15,17 @@ class TrimWhitespaceCleanerTest extends PlaisioTestCase //-------------------------------------------------------------------------------------------------------------------- use StringCleaner; + //-------------------------------------------------------------------------------------------------------------------- + /** + * Returns cases with spaces only. + * + * @return array + */ + public static function whitespaceOnly(): array + { + return [[''], [null], [' '], [' '], ["\n"], ["\n \n"], ["\n \t"], [" \t\n\r\0\x0B \t\n\r\0\x0B"]]; + } + //-------------------------------------------------------------------------------------------------------------------- /** * Returns an instance of TrimWhitespaceCleaner. @@ -55,17 +66,6 @@ public function testWhitSpaceOnly(?string $string): void self::assertNull($clean); } - //-------------------------------------------------------------------------------------------------------------------- - /** - * Returns cases with with spaces only. - * - * @return array - */ - public function whitespaceOnly(): array - { - return [[''], [null], [' '], [' '], ["\n"], ["\n \n"], ["\n \t"], [" \t\n\r\0\x0B \t\n\r\0\x0B"]]; - } - //-------------------------------------------------------------------------------------------------------------------- } diff --git a/test/Control/ButtonControlTest.php b/test/Control/ButtonControlTest.php index 43934e5..0bef55c 100644 --- a/test/Control/ButtonControlTest.php +++ b/test/Control/ButtonControlTest.php @@ -9,7 +9,7 @@ /** * Unit tests for class ButtonControl. */ -class ButtonControlTest extends PushControlTest +class ButtonControlTest extends PushControlTestCase { //-------------------------------------------------------------------------------------------------------------------- /** diff --git a/test/Control/CheckboxControlTest.php b/test/Control/CheckboxControlTest.php index 1eb4871..58be9c2 100644 --- a/test/Control/CheckboxControlTest.php +++ b/test/Control/CheckboxControlTest.php @@ -8,7 +8,7 @@ use Plaisio\Form\Control\ForceSubmitControl; use Plaisio\Form\Control\SimpleControl; use Plaisio\Form\RawForm; -use Plaisio\Form\Test\Control\Traits\ImmutableTest; +use Plaisio\Form\Test\Control\Traits\ImmutableTestCase; use Plaisio\Form\Test\Control\Traits\InputElementTest1; use Plaisio\Form\Test\PlaisioTestCase; @@ -18,7 +18,7 @@ class CheckboxControlTest extends PlaisioTestCase { //-------------------------------------------------------------------------------------------------------------------- - use ImmutableTest; + use ImmutableTestCase; use InputElementTest1; //-------------------------------------------------------------------------------------------------------------------- diff --git a/test/Control/CheckboxesControlTest.php b/test/Control/CheckboxesControlTest.php index f3691c8..c12b83e 100644 --- a/test/Control/CheckboxesControlTest.php +++ b/test/Control/CheckboxesControlTest.php @@ -494,7 +494,7 @@ public function testWhiteListed1(): void //-------------------------------------------------------------------------------------------------------------------- /** - * Test labels are casted to strings. + * Test labels are cast to strings. */ public function testWithNumericValues(): void { diff --git a/test/Control/DatabaseLabelControlTest.php b/test/Control/DatabaseLabelControlTest.php index 356674f..6ae7737 100644 --- a/test/Control/DatabaseLabelControlTest.php +++ b/test/Control/DatabaseLabelControlTest.php @@ -15,7 +15,7 @@ class DatabaseLabelControlTest extends TestCase /** * Returns invalid label prefixes. */ - public function getInvalidPrefixes(): array + public static function getInvalidPrefixes(): array { return [['123ABC'], ['_CMP_ID'], diff --git a/test/Control/DateControlTest.php b/test/Control/DateControlTest.php index 111038c..5e2270b 100644 --- a/test/Control/DateControlTest.php +++ b/test/Control/DateControlTest.php @@ -10,17 +10,17 @@ use Plaisio\Form\Control\SimpleControl; use Plaisio\Form\Formatter\DateFormatter; use Plaisio\Form\RawForm; -use Plaisio\Form\Test\Control\Traits\ImmutableTest; +use Plaisio\Form\Test\Control\Traits\ImmutableTestCase; use Plaisio\Form\Test\Control\Traits\InputElementTest1; use Plaisio\Form\Test\Control\Traits\InputElementTest2; /** * Unit tests for class DateControl. */ -class DateControlTest extends SimpleControlTest +class DateControlTest extends SimpleControlTestCase { //-------------------------------------------------------------------------------------------------------------------- - use ImmutableTest; + use ImmutableTestCase; use InputElementTest1; use InputElementTest2; diff --git a/test/Control/FileControlTest.php b/test/Control/FileControlTest.php index 56ec0e5..99fbfbc 100644 --- a/test/Control/FileControlTest.php +++ b/test/Control/FileControlTest.php @@ -3,10 +3,8 @@ namespace Plaisio\Form\Test\Control; -use Plaisio\Form\Control\FieldSet; use Plaisio\Form\Control\FileControl; use Plaisio\Form\Control\SimpleControl; -use Plaisio\Form\RawForm; use Plaisio\Form\Test\Control\Traits\InputElementTest1; use Plaisio\Form\Test\PlaisioTestCase; diff --git a/test/Control/ForceSubmitControlTest.php b/test/Control/ForceSubmitControlTest.php index 08cf92b..91dfbc4 100644 --- a/test/Control/ForceSubmitControlTest.php +++ b/test/Control/ForceSubmitControlTest.php @@ -10,7 +10,7 @@ /** * Unit tests for class ForceSubmitControl. */ -class ForceSubmitControlTest extends PushControlTest +class ForceSubmitControlTest extends PushControlTestCase { //-------------------------------------------------------------------------------------------------------------------- use InputElementTest1; diff --git a/test/Control/HiddenControlTest.php b/test/Control/HiddenControlTest.php index c334d62..8f66cfe 100644 --- a/test/Control/HiddenControlTest.php +++ b/test/Control/HiddenControlTest.php @@ -9,16 +9,16 @@ use Plaisio\Form\Control\HiddenControl; use Plaisio\Form\Control\SimpleControl; use Plaisio\Form\RawForm; -use Plaisio\Form\Test\Control\Traits\ImmutableTest; +use Plaisio\Form\Test\Control\Traits\ImmutableTestCase; use Plaisio\Form\Test\Control\Traits\InputElementTest1; /** * Unit tests for class HiddenControl. */ -class HiddenControlTest extends SimpleControlTest +class HiddenControlTest extends SimpleControlTestCase { //-------------------------------------------------------------------------------------------------------------------- - use ImmutableTest; + use ImmutableTestCase; use InputElementTest1; //-------------------------------------------------------------------------------------------------------------------- diff --git a/test/Control/HiddenSubmitControlTest.php b/test/Control/HiddenSubmitControlTest.php index 5f05dfd..2d51b74 100644 --- a/test/Control/HiddenSubmitControlTest.php +++ b/test/Control/HiddenSubmitControlTest.php @@ -10,7 +10,7 @@ /** * Unit tests for class HiddenSubmitControl. */ -class HiddenSubmitControlTest extends PushControlTest +class HiddenSubmitControlTest extends PushControlTestCase { //-------------------------------------------------------------------------------------------------------------------- use InputElementTest1; diff --git a/test/Control/HtmlControlTest.php b/test/Control/HtmlControlTest.php index 48e1de0..ca762a6 100644 --- a/test/Control/HtmlControlTest.php +++ b/test/Control/HtmlControlTest.php @@ -204,7 +204,7 @@ protected function setUp(): void * * @return RawForm */ - private function setupForm1($html = null): RawForm + private function setupForm1(?string $html = null): RawForm { $form = new RawForm(); $fieldset = new FieldSet(); diff --git a/test/Control/HttpControlTest.php b/test/Control/HttpControlTest.php index 662e6d1..350595e 100644 --- a/test/Control/HttpControlTest.php +++ b/test/Control/HttpControlTest.php @@ -9,7 +9,7 @@ use Plaisio\Form\Control\SimpleControl; use Plaisio\Form\Control\UrlControl; use Plaisio\Form\RawForm; -use Plaisio\Form\Test\Control\Traits\ImmutableTest; +use Plaisio\Form\Test\Control\Traits\ImmutableTestCase; use Plaisio\Form\Test\Control\Traits\InputElementTest1; use Plaisio\Form\Test\Control\Traits\InputElementTest2; use Plaisio\Form\Test\PlaisioTestCase; @@ -20,7 +20,7 @@ class HttpControlTest extends PlaisioTestCase { //-------------------------------------------------------------------------------------------------------------------- - use ImmutableTest; + use ImmutableTestCase; use InputElementTest1; use InputElementTest2; diff --git a/test/Control/ImageControlTest.php b/test/Control/ImageControlTest.php index 33242f4..d60e507 100644 --- a/test/Control/ImageControlTest.php +++ b/test/Control/ImageControlTest.php @@ -3,10 +3,8 @@ namespace Plaisio\Form\Test\Control; -use Plaisio\Form\Control\FieldSet; use Plaisio\Form\Control\ImageControl; use Plaisio\Form\Control\SimpleControl; -use Plaisio\Form\RawForm; use Plaisio\Form\Test\Control\Traits\InputElementTest1; use Plaisio\Form\Test\PlaisioTestCase; diff --git a/test/Control/NumberControlTest.php b/test/Control/NumberControlTest.php index 175fc91..a7e2b0c 100644 --- a/test/Control/NumberControlTest.php +++ b/test/Control/NumberControlTest.php @@ -5,17 +5,17 @@ use Plaisio\Form\Control\NumberControl; use Plaisio\Form\Control\SimpleControl; -use Plaisio\Form\Test\Control\Traits\ImmutableTest; +use Plaisio\Form\Test\Control\Traits\ImmutableTestCase; use Plaisio\Form\Test\Control\Traits\InputElementTest1; use Plaisio\Form\Test\Control\Traits\InputElementTest2; /** * Unit tests for class NumberControl. */ -class NumberControlTest extends SimpleControlTest +class NumberControlTest extends SimpleControlTestCase { //-------------------------------------------------------------------------------------------------------------------- - use ImmutableTest; + use ImmutableTestCase; use InputElementTest1; use InputElementTest2; diff --git a/test/Control/PasswordControlTest.php b/test/Control/PasswordControlTest.php index 2c780a5..6088ecc 100644 --- a/test/Control/PasswordControlTest.php +++ b/test/Control/PasswordControlTest.php @@ -5,17 +5,17 @@ use Plaisio\Form\Control\PasswordControl; use Plaisio\Form\Control\SimpleControl; -use Plaisio\Form\Test\Control\Traits\ImmutableTest; +use Plaisio\Form\Test\Control\Traits\ImmutableTestCase; use Plaisio\Form\Test\Control\Traits\InputElementTest1; use Plaisio\Form\Test\Control\Traits\InputElementTest2; /** * Unit tests for class PasswordControl. */ -class PasswordControlTest extends SimpleControlTest +class PasswordControlTest extends SimpleControlTestCase { //-------------------------------------------------------------------------------------------------------------------- - use ImmutableTest; + use ImmutableTestCase; use InputElementTest1; use InputElementTest2; diff --git a/test/Control/PushControlTest.php b/test/Control/PushControlTestCase.php similarity index 98% rename from test/Control/PushControlTest.php rename to test/Control/PushControlTestCase.php index 5d988d6..7d3ecbd 100644 --- a/test/Control/PushControlTest.php +++ b/test/Control/PushControlTestCase.php @@ -8,16 +8,16 @@ use Plaisio\Form\Control\PushControl; use Plaisio\Form\Control\SimpleControl; use Plaisio\Form\RawForm; -use Plaisio\Form\Test\Control\Traits\CommonSimpleControlTest; +use Plaisio\Form\Test\Control\Traits\CommonSimpleControlTestCase; use Plaisio\Form\Test\PlaisioTestCase; /** * Abstract parent class for unit tests for child classes of PushControl. */ -abstract class PushControlTest extends PlaisioTestCase +abstract class PushControlTestCase extends PlaisioTestCase { //-------------------------------------------------------------------------------------------------------------------- - use CommonSimpleControlTest; + use CommonSimpleControlTestCase; //-------------------------------------------------------------------------------------------------------------------- /** diff --git a/test/Control/RadioControlTest.php b/test/Control/RadioControlTest.php index 0deeafd..f934c3f 100644 --- a/test/Control/RadioControlTest.php +++ b/test/Control/RadioControlTest.php @@ -232,17 +232,26 @@ private function setForm2(int $immutable = null): RawForm $input = new RadioControl('name'); $input->setAttrValue(1) ->setValue(1); - if ($immutable===1) $input->setImmutable(true); + if ($immutable===1) + { + $input->setImmutable(true); + } $fieldset->addFormControl($input); $input = new RadioControl('name'); $input->setAttrValue(2); - if ($immutable===2) $input->setImmutable(true); + if ($immutable===2) + { + $input->setImmutable(true); + } $fieldset->addFormControl($input); $input = new RadioControl('name'); $input->setAttrValue(3); - if ($immutable===3) $input->setImmutable(true); + if ($immutable===3) + { + $input->setImmutable(true); + } $fieldset->addFormControl($input); $input = new ForceSubmitControl('submit', true); diff --git a/test/Control/RadiosControlTest.php b/test/Control/RadiosControlTest.php index 92a99ae..66ac8f6 100644 --- a/test/Control/RadiosControlTest.php +++ b/test/Control/RadiosControlTest.php @@ -22,7 +22,7 @@ class RadiosControlTest extends PlaisioTestCase * * @return array */ - public function getEmptyValues(): array + public static function getEmptyValues(): array { $cases = []; @@ -39,7 +39,7 @@ public function getEmptyValues(): array * * @return array[] */ - public function setValueCases(): array + public static function setValueCases(): array { $cases = []; @@ -252,7 +252,7 @@ public function testMutable(): void * * @dataProvider setValueCases */ - public function testSetValue($value, $submitted, $expected) + public function testSetValue(mixed $value, mixed $submitted, mixed $expected) { $_POST['cnt_id'] = $submitted; @@ -350,13 +350,13 @@ public function testWhiteListed2(): void //-------------------------------------------------------------------------------------------------------------------- /** - * Test labels are casted to strings. + * Test labels are cast to strings. * * @param mixed $empty The empty value. * * @dataProvider getEmptyValues */ - public function testWithEmptyValue($empty): void + public function testWithEmptyValue(mixed $empty): void { $_POST['day_id'] = $empty; @@ -386,7 +386,7 @@ public function testWithEmptyValue($empty): void //-------------------------------------------------------------------------------------------------------------------- /** - * Test labels are casted to strings. + * Test labels are cast to strings. */ public function testWithNumericValues(): void { diff --git a/test/Control/SelectControlTest.php b/test/Control/SelectControlTest.php index d9555ff..f6d6b31 100644 --- a/test/Control/SelectControlTest.php +++ b/test/Control/SelectControlTest.php @@ -20,7 +20,7 @@ class SelectControlTest extends PlaisioTestCase * * @return array */ - public function getEmptyValues(): array + public static function getEmptyValues(): array { $cases = []; @@ -37,7 +37,7 @@ public function getEmptyValues(): array * * @return array[] */ - public function setValueCases(): array + public static function setValueCases(): array { $cases = []; @@ -230,7 +230,7 @@ public function testMutable(): void * * @dataProvider setValueCases */ - public function testSetValue($value, $submitted, $expected) + public function testSetValue(mixed $value, mixed $submitted, mixed $expected) { $_POST['cnt_id'] = $submitted; @@ -343,13 +343,13 @@ public function testWhiteListed2(): void //-------------------------------------------------------------------------------------------------------------------- /** - * Test labels are casted to strings. + * Test labels are cast to strings. * * @param mixed $empty The empty value. * * @dataProvider getEmptyValues */ - public function testWithEmptyValue($empty): void + public function testWithEmptyValue(mixed $empty): void { $_POST['day_id'] = $empty; @@ -379,7 +379,7 @@ public function testWithEmptyValue($empty): void //-------------------------------------------------------------------------------------------------------------------- /** - * Test labels are casted to strings. + * Test labels are cast to strings. */ public function testWithNumericValues(): void { diff --git a/test/Control/SilentControlTest.php b/test/Control/SilentControlTest.php index 817f0c6..c43fb47 100644 --- a/test/Control/SilentControlTest.php +++ b/test/Control/SilentControlTest.php @@ -253,7 +253,7 @@ protected function getValidValue(): string * * @return RawForm */ - private function setupForm1($value): RawForm + private function setupForm1(mixed $value): RawForm { $form = new RawForm(); $fieldset = new FieldSet(); diff --git a/test/Control/SimpleControlTest.php b/test/Control/SimpleControlTestCase.php similarity index 96% rename from test/Control/SimpleControlTest.php rename to test/Control/SimpleControlTestCase.php index eb9ca9a..4ec0b1e 100644 --- a/test/Control/SimpleControlTest.php +++ b/test/Control/SimpleControlTestCase.php @@ -10,9 +10,9 @@ use Plaisio\Form\Test\PlaisioTestCase; /** - * Abstract parent class for unit tests for child classes of CommonSimpleControlTest. + * Abstract parent class for unit tests for child classes of CommonSimpleControlTestCase. */ -abstract class SimpleControlTest extends PlaisioTestCase +abstract class SimpleControlTestCase extends PlaisioTestCase { //-------------------------------------------------------------------------------------------------------------------- /** @@ -133,7 +133,7 @@ public function testValid103(): void //-------------------------------------------------------------------------------------------------------------------- /** - * Returns the concrete CommonSimpleControlTest + * Returns the concrete CommonSimpleControlTestCase * * @param string $name The name of the form control. * @@ -171,7 +171,7 @@ protected function getValidSubmittedValue(): string * * @return RawForm */ - private function setupForm1($value): RawForm + private function setupForm1(mixed $value): RawForm { $form = new RawForm(); $fieldset = new FieldSet(); diff --git a/test/Control/SubmitControlTest.php b/test/Control/SubmitControlTest.php index 053ad53..e9e0362 100644 --- a/test/Control/SubmitControlTest.php +++ b/test/Control/SubmitControlTest.php @@ -9,7 +9,7 @@ /** * Unit tests for class SubmitControl. */ -class SubmitControlTest extends PushControlTest +class SubmitControlTest extends PushControlTestCase { //-------------------------------------------------------------------------------------------------------------------- public function testAttributes(): void diff --git a/test/Control/TelControlTest.php b/test/Control/TelControlTest.php index f4a6ad2..bef82b6 100644 --- a/test/Control/TelControlTest.php +++ b/test/Control/TelControlTest.php @@ -8,17 +8,17 @@ use Plaisio\Form\Control\SimpleControl; use Plaisio\Form\Control\TelControl; use Plaisio\Form\RawForm; -use Plaisio\Form\Test\Control\Traits\ImmutableTest; +use Plaisio\Form\Test\Control\Traits\ImmutableTestCase; use Plaisio\Form\Test\Control\Traits\InputElementTest1; use Plaisio\Form\Test\Control\Traits\InputElementTest2; /** * Unit tests for class TelControl. */ -class TelControlTest extends SimpleControlTest +class TelControlTest extends SimpleControlTestCase { //-------------------------------------------------------------------------------------------------------------------- - use ImmutableTest; + use ImmutableTestCase; use InputElementTest1; use InputElementTest2; diff --git a/test/Control/TextAreaControlTest.php b/test/Control/TextAreaControlTest.php index 181d42b..eb7a46c 100644 --- a/test/Control/TextAreaControlTest.php +++ b/test/Control/TextAreaControlTest.php @@ -8,8 +8,8 @@ use Plaisio\Form\Control\ForceSubmitControl; use Plaisio\Form\Control\TextAreaControl; use Plaisio\Form\RawForm; -use Plaisio\Form\Test\Control\Traits\CommonSimpleControlTest; -use Plaisio\Form\Test\Control\Traits\ImmutableTest; +use Plaisio\Form\Test\Control\Traits\CommonSimpleControlTestCase; +use Plaisio\Form\Test\Control\Traits\ImmutableTestCase; use Plaisio\Form\Test\PlaisioTestCase; /** @@ -18,11 +18,11 @@ class TextAreaControlTest extends PlaisioTestCase { //-------------------------------------------------------------------------------------------------------------------- - use ImmutableTest; - use CommonSimpleControlTest + use ImmutableTestCase; + use CommonSimpleControlTestCase { - CommonSimpleControlTest::stringAttributes as parentStringAttributes; - CommonSimpleControlTest::integerAttributes as parentIntegerAttributes; + CommonSimpleControlTestCase::stringAttributes as parentStringAttributes; + CommonSimpleControlTestCase::integerAttributes as parentIntegerAttributes; } //-------------------------------------------------------------------------------------------------------------------- @@ -31,9 +31,9 @@ class TextAreaControlTest extends PlaisioTestCase * * @return string[][] */ - public function integerAttributes(): array + public static function integerAttributes(): array { - $ret = $this->parentIntegerAttributes(); + $ret = self::parentIntegerAttributes(); $ret[] = ['setAttrCols', 'cols']; $ret[] = ['setAttrRows', 'rows']; @@ -47,9 +47,9 @@ public function integerAttributes(): array * * @return string[][] */ - public function stringAttributes(): array + public static function stringAttributes(): array { - $ret = $this->parentStringAttributes(); + $ret = self::parentStringAttributes(); $ret[] = ['setAttrWrap', 'wrap']; @@ -140,7 +140,7 @@ public function testSubmittedValue(): void //-------------------------------------------------------------------------------------------------------------------- /** - * Test labels are casted to strings. + * Test labels are cast to strings. */ public function testWithNumericValues(): void { diff --git a/test/Control/TextControlTest.php b/test/Control/TextControlTest.php index 9ca6f31..2a6aa39 100644 --- a/test/Control/TextControlTest.php +++ b/test/Control/TextControlTest.php @@ -11,17 +11,17 @@ use Plaisio\Form\Control\TextControl; use Plaisio\Form\Formatter\DateFormatter; use Plaisio\Form\RawForm; -use Plaisio\Form\Test\Control\Traits\ImmutableTest; +use Plaisio\Form\Test\Control\Traits\ImmutableTestCase; use Plaisio\Form\Test\Control\Traits\InputElementTest1; use Plaisio\Form\Test\Control\Traits\InputElementTest2; /** * Unit tests for class TextControl. */ -class TextControlTest extends SimpleControlTest +class TextControlTest extends SimpleControlTestCase { //-------------------------------------------------------------------------------------------------------------------- - use ImmutableTest; + use ImmutableTestCase; use InputElementTest1; use InputElementTest2; diff --git a/test/Control/Traits/CommonSimpleControlTest.php b/test/Control/Traits/CommonSimpleControlTestCase.php similarity index 94% rename from test/Control/Traits/CommonSimpleControlTest.php rename to test/Control/Traits/CommonSimpleControlTestCase.php index 4b71318..404fa2f 100644 --- a/test/Control/Traits/CommonSimpleControlTest.php +++ b/test/Control/Traits/CommonSimpleControlTestCase.php @@ -4,9 +4,9 @@ namespace Plaisio\Form\Test\Control\Traits; /** - * Test cases for child classes of CommonSimpleControlTest. + * Test cases for child classes of CommonSimpleControlTestCase. */ -trait CommonSimpleControlTest +trait CommonSimpleControlTestCase { //-------------------------------------------------------------------------------------------------------------------- /** @@ -14,7 +14,7 @@ trait CommonSimpleControlTest * * @return string[][] */ - public function booleanAttributes(): array + public static function booleanAttributes(): array { return [['setAttrAutoComplete', 'autocomplete'], ['setAttrAutoFocus', 'autofocus'], @@ -32,7 +32,7 @@ public function booleanAttributes(): array * * @return string[][] */ - public function integerAttributes(): array + public static function integerAttributes(): array { return [['setAttrMaxLength', 'maxlength'], ['setAttrSize', 'size']]; @@ -44,7 +44,7 @@ public function integerAttributes(): array * * @return string[][] */ - public function stringAttributes(): array + public static function stringAttributes(): array { return [['setAttrForm', 'form'], ['setAttrList', 'list'], diff --git a/test/Control/Traits/ImmutableTest.php b/test/Control/Traits/ImmutableTestCase.php similarity index 99% rename from test/Control/Traits/ImmutableTest.php rename to test/Control/Traits/ImmutableTestCase.php index b10857c..7e7fe45 100644 --- a/test/Control/Traits/ImmutableTest.php +++ b/test/Control/Traits/ImmutableTestCase.php @@ -11,7 +11,7 @@ /** * Test for immutable form controls. */ -trait ImmutableTest +trait ImmutableTestCase { //-------------------------------------------------------------------------------------------------------------------- /** diff --git a/test/Control/Traits/InputElementTest1.php b/test/Control/Traits/InputElementTest1.php index 4458a5c..1debdef 100644 --- a/test/Control/Traits/InputElementTest1.php +++ b/test/Control/Traits/InputElementTest1.php @@ -36,8 +36,10 @@ public function testHtml(): void $form = new RawForm('myForm'); $form->addFieldSet($fieldSet); - $html = $form->htmlForm(); - $expected = sprintf('
', $this->getControlClass(), $this->getControlType()); + $html = $form->htmlForm(); + $expected = sprintf('
', + $this->getControlClass(), + $this->getControlType()); self::assertSame($expected, $html); } diff --git a/test/Control/UrlControlTest.php b/test/Control/UrlControlTest.php index 026dad9..7f224a1 100644 --- a/test/Control/UrlControlTest.php +++ b/test/Control/UrlControlTest.php @@ -8,7 +8,7 @@ use Plaisio\Form\Control\SimpleControl; use Plaisio\Form\Control\UrlControl; use Plaisio\Form\RawForm; -use Plaisio\Form\Test\Control\Traits\ImmutableTest; +use Plaisio\Form\Test\Control\Traits\ImmutableTestCase; use Plaisio\Form\Test\Control\Traits\InputElementTest1; use Plaisio\Form\Test\Control\Traits\InputElementTest2; use Plaisio\Form\Test\PlaisioTestCase; @@ -19,7 +19,7 @@ class UrlControlTest extends PlaisioTestCase { //-------------------------------------------------------------------------------------------------------------------- - use ImmutableTest; + use ImmutableTestCase; use InputElementTest1; use InputElementTest2; diff --git a/test/RawFormTest.php b/test/RawFormTest.php index f6c6185..0397534 100644 --- a/test/RawFormTest.php +++ b/test/RawFormTest.php @@ -85,7 +85,7 @@ public function testFindFieldSet(): void //-------------------------------------------------------------------------------------------------------------------- /** - * Test for finding a complex with with different types of names. + * Test for finding a complex with different types of names. */ public function testFindSimpleControl(): void { diff --git a/test/Validator/DateValidatorTest.php b/test/Validator/DateValidatorTest.php index f1e7dbf..668a38f 100644 --- a/test/Validator/DateValidatorTest.php +++ b/test/Validator/DateValidatorTest.php @@ -17,7 +17,7 @@ class DateValidatorTest extends PlaisioTestCase * * @return array */ - public function getInvalidValues(): array + public static function getInvalidValues(): array { return [['15- 7 -20'], ['10-april-1966'], @@ -25,7 +25,7 @@ public function getInvalidValues(): array ['15- 7 -20'], ['2015-02-29'], ['2020-11-31'], - [$this], + [new \stdClass()], ['foo' => 'bar'], [false], [true]]; @@ -37,7 +37,7 @@ public function getInvalidValues(): array * * @return array */ - public function getValidValues(): array + public static function getValidValues(): array { return [['1966-04-10'], ['1970-01-01'], ['1900-01-01'], ['9999-12-31'], ['2020-02-29'], [''], [null]]; } @@ -50,7 +50,7 @@ public function getValidValues(): array * * @dataProvider getInvalidValues */ - public function testInvalidDates($value): void + public function testInvalidDates(mixed $value): void { $control = new TestControl('test', $value); $validator = new DateValidator(); @@ -66,7 +66,7 @@ public function testInvalidDates($value): void * * @dataProvider getValidValues */ - public function testValidDates($value): void + public function testValidDates(mixed $value): void { $control = new TestControl('test', $value); $validator = new DateValidator(); diff --git a/test/Validator/EmailValidatorTest.php b/test/Validator/EmailValidatorTest.php index 6c7bc02..824bddf 100644 --- a/test/Validator/EmailValidatorTest.php +++ b/test/Validator/EmailValidatorTest.php @@ -17,7 +17,7 @@ class EmailValidatorTest extends PlaisioTestCase * * @return array */ - public function getInvalidValues(): array + public static function getInvalidValues(): array { $ret = []; @@ -35,7 +35,7 @@ public function getInvalidValues(): array // An email address without an existing A or MX record is invalid. $ret[] = ['info@xsetbased.nl']; - // An email address with a to long local part must be invalid. The maximum length of the local part is 64 characters, + // An email address with to long local part must be invalid. The maximum length of the local part is 64 characters, // see http://en.wikipedia.org/wiki/Email_address. $local = str_repeat('x', 65); $ret[] = ["$local@setbased.nl"]; @@ -44,7 +44,7 @@ public function getInvalidValues(): array $ret[] = ['info.setbased.nl']; // Only strings are valid - $ret[] = [$this]; + $ret[] = [new \stdClass()]; $ret[] = [['foo' => 'bar']]; $ret[] = [false]; $ret[] = [true]; @@ -58,7 +58,7 @@ public function getInvalidValues(): array * * @return array */ - public function getValidValues(): array + public static function getValidValues(): array { $ret = []; @@ -94,7 +94,7 @@ public function getValidValues(): array * * @dataProvider getInvalidValues */ - public function testInvalidAddresses($value): void + public function testInvalidAddresses(mixed $value): void { $control = new TestControl('test', $value); $validator = new EmailValidator(); @@ -110,7 +110,7 @@ public function testInvalidAddresses($value): void * * @dataProvider getValidValues */ - public function testValidAddresses($value): void + public function testValidAddresses(mixed $value): void { $control = new TestControl('test', $value); $validator = new EmailValidator(); diff --git a/test/Validator/HttpValidatorTest.php b/test/Validator/HttpValidatorTest.php index 6c2edc1..c737788 100644 --- a/test/Validator/HttpValidatorTest.php +++ b/test/Validator/HttpValidatorTest.php @@ -17,11 +17,11 @@ class HttpValidatorTest extends PlaisioTestCase * * @return array */ - public function getInvalidValues(): array + public static function getInvalidValues(): array { $ret = []; - // An usual url address must be invalid. + // A unusual url address must be invalid. $ret[] = ['hffd//:www.setbased/nl']; $ret[] = ['http//golgelinva']; $ret[] = ['ftp//:!#$%&\'*+-/=?^_`{}|~ed.com']; @@ -33,7 +33,7 @@ public function getInvalidValues(): array $ret[] = ['http://www.xsetbased.nl']; // Only strings are valid - $ret[] = [$this]; + $ret[] = [new \stdClass()]; $ret[] = [['foo' => 'bar']]; $ret[] = [false]; $ret[] = [true]; @@ -47,7 +47,7 @@ public function getInvalidValues(): array * * @return array */ - public function getValidValues(): array + public static function getValidValues(): array { $ret = []; @@ -73,7 +73,7 @@ public function getValidValues(): array * * @dataProvider getInvalidValues */ - public function testInvalidUrl($value): void + public function testInvalidUrl(mixed $value): void { $control = new TestControl('test', $value); $validator = new HttpValidator(); @@ -89,7 +89,7 @@ public function testInvalidUrl($value): void * * @dataProvider getValidValues */ - public function testValidUrl($value): void + public function testValidUrl(mixed $value): void { $control = new TestControl('test', $value); $validator = new HttpValidator(); diff --git a/test/Validator/IntegerValidatorTest.php b/test/Validator/IntegerValidatorTest.php index 8519435..d25de4a 100644 --- a/test/Validator/IntegerValidatorTest.php +++ b/test/Validator/IntegerValidatorTest.php @@ -17,7 +17,7 @@ class IntegerValidatorTest extends TestCase * * @return array */ - public function getInvalidValues(): array + public static function getInvalidValues(): array { $ret = []; @@ -36,7 +36,7 @@ public function getInvalidValues(): array $ret[] = [-1, 10, -23]; // Only strings or integers are valid. - $ret[] = [null, null, $this]; + $ret[] = [null, null, new \stdClass()]; $ret[] = [null, null, ['foo' => 'bar']]; return $ret; @@ -48,7 +48,7 @@ public function getInvalidValues(): array * * @return array */ - public function getValidValues(): array + public static function getValidValues(): array { $ret = []; @@ -79,43 +79,43 @@ public function getValidValues(): array //-------------------------------------------------------------------------------------------------------------------- /** - * Test against invalid strings. + * Test against valid strings. * * @param int|null $minValue The minimum value. * @param int|null $maxValue The maximum value. - * @param mixed $value The invalid value. + * @param mixed $value The valid value. * - * @dataProvider getInvalidValues + * @dataProvider getValidValues */ - public function testInvalidValues(?int $minValue, ?int $maxValue, $value): void + public static function testValidValues(?int $minValue, ?int $maxValue, mixed $value): void { $control = new TestControl('test', $value); $validator = new IntegerValidator($minValue, $maxValue); $valid = $validator->validate($control); $errors = $control->getErrorMessages(); - self::assertFalse($valid); - self::assertIsArray($errors); - self::assertCount(1, $errors); + self::assertTrue($valid); + self::assertNull($errors); } //-------------------------------------------------------------------------------------------------------------------- /** - * Test against valid strings. + * Test against invalid strings. * * @param int|null $minValue The minimum value. * @param int|null $maxValue The maximum value. - * @param mixed $value The valid value. + * @param mixed $value The invalid value. * - * @dataProvider getValidValues + * @dataProvider getInvalidValues */ - public function testValidValues(?int $minValue, ?int $maxValue, $value): void + public function testInvalidValues(?int $minValue, ?int $maxValue, mixed $value): void { $control = new TestControl('test', $value); $validator = new IntegerValidator($minValue, $maxValue); $valid = $validator->validate($control); $errors = $control->getErrorMessages(); - self::assertTrue($valid); - self::assertNull($errors); + self::assertFalse($valid); + self::assertIsArray($errors); + self::assertCount(1, $errors); } //-------------------------------------------------------------------------------------------------------------------- diff --git a/test/Validator/LengthValidatorTest.php b/test/Validator/LengthValidatorTest.php index 42f64cb..74286e6 100644 --- a/test/Validator/LengthValidatorTest.php +++ b/test/Validator/LengthValidatorTest.php @@ -17,7 +17,7 @@ class LengthValidatorTest extends TestCase * * @return array */ - public function getInvalidValues(): array + public static function getInvalidValues(): array { $ret = []; @@ -28,7 +28,7 @@ public function getInvalidValues(): array $ret[] = [10, 20, 'Isaac']; // Only strings are valid - $ret[] = [0, 100, $this]; + $ret[] = [0, 100, new \stdClass()]; $ret[] = [0, 100, ['foo' => 'bar']]; $ret[] = [0, 100, false]; $ret[] = [0, 100, true]; @@ -42,7 +42,7 @@ public function getInvalidValues(): array * * @return array */ - public function getValidValues(): array + public static function getValidValues(): array { $ret = []; @@ -72,7 +72,7 @@ public function getValidValues(): array * * @dataProvider getInvalidValues */ - public function testInvalidStrings(int $minLength, int $maxLength, $value): void + public function testInvalidStrings(int $minLength, int $maxLength, mixed $value): void { $control = new TestControl('test', $value); $validator = new LengthValidator($minLength, $maxLength); @@ -90,7 +90,7 @@ public function testInvalidStrings(int $minLength, int $maxLength, $value): void * * @dataProvider getValidValues */ - public function testValidStrings(int $minLength, int $maxLength, $value): void + public function testValidStrings(int $minLength, int $maxLength, mixed $value): void { $control = new TestControl('test', $value); $validator = new LengthValidator($minLength, $maxLength); diff --git a/test/Validator/MandatoryValidatorTest.php b/test/Validator/MandatoryValidatorTest.php index 7eb1dde..15972c8 100644 --- a/test/Validator/MandatoryValidatorTest.php +++ b/test/Validator/MandatoryValidatorTest.php @@ -17,7 +17,7 @@ class MandatoryValidatorTest extends PlaisioTestCase * * @return array */ - public function getInvalidValues(): array + public static function getInvalidValues(): array { $ret = []; @@ -36,7 +36,7 @@ public function getInvalidValues(): array * * @return array */ - public function getValidValues(): array + public static function getValidValues(): array { $ret = []; @@ -44,7 +44,7 @@ public function getValidValues(): array $ret[] = [true]; $ret[] = [0]; $ret[] = ['0']; - $ret[] = [$this]; + $ret[] = [new \stdClass()]; $ret[] = [['options' => ['a' => false, 'b' => true, 'c' => false]]]; $ret[] = [['options' => ['a' => '', 'b' => '0', 'c' => null]]]; $ret[] = [['options' => ['a' => '', 'b' => 0, 'c' => null]]]; @@ -61,7 +61,7 @@ public function getValidValues(): array * * @dataProvider getInvalidValues */ - public function testInvalidAddresses($value): void + public function testInvalidAddresses(mixed $value): void { $control = new TestControl('test', $value); $validator = new MandatoryValidator(); @@ -80,7 +80,7 @@ public function testInvalidAddresses($value): void * * @dataProvider getValidValues */ - public function testValidAddresses($value): void + public function testValidAddresses(mixed $value): void { $control = new TestControl('test', $value); $validator = new MandatoryValidator(); diff --git a/test/Validator/ProxyCompoundValidatorTest.php b/test/Validator/ProxyCompoundValidatorTest.php index ee83902..b4291c9 100644 --- a/test/Validator/ProxyCompoundValidatorTest.php +++ b/test/Validator/ProxyCompoundValidatorTest.php @@ -73,7 +73,7 @@ public function test04(): void * * @return bool */ - public function validate(CompoundControl $control, $data = null): bool + public function validate(CompoundControl $control, mixed $data = null): bool { $input = $control->getFormControlByName('input'); @@ -88,7 +88,7 @@ public function validate(CompoundControl $control, $data = null): bool * * @return RawForm */ - private function setupForm1($data = null): RawForm + private function setupForm1(mixed $data = null): RawForm { $form = new RawForm(); $fieldset = new FieldSet(); diff --git a/test/Validator/ProxyValidatorTest.php b/test/Validator/ProxyValidatorTest.php index 8342501..535696e 100644 --- a/test/Validator/ProxyValidatorTest.php +++ b/test/Validator/ProxyValidatorTest.php @@ -73,7 +73,7 @@ public function test04(): void * * @return bool */ - public function validate(Control $control, $data = null): bool + public function validate(Control $control, mixed $data = null): bool { return ($control->getSubmittedValue()==$data); } @@ -82,11 +82,11 @@ public function validate(Control $control, $data = null): bool /** * Setups a form with a text form control (which must be a valid email address) values. * - * @param mixed $data The additional data. + * @param mixed|null $data The additional data. * * @return RawForm */ - private function setupForm1($data = null): RawForm + private function setupForm1(mixed $data = null): RawForm { $form = new RawForm(); $fieldset = new FieldSet(); diff --git a/test/Validator/TestControl.php b/test/Validator/TestControl.php index 40a3de7..03e49a2 100644 --- a/test/Validator/TestControl.php +++ b/test/Validator/TestControl.php @@ -18,7 +18,7 @@ class TestControl extends Control * * @var mixed */ - public $value; + public mixed $value; //-------------------------------------------------------------------------------------------------------------------- /** @@ -27,7 +27,7 @@ class TestControl extends Control * @param string $name The name of the form control. * @param mixed $value The value of this form control. */ - public function __construct(string $name, $value) + public function __construct(string $name, mixed $value) { parent::__construct($name); @@ -38,7 +38,7 @@ public function __construct(string $name, $value) /** * @inheritDoc */ - public function htmlControl(RenderWalker $walker): string + public function getSetValuesBase(array &$values): void { throw new \LogicException('Not implemented'); } @@ -47,18 +47,18 @@ public function htmlControl(RenderWalker $walker): string /** * @inheritDoc */ - public function getSetValuesBase(array &$values): void + public function getSubmittedValue(): mixed { - throw new \LogicException('Not implemented'); + return $this->value; } //-------------------------------------------------------------------------------------------------------------------- /** * @inheritDoc */ - public function getSubmittedValue(): mixed + public function htmlControl(RenderWalker $walker): string { - return $this->value; + throw new \LogicException('Not implemented'); } //-------------------------------------------------------------------------------------------------------------------- diff --git a/test/Walker/LoadWalkerTest.php b/test/Walker/LoadWalkerTest.php index 0db4bf0..2829da4 100644 --- a/test/Walker/LoadWalkerTest.php +++ b/test/Walker/LoadWalkerTest.php @@ -25,7 +25,6 @@ public function testDescendWithBogusData(): void { $whiteListValues = []; $changedControls = []; - $branch = []; $submittedValues = ['test1' => '', 'test2' => 'xxx']; @@ -175,7 +174,7 @@ public function testGetWhitelistValueByPath4(): void public function testGetWhitelistValueByPath5(): void { $this->expectException(\LogicException::class); - $this->expectExceptionMessage('Branch Z does not exists at path /.'); + $this->expectExceptionMessage('Branch Z does not exist at path /.'); TestControl::$testName = 'getWhitelistValueByPath(/Z)'; TestControl::$testControlName = 'CCC'; diff --git a/test/Walker/TestControl.php b/test/Walker/TestControl.php index 1bc43a1..6fbeac8 100644 --- a/test/Walker/TestControl.php +++ b/test/Walker/TestControl.php @@ -32,7 +32,7 @@ class TestControl extends TextControl * * @var mixed */ - public static $testResult = null; + public static mixed $testResult = null; //-------------------------------------------------------------------------------------------------------------------- /**