From 016f9769f5bf21d2e9ac716e64be093e4d207391 Mon Sep 17 00:00:00 2001 From: Karsten Dambekalns Date: Tue, 11 Aug 2026 19:34:49 +0200 Subject: [PATCH 1/5] TASK: Replace PhpUnit annotations with attributes PhpUnit 11 deprecated metadata in doc comments, so `@test`, `@dataProvider` and `@group large` are replaced by the `#[Test]`, `#[DataProvider]` and `#[Large]` attributes across all tests. --- .../Functional/AbstractFunctionalTestCase.php | 5 +- Tests/Functional/FormBuildingFinishedTest.php | 10 +- Tests/Functional/SimpleFormTest.php | 27 ++-- .../Unit/Core/Model/AbstractFinisherTest.php | 46 +++--- .../Core/Model/AbstractFormElementTest.php | 46 ++---- Tests/Unit/Core/Model/FinisherContextTest.php | 17 +-- Tests/Unit/Core/Model/FormDefinitionTest.php | 138 ++++++------------ Tests/Unit/Core/Model/PageTest.php | 104 ++++--------- Tests/Unit/Core/Model/ProcessingRuleTest.php | 35 ++--- Tests/Unit/Core/Renderer/FormRuntimeTest.php | 42 ++---- .../Unit/Factory/AbstractFormFactoryTest.php | 28 ++-- Tests/Unit/Factory/ArrayFormFactoryTest.php | 19 +-- .../YamlPersistenceManagerTest.php | 47 ++---- Tests/Unit/Utility/SupertypeResolverTest.php | 16 +- Tests/Unit/ViewHelpers/FormViewHelperTest.php | 7 +- 15 files changed, 194 insertions(+), 393 deletions(-) diff --git a/Tests/Functional/AbstractFunctionalTestCase.php b/Tests/Functional/AbstractFunctionalTestCase.php index c254f750..e7f642e6 100644 --- a/Tests/Functional/AbstractFunctionalTestCase.php +++ b/Tests/Functional/AbstractFunctionalTestCase.php @@ -11,7 +11,7 @@ * information, please view the LICENSE file which was distributed with this * source code. */ - +use PHPUnit\Framework\Attributes\Large; use Neos\Flow\Http\Client\Browser; use Neos\Flow\Mvc\Routing\Route; use Neos\Flow\Tests\FunctionalTestCase; @@ -21,9 +21,8 @@ /** * Testcase for Simple Form - * - * @group large */ +#[Large] abstract class AbstractFunctionalTestCase extends FunctionalTestCase { /** diff --git a/Tests/Functional/FormBuildingFinishedTest.php b/Tests/Functional/FormBuildingFinishedTest.php index 4823b857..c311cecf 100644 --- a/Tests/Functional/FormBuildingFinishedTest.php +++ b/Tests/Functional/FormBuildingFinishedTest.php @@ -10,19 +10,17 @@ * information, please view the LICENSE file which was distributed with this * source code. */ - +use PHPUnit\Framework\Attributes\Large; +use PHPUnit\Framework\Attributes\Test; use PHPUnit\Framework\Assert; /** * Testcase for onBuildingFinished - * - * @group large */ +#[Large] class FormBuildingFinishedTest extends AbstractFunctionalTestCase { - /** - * @test - */ + #[Test] public function aFormElementCanAddNewSubelementsWithValidationApplied() { $this->browser->request('http://localhost/test/form/simpleform/TestingFormBuildingFinished'); diff --git a/Tests/Functional/SimpleFormTest.php b/Tests/Functional/SimpleFormTest.php index 97500984..4525495b 100644 --- a/Tests/Functional/SimpleFormTest.php +++ b/Tests/Functional/SimpleFormTest.php @@ -10,22 +10,21 @@ * information, please view the LICENSE file which was distributed with this * source code. */ +use PHPUnit\Framework\Attributes\Large; +use PHPUnit\Framework\Attributes\Test; use Neos\Utility\ObjectAccess; use PHPUnit\Framework\Assert; use Symfony\Component\DomCrawler\Field\InputFormField; /** * Testcase for Simple Form - * - * @group large */ +#[Large] class SimpleFormTest extends AbstractFunctionalTestCase { protected static $testablePersistenceEnabled = true; - /** - * @test - */ + #[Test] public function goingForthAndBackStoresFormValuesOfFirstPage() { $this->browser->request('http://localhost/test/form/simpleform/ThreePageFormWithValidation'); @@ -41,9 +40,7 @@ public function goingForthAndBackStoresFormValuesOfFirstPage() Assert::assertSame('My Text on the first page', $form['--three-page-form-with-validation']['text1-1']->getValue()); } - /** - * @test - */ + #[Test] public function goingForthAndBackStoresFormValuesOfSecondPage() { $this->browser->request('http://localhost/test/form/simpleform/ThreePageFormWithValidation'); @@ -59,9 +56,7 @@ public function goingForthAndBackStoresFormValuesOfSecondPage() Assert::assertSame('My Text on the second page', $form['--three-page-form-with-validation']['text2-1']->getValue()); } - /** - * @test - */ + #[Test] public function goingForthAndBackStoresFormValuesOfSecondPageAndTriggersValidationOnlyWhenGoingForward() { $this->browser->request('http://localhost/test/form/simpleform/ThreePageFormWithValidation'); @@ -83,10 +78,7 @@ public function goingForthAndBackStoresFormValuesOfSecondPageAndTriggersValidati Assert::assertSame('', $form['--three-page-form-with-validation']['text3-1']->getValue()); } - /** - * @test - * Thanks to Anian Weber for reporting that issue! - */ + #[Test] public function validationIsNotSkippedForGetRequests() { $this->browser->request('http://localhost/test/form/simpleform/ThreePageFormWithValidation'); @@ -109,11 +101,11 @@ public function validationIsNotSkippedForGetRequests() } /** - * @test * @see https://github.com/neos/form/issues/126 * @see https://github.com/neos/form/issues/135 * @see https://github.com/neos/form/issues/143 */ + #[Test] public function formStateCanContainArbitraryObjects() { $this->browser->request('http://localhost/test/form/simpleform/TwoPageFormWithUpload'); @@ -136,9 +128,8 @@ public function formStateCanContainArbitraryObjects() * that we do NOT send any of the parameters with the form; as we only want the form state to be applied. * * So, if the form state contains some values, we want to be sure these values are re-displayed. - * - * @test */ + #[Test] public function goingForthAndBackStoresFormValuesOfSecondPageEvenWhenSecondPageIsManuallyCalledAsGetRequest() { $this->markTestSkipped('This test is skipped because we no longer allow Form validators to be skipped, see https://github.com/neos/form/security/advisories/GHSA-m5vx-8chx-qvmm'); diff --git a/Tests/Unit/Core/Model/AbstractFinisherTest.php b/Tests/Unit/Core/Model/AbstractFinisherTest.php index ab281890..076d6fef 100644 --- a/Tests/Unit/Core/Model/AbstractFinisherTest.php +++ b/Tests/Unit/Core/Model/AbstractFinisherTest.php @@ -10,7 +10,9 @@ * information, please view the LICENSE file which was distributed with this * source code. */ - +use PHPUnit\Framework\Attributes\CoversClass; +use PHPUnit\Framework\Attributes\Test; +use PHPUnit\Framework\Attributes\DataProvider; use Neos\Flow\Tests\UnitTestCase; use Neos\Form\Core\Model\AbstractFinisher; use Neos\Form\Core\Model\FinisherContext; @@ -20,11 +22,11 @@ /** * Test for AbstractFinisher - * @covers \Neos\Form\Core\Model\AbstractFinisher - * @covers \Neos\Form\Core\Model\FinisherContext - * @covers \Neos\Form\Core\Runtime\FormRuntime - * @covers \Neos\Form\Core\Runtime\FormState */ +#[CoversClass(AbstractFinisher::class)] +#[CoversClass(FinisherContext::class)] +#[CoversClass(FormRuntime::class)] +#[CoversClass(FormState::class)] class AbstractFinisherTest extends UnitTestCase { /** @@ -32,9 +34,7 @@ class AbstractFinisherTest extends UnitTestCase */ protected $formRuntime = null; - /** - * @test - */ + #[Test] public function executeSetsFinisherContextAndCallsExecuteInternal() { $finisher = $this->getAbstractFinisher(); @@ -45,9 +45,7 @@ public function executeSetsFinisherContextAndCallsExecuteInternal() Assert::assertSame($finisherContext, $finisher->_get('finisherContext')); } - /** - * @test - */ + #[Test] public function parseOptionReturnsPreviouslySetOption() { $finisher = $this->getAbstractFinisher(); @@ -58,9 +56,7 @@ public function parseOptionReturnsPreviouslySetOption() Assert::assertSame('bar', $finisher->_call('parseOption', 'foo')); } - /** - * @test - */ + #[Test] public function parseOptionReturnsNumbersAndSimpleTypesWithoutModification() { $finisher = $this->getAbstractFinisher(); @@ -117,10 +113,8 @@ public function dataProviderForDefaultOptions() ]; } - /** - * @dataProvider dataProviderForDefaultOptions - * @test - */ + #[DataProvider('dataProviderForDefaultOptions')] + #[Test] public function parseOptionReturnsDefaultOptionIfNecessary($defaultOptions, $options, $optionKey, $expected) { $finisher = $this->getAbstractFinisher(); @@ -153,10 +147,8 @@ public function dataProviderForPlaceholderReplacement() ]; } - /** - * @dataProvider dataProviderForPlaceholderReplacement - * @test - */ + #[DataProvider('dataProviderForPlaceholderReplacement')] + #[Test] public function placeholdersAreReplacedWithFormRuntimeValues($formValues, $optionValue, $expected) { $finisher = $this->getAbstractFinisher(); @@ -173,10 +165,8 @@ public function placeholdersAreReplacedWithFormRuntimeValues($formValues, $optio Assert::assertSame($expected, $finisher->_call('parseOption', 'key1')); } - /** - * @dataProvider dataProviderForPlaceholderReplacement - * @test - */ + #[DataProvider('dataProviderForPlaceholderReplacement')] + #[Test] public function placeholdersInsideDefaultsReplacedWithFormRuntimeValues($formValues, $optionValue, $expected) { $finisher = $this->getAbstractFinisher(); @@ -193,9 +183,7 @@ public function placeholdersInsideDefaultsReplacedWithFormRuntimeValues($formVal Assert::assertSame($expected, $finisher->_call('parseOption', 'key1')); } - /** - * @test - */ + #[Test] public function cancelCanBeSetOnFinisherContext() { $finisherContext = $this->getFinisherContext(); diff --git a/Tests/Unit/Core/Model/AbstractFormElementTest.php b/Tests/Unit/Core/Model/AbstractFormElementTest.php index 32542265..61930ad6 100644 --- a/Tests/Unit/Core/Model/AbstractFormElementTest.php +++ b/Tests/Unit/Core/Model/AbstractFormElementTest.php @@ -10,7 +10,9 @@ * information, please view the LICENSE file which was distributed with this * source code. */ - +use PHPUnit\Framework\Attributes\CoversClass; +use PHPUnit\Framework\Attributes\Test; +use PHPUnit\Framework\Attributes\DataProvider; use Neos\Flow\Tests\UnitTestCase; use Neos\Flow\Validation\Exception\InvalidValidationOptionsException; use Neos\Flow\Validation\Validator\ConjunctionValidator; @@ -28,13 +30,11 @@ /** * Test for AbstractFormElement Domain Model - * @covers \Neos\Form\Core\Model\AbstractFormElement */ +#[CoversClass(AbstractFormElement::class)] class AbstractFormElementTest extends UnitTestCase { - /** - * @test - */ + #[Test] public function constructorSetsIdentifierAndType() { $element = $this->getFormElement(['myIdentifier', 'Neos.Form:MyType']); @@ -51,10 +51,8 @@ public function invalidIdentifiers() ]; } - /** - * @test - * @dataProvider invalidIdentifiers - */ + #[DataProvider('invalidIdentifiers')] + #[Test] public function ifBogusIdentifierSetInConstructorAnExceptionIsThrown($identifier) { $this->expectException(IdentifierNotValidException::class); @@ -62,9 +60,7 @@ public function ifBogusIdentifierSetInConstructorAnExceptionIsThrown($identifier $this->getFormElement([$identifier, 'Neos.Form:MyType']); } - /** - * @test - */ + #[Test] public function labelCanBeSetAndGet() { $formElement = $this->getFormElement(['foo', 'Neos.Form:MyType']); @@ -73,9 +69,7 @@ public function labelCanBeSetAndGet() Assert::assertSame('my label', $formElement->getLabel()); } - /** - * @test - */ + #[Test] public function defaultValueCanBeSetAndGet() { $formDefinition = new FormDefinition('foo'); @@ -88,9 +82,7 @@ public function defaultValueCanBeSetAndGet() Assert::assertSame('My Default Value', $formElement->getDefaultValue()); } - /** - * @test - */ + #[Test] public function renderingOptionsCanBeSetAndGet() { $formElement = $this->getFormElement(['foo', 'Neos.Form:MyType']); @@ -101,9 +93,7 @@ public function renderingOptionsCanBeSetAndGet() Assert::assertSame(['option1' => 'value1', 'option2' => 'value2'], $formElement->getRenderingOptions()); } - /** - * @test - */ + #[Test] public function rendererClassNameCanBeGetAndSet() { $formElement = $this->getFormElement(['foo', 'Neos.Form:MyType']); @@ -112,9 +102,7 @@ public function rendererClassNameCanBeGetAndSet() Assert::assertSame('MyRendererClassName', $formElement->getRendererClassName()); } - /** - * @test - */ + #[Test] public function getUniqueIdentifierBuildsIdentifierFromRootFormAndElementIdentifier() { $formDefinition = new FormDefinition('foo'); @@ -137,14 +125,14 @@ public function getUniqueIdentifierReplacesSpecialCharactersByUnderscoresProvide } /** - * @test - * @dataProvider getUniqueIdentifierReplacesSpecialCharactersByUnderscoresProvider * @param string $formIdentifier * @param string $elementIdentifier * @param string $expectedResult * @throws FormDefinitionConsistencyException * @throws IdentifierNotValidException */ + #[DataProvider('getUniqueIdentifierReplacesSpecialCharactersByUnderscoresProvider')] + #[Test] public function getUniqueIdentifierReplacesSpecialCharactersByUnderscores($formIdentifier, $elementIdentifier, $expectedResult) { $formDefinition = new FormDefinition($formIdentifier); @@ -157,10 +145,10 @@ public function getUniqueIdentifierReplacesSpecialCharactersByUnderscores($formI } /** - * @test * @throws FormDefinitionConsistencyException * @throws IdentifierNotValidException */ + #[Test] public function isRequiredReturnsFalseByDefault() { $formDefinition = $this->getFormDefinitionWithProcessingRule('bar'); @@ -173,9 +161,7 @@ public function isRequiredReturnsFalseByDefault() $this->assertFalse($myFormElement->isRequired()); } - /** - * @test - */ + #[Test] public function isRequiredReturnsTrueIfNotEmptyValidatorIsAdded() { $formDefinition = $this->getFormDefinitionWithProcessingRule('bar'); diff --git a/Tests/Unit/Core/Model/FinisherContextTest.php b/Tests/Unit/Core/Model/FinisherContextTest.php index ffbc50b2..5bb2d5f0 100644 --- a/Tests/Unit/Core/Model/FinisherContextTest.php +++ b/Tests/Unit/Core/Model/FinisherContextTest.php @@ -10,7 +10,8 @@ * information, please view the LICENSE file which was distributed with this * source code. */ - +use PHPUnit\Framework\Attributes\CoversClass; +use PHPUnit\Framework\Attributes\Test; use Neos\Flow\Tests\UnitTestCase; use Neos\Form\Core\Model\FinisherContext; use Neos\Form\Core\Runtime\FormRuntime; @@ -18,8 +19,8 @@ /** * Test for FinisherContext Domain Model - * @covers \Neos\Form\Core\Model\FinisherContext */ +#[CoversClass(FinisherContext::class)] class FinisherContextTest extends UnitTestCase { /** @@ -38,25 +39,19 @@ public function setUp(): void $this->finisherContext = new FinisherContext($this->mockFormRuntime); } - /** - * @test - */ + #[Test] public function getFormRuntimeReturnsTheFormRuntime() { Assert::assertSame($this->mockFormRuntime, $this->finisherContext->getFormRuntime()); } - /** - * @test - */ + #[Test] public function isCancelReturnsFalseByDefault() { Assert::assertFalse($this->finisherContext->isCancelled()); } - /** - * @test - */ + #[Test] public function isCancelReturnsTrueIfContextHasBeenCancelled() { $this->finisherContext->cancel(); diff --git a/Tests/Unit/Core/Model/FormDefinitionTest.php b/Tests/Unit/Core/Model/FormDefinitionTest.php index 6b95b75d..2b77a96a 100644 --- a/Tests/Unit/Core/Model/FormDefinitionTest.php +++ b/Tests/Unit/Core/Model/FormDefinitionTest.php @@ -10,7 +10,9 @@ * information, please view the LICENSE file which was distributed with this * source code. */ - +use PHPUnit\Framework\Attributes\CoversClass; +use PHPUnit\Framework\Attributes\Test; +use PHPUnit\Framework\Attributes\DataProvider; use Neos\Flow\Mvc\ActionRequest; use Neos\Flow\Mvc\ActionResponse; use Neos\Flow\Tests\UnitTestCase; @@ -36,14 +38,12 @@ /** * Test for FormDefinition Domain Model - * @covers \Neos\Form\Core\Model\FormDefinition - * @covers \Neos\Form\Core\Model\Page */ +#[CoversClass(FormDefinition::class)] +#[CoversClass(Page::class)] class FormDefinitionTest extends UnitTestCase { - /** - * @test - */ + #[Test] public function identifierSetInConstructorCanBeReadAgain() { $formDefinition = new FormDefinition('foo'); @@ -63,11 +63,11 @@ public function invalidIdentifiers() } /** - * @test - * @dataProvider invalidIdentifiers * @param $identifier * @throws IdentifierNotValidException */ + #[DataProvider('invalidIdentifiers')] + #[Test] public function ifBogusIdentifierSetInConstructorAnExceptionIsThrown($identifier) { $this->expectException(IdentifierNotValidException::class); @@ -75,9 +75,9 @@ public function ifBogusIdentifierSetInConstructorAnExceptionIsThrown($identifier } /** - * @test * @throws IdentifierNotValidException */ + #[Test] public function constructorSetsRendererClassName() { $formDefinition = new FormDefinition('myForm', [ @@ -91,9 +91,9 @@ public function constructorSetsRendererClassName() } /** - * @test * @throws IdentifierNotValidException */ + #[Test] public function constructorSetsFinishers() { $formDefinition = new FormDefinition('myForm', [ @@ -128,9 +128,9 @@ public function constructorSetsFinishers() } /** - * @test * @throws IdentifierNotValidException */ + #[Test] public function constructorSetsRenderingOptions() { $formDefinition = new FormDefinition('myForm', [ @@ -147,9 +147,9 @@ public function constructorSetsRenderingOptions() } /** - * @test * @throws IdentifierNotValidException */ + #[Test] public function constructorMakesValidatorPresetsAvailable() { $formDefinition = new FormDefinition('myForm', [ @@ -164,9 +164,9 @@ public function constructorMakesValidatorPresetsAvailable() } /** - * @test * @throws IdentifierNotValidException */ + #[Test] public function constructorThrowsExceptionIfUnknownPropertySet() { $this->expectException(TypeDefinitionNotValidException::class); @@ -179,18 +179,14 @@ public function constructorThrowsExceptionIfUnknownPropertySet() ]); } - /** - * @test - */ + #[Test] public function getPagesReturnsEmptyArrayByDefault() { $formDefinition = new FormDefinition('foo'); Assert::assertSame([], $formDefinition->getPages()); } - /** - * @test - */ + #[Test] public function getPageByIndexThrowsExceptionIfSpecifiedIndexDoesNotExist() { $this->expectException(Exception::class); @@ -198,9 +194,7 @@ public function getPageByIndexThrowsExceptionIfSpecifiedIndexDoesNotExist() $formDefinition->getPageByIndex(0); } - /** - * @test - */ + #[Test] public function hasPageWithIndexReturnsTrueIfTheSpecifiedIndexExists() { $formDefinition = new FormDefinition('foo'); @@ -210,10 +204,10 @@ public function hasPageWithIndexReturnsTrueIfTheSpecifiedIndexExists() } /** - * @test * @throws FormDefinitionConsistencyException * @throws IdentifierNotValidException */ + #[Test] public function hasPageWithIndexReturnsFalseIfTheSpecifiedIndexDoesNotExist() { $formDefinition = new FormDefinition('foo'); @@ -223,9 +217,7 @@ public function hasPageWithIndexReturnsFalseIfTheSpecifiedIndexDoesNotExist() Assert::assertFalse($formDefinition->hasPageWithIndex(1)); } - /** - * @test - */ + #[Test] public function addPageAddsPageToPagesArrayAndSetsBackReferenceToForm() { $formDefinition = new FormDefinition('foo'); @@ -237,9 +229,7 @@ public function addPageAddsPageToPagesArrayAndSetsBackReferenceToForm() Assert::assertSame($page, $formDefinition->getPageByIndex(0)); } - /** - * @test - */ + #[Test] public function addPageAddsIndexToPage() { $formDefinition = new FormDefinition('foo'); @@ -254,10 +244,10 @@ public function addPageAddsIndexToPage() } /** - * @test * @throws FormDefinitionConsistencyException * @throws IdentifierNotValidException */ + #[Test] public function getElementByIdentifierReturnsElementsWhichAreAlreadyAttachedToThePage() { $page = new Page('bar'); @@ -270,9 +260,7 @@ public function getElementByIdentifierReturnsElementsWhichAreAlreadyAttachedToTh Assert::assertSame($mockFormElement, $formDefinition->getElementByIdentifier('myFormElementIdentifier')); } - /** - * @test - */ + #[Test] public function getElementByIdentifierReturnsElementsWhichAreLazilyAttachedToThePage() { $formDefinition = new FormDefinition('foo'); @@ -285,9 +273,7 @@ public function getElementByIdentifierReturnsElementsWhichAreLazilyAttachedToThe Assert::assertSame($mockFormElement, $formDefinition->getElementByIdentifier('myFormElementIdentifier')); } - /** - * @test - */ + #[Test] public function bindReturnsBoundFormRuntime() { $formDefinition = new FormDefinition('foo'); @@ -300,9 +286,7 @@ public function bindReturnsBoundFormRuntime() Assert::assertInstanceOf(FormRuntime::class, $form); } - /** - * @test - */ + #[Test] public function attachingTwoElementsWithSameIdentifierToFormThrowsException1() { $this->expectException(DuplicateFormElementException::class); @@ -318,9 +302,7 @@ public function attachingTwoElementsWithSameIdentifierToFormThrowsException1() $formDefinition->addPage($page); } - /** - * @test - */ + #[Test] public function attachingTwoElementsWithSameIdentifierToFormThrowsException2() { $this->expectException(DuplicateFormElementException::class); @@ -337,9 +319,7 @@ public function attachingTwoElementsWithSameIdentifierToFormThrowsException2() $page->addElement($mockFormElement2); } - /** - * @test - */ + #[Test] public function aPageCanOnlyBeAttachedToASingleFormDefinition() { $this->expectException(FormDefinitionConsistencyException::class); @@ -354,11 +334,11 @@ public function aPageCanOnlyBeAttachedToASingleFormDefinition() } /** - * @test * @throws Exception * @throws IdentifierNotValidException * @throws TypeDefinitionNotFoundException */ + #[Test] public function createPageCreatesPageAndAddsItToForm() { $formDefinition = new FormDefinition('myForm', [ @@ -376,11 +356,11 @@ public function createPageCreatesPageAndAddsItToForm() } /** - * @test * @throws Exception * @throws IdentifierNotValidException * @throws TypeDefinitionNotFoundException */ + #[Test] public function createPageSetsLabelFromTypeDefinition() { $formDefinition = new FormDefinition('myForm', [ @@ -397,11 +377,11 @@ public function createPageSetsLabelFromTypeDefinition() } /** - * @test * @throws Exception * @throws IdentifierNotValidException * @throws TypeDefinitionNotFoundException */ + #[Test] public function createPageSetsRendererClassNameFromTypeDefinition() { $formDefinition = new FormDefinition('myForm', [ @@ -418,11 +398,11 @@ public function createPageSetsRendererClassNameFromTypeDefinition() } /** - * @test * @throws Exception * @throws IdentifierNotValidException * @throws TypeDefinitionNotFoundException */ + #[Test] public function createPageSetsRenderingOptionsFromTypeDefinition() { $formDefinition = new FormDefinition('myForm', [ @@ -439,11 +419,11 @@ public function createPageSetsRenderingOptionsFromTypeDefinition() } /** - * @test * @throws Exception * @throws IdentifierNotValidException * @throws TypeDefinitionNotFoundException */ + #[Test] public function createPageThrowsExceptionIfUnknownPropertyFoundInTypeDefinition() { $this->expectException(TypeDefinitionNotValidException::class); @@ -462,11 +442,11 @@ public function createPageThrowsExceptionIfUnknownPropertyFoundInTypeDefinition( } /** - * @test * @throws Exception * @throws IdentifierNotValidException * @throws TypeDefinitionNotFoundException */ + #[Test] public function createPageThrowsExceptionIfImplementationClassNameNotFound() { $this->expectException(TypeDefinitionNotFoundException::class); @@ -482,18 +462,14 @@ public function createPageThrowsExceptionIfImplementationClassNameNotFound() $formDefinition->createPage('myPage', 'Neos.Form:Page2'); } - /** - * @test - */ + #[Test] public function formFieldTypeManagerIsReturned() { $formDefinition = new FormDefinition('myForm'); Assert::assertInstanceOf(SupertypeResolver::class, $formDefinition->getFormFieldTypeManager()); } - /** - * @test - */ + #[Test] public function movePageBeforeMovesPageBeforeReferenceElement() { $formDefinition = new FormDefinition('foo1'); @@ -517,9 +493,7 @@ public function movePageBeforeMovesPageBeforeReferenceElement() Assert::assertSame([$page2, $page1, $page3], $formDefinition->getPages()); } - /** - * @test - */ + #[Test] public function movePageBeforeThrowsExceptionIfPagesDoNotBelongToSameForm() { $this->expectException(FormDefinitionConsistencyException::class); @@ -532,9 +506,7 @@ public function movePageBeforeThrowsExceptionIfPagesDoNotBelongToSameForm() $formDefinition->movePageBefore($page2, $page1); } - /** - * @test - */ + #[Test] public function movePageAfterMovesPageAfterReferenceElement() { $formDefinition = new FormDefinition('foo1'); @@ -558,9 +530,7 @@ public function movePageAfterMovesPageAfterReferenceElement() Assert::assertSame([$page2, $page1, $page3], $formDefinition->getPages()); } - /** - * @test - */ + #[Test] public function movePageAfterThrowsExceptionIfPagesDoNotBelongToSameForm() { $this->expectException(FormDefinitionConsistencyException::class); @@ -574,10 +544,10 @@ public function movePageAfterThrowsExceptionIfPagesDoNotBelongToSameForm() } /** - * @test * @throws FormDefinitionConsistencyException * @throws IdentifierNotValidException */ + #[Test] public function removePageRemovesPageFromForm() { $formDefinition = new FormDefinition('foo1'); @@ -596,10 +566,10 @@ public function removePageRemovesPageFromForm() } /** - * @test * @throws FormDefinitionConsistencyException * @throws IdentifierNotValidException */ + #[Test] public function removePageRemovesFormElementsOnPageFromForm() { $formDefinition = new FormDefinition('foo1'); @@ -619,9 +589,7 @@ public function removePageRemovesFormElementsOnPageFromForm() $this->assertNull($formDefinition->getElementByIdentifier('el2')); } - /** - * @test - */ + #[Test] public function removePageThrowsExceptionIfPageIsNotOnForm() { $this->expectException(FormDefinitionConsistencyException::class); @@ -631,9 +599,7 @@ public function removePageThrowsExceptionIfPageIsNotOnForm() $formDefinition->removePage($page1); } - /** - * @test - */ + #[Test] public function getProcessingRuleCreatesProcessingRuleIfItDoesNotExistYet() { $formDefinition = new FormDefinition('foo1'); @@ -646,9 +612,7 @@ public function getProcessingRuleCreatesProcessingRuleIfItDoesNotExistYet() Assert::assertSame(['foo' => $processingRule1], $formDefinition->getProcessingRules()); } - /** - * @test - */ + #[Test] public function addFinisherAddsFinishersToList() { $formDefinition = new FormDefinition('foo1'); @@ -658,9 +622,7 @@ public function addFinisherAddsFinishersToList() Assert::assertSame([$finisher], $formDefinition->getFinishers()); } - /** - * @test - */ + #[Test] public function createFinisherThrowsExceptionIfFinisherPresetNotFound() { $this->expectException(FinisherPresetNotFoundException::class); @@ -669,9 +631,7 @@ public function createFinisherThrowsExceptionIfFinisherPresetNotFound() $formDefinition->createFinisher('asdf'); } - /** - * @test - */ + #[Test] public function createFinisherThrowsExceptionIfImplementationClassNameIsEmpty() { $this->expectException(FinisherPresetNotFoundException::class); @@ -680,9 +640,7 @@ public function createFinisherThrowsExceptionIfImplementationClassNameIsEmpty() $formDefinition->createFinisher('asdf'); } - /** - * @test - */ + #[Test] public function createFinisherCreatesFinisherCorrectly() { $formDefinition = $this->getFormDefinitionWithFinisherConfiguration(); @@ -691,9 +649,7 @@ public function createFinisherCreatesFinisherCorrectly() Assert::assertSame([$finisher], $formDefinition->getFinishers()); } - /** - * @test - */ + #[Test] public function createFinisherSetsOptionsCorrectly() { $formDefinition = $this->getFormDefinitionWithFinisherConfiguration(); @@ -702,9 +658,7 @@ public function createFinisherSetsOptionsCorrectly() Assert::assertSame(['foo' => 'bar', 'name' => 'asdf'], $finisher->_get('options')); } - /** - * @test - */ + #[Test] public function createFinisherSetsOptionsCorrectlyAndMergesThemWithPassedOptions() { $formDefinition = $this->getFormDefinitionWithFinisherConfiguration(); diff --git a/Tests/Unit/Core/Model/PageTest.php b/Tests/Unit/Core/Model/PageTest.php index b248c945..3408724f 100644 --- a/Tests/Unit/Core/Model/PageTest.php +++ b/Tests/Unit/Core/Model/PageTest.php @@ -10,7 +10,9 @@ * information, please view the LICENSE file which was distributed with this * source code. */ - +use PHPUnit\Framework\Attributes\CoversClass; +use PHPUnit\Framework\Attributes\Test; +use PHPUnit\Framework\Attributes\DataProvider; use Neos\Flow\Tests\UnitTestCase; use Neos\Flow\Validation\Validator\ConjunctionValidator; use Neos\Flow\Validation\Validator\NotEmptyValidator; @@ -33,14 +35,12 @@ /** * Test for Page Domain Model - * @covers \Neos\Form\Core\Model\Page - * @covers \Neos\Form\Core\Model\AbstractFormElement */ +#[CoversClass(Page::class)] +#[CoversClass(AbstractFormElement::class)] class PageTest extends UnitTestCase { - /** - * @test - */ + #[Test] public function identifierSetInConstructorCanBeReadAgain() { $page = new Page('foo'); @@ -50,18 +50,14 @@ public function identifierSetInConstructorCanBeReadAgain() Assert::assertSame('bar', $page->getIdentifier()); } - /** - * @test - */ + #[Test] public function defaultTypeIsCorrect() { $page = new Page('foo'); Assert::assertSame('Neos.Form:Page', $page->getType()); } - /** - * @test - */ + #[Test] public function typeCanBeOverridden() { $page = new Page('foo', 'Neos.Foo:Bar'); @@ -78,38 +74,32 @@ public function invalidIdentifiers() } /** - * @test - * @dataProvider invalidIdentifiers * @param mixed $identifier * @throws IdentifierNotValidException */ + #[DataProvider('invalidIdentifiers')] + #[Test] public function ifBogusIdentifierSetInConstructorAnExceptionIsThrown($identifier) { $this->expectException(IdentifierNotValidException::class); new Page($identifier); } - /** - * @test - */ + #[Test] public function getElementsReturnsEmptyArrayByDefault() { $page = new Page('foo'); Assert::assertSame([], $page->getElements()); } - /** - * @test - */ + #[Test] public function getElementsRecursivelyReturnsEmptyArrayByDefault() { $page = new Page('foo'); Assert::assertSame([], $page->getElementsRecursively()); } - /** - * @test - */ + #[Test] public function getElementsRecursivelyReturnsFirstLevelFormElements() { $page = new Page('foo'); @@ -122,9 +112,7 @@ public function getElementsRecursivelyReturnsFirstLevelFormElements() Assert::assertSame([$element1, $element2], $page->getElementsRecursively()); } - /** - * @test - */ + #[Test] public function getElementsRecursivelyReturnsRecursiveFormElementsInCorrectOrder() { $page = new Page('foo'); @@ -148,9 +136,7 @@ public function getElementsRecursivelyReturnsRecursiveFormElementsInCorrectOrder Assert::assertSame([$element1, $element2, $element21, $element22, $element3], $page->getElementsRecursively()); } - /** - * @test - */ + #[Test] public function aFormElementCanOnlyBeAttachedToASinglePage() { $this->expectException(FormDefinitionConsistencyException::class); @@ -165,9 +151,7 @@ public function aFormElementCanOnlyBeAttachedToASinglePage() $page2->addElement($element); } - /** - * @test - */ + #[Test] public function addElementAddsElementAndSetsBackReferenceToPage() { $page = new Page('bar'); @@ -178,9 +162,7 @@ public function addElementAddsElementAndSetsBackReferenceToPage() Assert::assertSame($page, $element->getParentRenderable()); } - /** - * @test - */ + #[Test] public function createElementCreatesElementAndAddsItToForm() { $formDefinition = $this->getDummyFormDefinition(); @@ -193,9 +175,7 @@ public function createElementCreatesElementAndAddsItToForm() Assert::assertSame([$element], $page->getElements()); } - /** - * @test - */ + #[Test] public function createElementSetsAdditionalPropertiesInElement() { $formDefinition = $this->getDummyFormDefinition(); @@ -209,9 +189,7 @@ public function createElementSetsAdditionalPropertiesInElement() Assert::assertSame('MyRendererClassName', $element->getRendererClassName()); } - /** - * @test - */ + #[Test] public function createElementThrowsExceptionIfPageIsNotAttachedToParentForm() { $this->expectException(FormDefinitionConsistencyException::class); @@ -219,9 +197,7 @@ public function createElementThrowsExceptionIfPageIsNotAttachedToParentForm() $page->createElement('myElement', 'Neos.Form:MyElementType'); } - /** - * @test - */ + #[Test] public function createElementThrowsExceptionIfImplementationClassNameNotFound() { $this->expectException(TypeDefinitionNotFoundException::class); @@ -231,9 +207,7 @@ public function createElementThrowsExceptionIfImplementationClassNameNotFound() $page->createElement('myElement', 'Neos.Form:MyElementTypeWithoutImplementationClassName'); } - /** - * @test - */ + #[Test] public function createElementThrowsExceptionIfImplementationClassNameDoesNotImplementFormElementInterface() { $this->expectException(TypeDefinitionNotValidException::class); @@ -243,9 +217,7 @@ public function createElementThrowsExceptionIfImplementationClassNameDoesNotImpl $page->createElement('myElement', 'Neos.Form:MyElementTypeWhichDoesNotImplementFormElementInterface'); } - /** - * @test - */ + #[Test] public function createElementThrowsExceptionIfUnknownPropertyFoundInTypeDefinition() { $this->expectException(TypeDefinitionNotValidException::class); @@ -255,9 +227,7 @@ public function createElementThrowsExceptionIfUnknownPropertyFoundInTypeDefiniti $page->createElement('myElement', 'Neos.Form:MyElementTypeWithUnknownProperties'); } - /** - * @test - */ + #[Test] public function moveElementBeforeMovesElementBeforeReferenceElement() { $formDefinition = $this->getDummyFormDefinition(); @@ -270,9 +240,7 @@ public function moveElementBeforeMovesElementBeforeReferenceElement() Assert::assertSame([$element2, $element1], $page->getElements()); } - /** - * @test - */ + #[Test] public function moveElementBeforeThrowsExceptionIfElementsAreNotOnSamePage() { $this->expectException(FormDefinitionConsistencyException::class); @@ -287,9 +255,7 @@ public function moveElementBeforeThrowsExceptionIfElementsAreNotOnSamePage() $page1->moveElementBefore($element1, $element2); } - /** - * @test - */ + #[Test] public function moveElementAfterMovesElementAfterReferenceElement() { $formDefinition = $this->getDummyFormDefinition(); @@ -302,9 +268,7 @@ public function moveElementAfterMovesElementAfterReferenceElement() Assert::assertSame([$element2, $element1], $page->getElements()); } - /** - * @test - */ + #[Test] public function moveElementAfterThrowsExceptionIfElementsAreNotOnSamePage() { $this->expectException(FormDefinitionConsistencyException::class); @@ -319,9 +283,7 @@ public function moveElementAfterThrowsExceptionIfElementsAreNotOnSamePage() $page1->moveElementAfter($element1, $element2); } - /** - * @test - */ + #[Test] public function removeElementRemovesElementFromCurrentPageAndUnregistersItFromForm() { $formDefinition = $this->getDummyFormDefinition(); @@ -337,9 +299,7 @@ public function removeElementRemovesElementFromCurrentPageAndUnregistersItFromFo $this->assertNull($element1->getParentRenderable()); } - /** - * @test - */ + #[Test] public function removeElementThrowsExceptionIfElementIsNotOnCurrentPage() { $this->expectException(FormDefinitionConsistencyException::class); @@ -351,9 +311,7 @@ public function removeElementThrowsExceptionIfElementIsNotOnCurrentPage() $page1->removeElement($element1); } - /** - * @test - */ + #[Test] public function validatorKeyCorrectlyAddsValidator() { $formDefinition = $this->getDummyFormDefinition(); @@ -378,9 +336,7 @@ public function validatorKeyCorrectlyAddsValidator() Assert::assertSame($validatorOptions['maximum'], PHP_INT_MAX); } - /** - * @test - */ + #[Test] public function validatorKeyThrowsExceptionIfValidatorPresetIsNotFound() { $this->expectException(ValidatorPresetNotFoundException::class); diff --git a/Tests/Unit/Core/Model/ProcessingRuleTest.php b/Tests/Unit/Core/Model/ProcessingRuleTest.php index 4f5fd6e0..e82b8c80 100644 --- a/Tests/Unit/Core/Model/ProcessingRuleTest.php +++ b/Tests/Unit/Core/Model/ProcessingRuleTest.php @@ -10,7 +10,8 @@ * information, please view the LICENSE file which was distributed with this * source code. */ - +use PHPUnit\Framework\Attributes\CoversClass; +use PHPUnit\Framework\Attributes\Test; use Neos\Error\Messages\Error; use Neos\Error\Messages\Result; use Neos\Flow\Property\PropertyMapper; @@ -23,8 +24,8 @@ /** * Test for ProcessingRule Domain Model - * @covers \Neos\Form\Core\Model\ProcessingRule */ +#[CoversClass(ProcessingRule::class)] class ProcessingRuleTest extends UnitTestCase { /** @@ -46,35 +47,29 @@ public function setUp(): void $this->inject($this->processingRule, 'propertyMapper', $this->mockPropertyMapper); } - /** - * @test - */ + #[Test] public function getDataTypeReturnsNullByDefault() { $this->assertNull($this->processingRule->getDataType()); } - /** - * @test - */ + #[Test] public function getDataTypeReturnsSpecifiedDataType() { $this->processingRule->setDataType('SomeDataType'); Assert::assertSame('SomeDataType', $this->processingRule->getDataType()); } - /** - * @test - */ + #[Test] public function getValidatorsReturnsAnEmptyCollectionByDefault() { Assert::assertSame(0, count($this->processingRule->getValidators())); } /** - * @test * @throws \ReflectionException */ + #[Test] public function getValidatorsReturnsPreviouslyAddedValidators() { /** @var ValidatorInterface $mockValidator1 */ @@ -89,18 +84,14 @@ public function getValidatorsReturnsPreviouslyAddedValidators() Assert::assertTrue($validators->contains($mockValidator2)); } - /** - * @test - */ + #[Test] public function processReturnsTheUnchangedValueByDefault() { $actualResult = $this->processingRule->process('Some Value'); Assert::assertEquals('Some Value', $actualResult); } - /** - * @test - */ + #[Test] public function processingMessagesCanBeModifiedBeforeProcessing() { $this->processingRule->getProcessingMessages()->addError(new Error('Test')); @@ -108,18 +99,14 @@ public function processingMessagesCanBeModifiedBeforeProcessing() Assert::assertTrue($this->processingRule->getProcessingMessages()->hasErrors()); } - /** - * @test - */ + #[Test] public function processDoesNotConvertValueIfTargetTypeIsNotSpecified() { $this->mockPropertyMapper->expects($this->never())->method('convert'); $this->processingRule->process('Some Value'); } - /** - * @test - */ + #[Test] public function processConvertsValueIfDataTypeIsSpecified() { $this->processingRule->setDataType('SomeDataType'); diff --git a/Tests/Unit/Core/Renderer/FormRuntimeTest.php b/Tests/Unit/Core/Renderer/FormRuntimeTest.php index 52130061..9f1e3eb0 100644 --- a/Tests/Unit/Core/Renderer/FormRuntimeTest.php +++ b/Tests/Unit/Core/Renderer/FormRuntimeTest.php @@ -10,7 +10,8 @@ * information, please view the LICENSE file which was distributed with this * source code. */ - +use PHPUnit\Framework\Attributes\CoversClass; +use PHPUnit\Framework\Attributes\Test; use Neos\Flow\Mvc\ActionRequest; use Neos\Flow\Mvc\ActionResponse; use Neos\Flow\Tests\UnitTestCase; @@ -25,14 +26,11 @@ /** * Test for Form Runtime - * - * @covers \Neos\Form\Core\Runtime\FormRuntime */ +#[CoversClass(FormRuntime::class)] class FormRuntimeTest extends UnitTestCase { - /** - * @test - */ + #[Test] public function valuesSetInConstructorCanBeReadAgain() { $formDefinition = new FormDefinition('foo'); @@ -52,9 +50,7 @@ public function valuesSetInConstructorCanBeReadAgain() Assert::assertSame($formDefinition, $formRuntime->_get('formDefinition')); } - /** - * @test - */ + #[Test] public function getTypeReturnsTypeOfFormDefinition() { $formDefinition = new FormDefinition('foo'); @@ -62,9 +58,7 @@ public function getTypeReturnsTypeOfFormDefinition() Assert::assertSame('Neos.Form:Form', $formRuntime->getType()); } - /** - * @test - */ + #[Test] public function getIdentifierReturnsIdentifierOfFormDefinition() { $formDefinition = new FormDefinition('foo'); @@ -72,9 +66,7 @@ public function getIdentifierReturnsIdentifierOfFormDefinition() Assert::assertSame('foo', $formRuntime->getIdentifier()); } - /** - * @test - */ + #[Test] public function getRenderingOptionsReturnsRenderingOptionsOfFormDefinition() { $formDefinition = new FormDefinition('foo'); @@ -83,9 +75,7 @@ public function getRenderingOptionsReturnsRenderingOptionsOfFormDefinition() Assert::assertSame(['asdf' => 'test'], $formRuntime->getRenderingOptions()); } - /** - * @test - */ + #[Test] public function getRendererClassNameReturnsRendererClassNameOfFormDefinition() { $formDefinition = new FormDefinition('foo'); @@ -94,9 +84,7 @@ public function getRendererClassNameReturnsRendererClassNameOfFormDefinition() Assert::assertSame('MyRendererClassName', $formRuntime->getRendererClassName()); } - /** - * @test - */ + #[Test] public function getLabelReturnsLabelOfFormDefinition() { $formDefinition = new FormDefinition('foo'); @@ -105,9 +93,7 @@ public function getLabelReturnsLabelOfFormDefinition() Assert::assertSame('my cool label', $formRuntime->getLabel()); } - /** - * @test - */ + #[Test] public function invokeFinishersInvokesFinishersInCorrectOrder() { $formDefinition = new FormDefinition('foo'); @@ -147,9 +133,7 @@ protected function getMockFinisher(\Closure $closureToExecute) return $finisher; } - /** - * @test - */ + #[Test] public function pageNavigationWorks() { $formDefinition = new FormDefinition('foo'); @@ -179,9 +163,7 @@ public function pageNavigationWorks() Assert::assertSame(null, $formRuntime->getNextPage()); } - /** - * @test - */ + #[Test] public function arrayAccessReturnsDefaultValuesIfSet() { $formDefinition = new FormDefinition('foo'); diff --git a/Tests/Unit/Factory/AbstractFormFactoryTest.php b/Tests/Unit/Factory/AbstractFormFactoryTest.php index 02937315..7940dbf6 100644 --- a/Tests/Unit/Factory/AbstractFormFactoryTest.php +++ b/Tests/Unit/Factory/AbstractFormFactoryTest.php @@ -10,7 +10,9 @@ * information, please view the LICENSE file which was distributed with this * source code. */ - +use PHPUnit\Framework\Attributes\CoversClass; +use PHPUnit\Framework\Attributes\DataProvider; +use PHPUnit\Framework\Attributes\Test; use Neos\Flow\Configuration\ConfigurationManager; use Neos\Flow\Tests\UnitTestCase; use Neos\Form\Exception\PresetNotFoundException; @@ -19,8 +21,8 @@ /** * Test for Supertype Resolver - * @covers \Neos\Form\Factory\AbstractFormFactory */ +#[CoversClass(AbstractFormFactory::class)] class AbstractFormFactoryTest extends UnitTestCase { public function dataProviderForConfigurationMerging() @@ -86,10 +88,8 @@ public function dataProviderForConfigurationMerging() ]; } - /** - * @dataProvider dataProviderForConfigurationMerging - * @test - */ + #[DataProvider('dataProviderForConfigurationMerging')] + #[Test] public function getPresetConfigurationReturnsCorrectConfigurationForPresets($presets, $presetName, $expected) { $abstractFormFactory = $this->getAbstractFormFactory(); @@ -101,9 +101,7 @@ public function getPresetConfigurationReturnsCorrectConfigurationForPresets($pre Assert::assertSame($expected, $actual); } - /** - * @test - */ + #[Test] public function getPresetConfigurationThrowsExceptionIfPresetIsNotFound() { $this->expectException(PresetNotFoundException::class); @@ -111,9 +109,7 @@ public function getPresetConfigurationThrowsExceptionIfPresetIsNotFound() $abstractFormFactory->_call('getPresetConfiguration', 'NonExistingPreset'); } - /** - * @test - */ + #[Test] public function initializeObjectLoadsSettings() { $abstractFormFactory = $this->getAbstractFormFactory(); @@ -137,11 +133,9 @@ protected function getAbstractFormFactory() return $this->getAccessibleMock(AbstractFormFactory::class, ['build']); } - /** - * @dataProvider dataProviderForConfigurationMerging - * @test - */ - public function getPresetsWorks($presets) + #[DataProvider('dataProviderForConfigurationMerging')] + #[Test] + public function getPresetsWorks($presets, $presetName, $expected) { $abstractFormFactory = $this->getAbstractFormFactory(); $abstractFormFactory->_set('formSettings', [ diff --git a/Tests/Unit/Factory/ArrayFormFactoryTest.php b/Tests/Unit/Factory/ArrayFormFactoryTest.php index bc17cc2e..e56329a3 100644 --- a/Tests/Unit/Factory/ArrayFormFactoryTest.php +++ b/Tests/Unit/Factory/ArrayFormFactoryTest.php @@ -10,7 +10,8 @@ * information, please view the LICENSE file which was distributed with this * source code. */ - +use PHPUnit\Framework\Attributes\CoversClass; +use PHPUnit\Framework\Attributes\Test; use Neos\Flow\Tests\UnitTestCase; use Neos\Form\Core\Model\Page; use Neos\Form\Exception\IdentifierNotValidException; @@ -18,14 +19,10 @@ use Neos\Form\FormElements\GenericFormElement; use PHPUnit\Framework\Assert; -/** - * @covers \Neos\Form\Factory\ArrayFormFactory - */ +#[CoversClass(ArrayFormFactory::class)] class ArrayFormFactoryTest extends UnitTestCase { - /** - * @test - */ + #[Test] public function simpleFormObjectIsReturned() { $factory = $this->getArrayFormFactory(); @@ -37,9 +34,7 @@ public function simpleFormObjectIsReturned() Assert::assertSame('myFormIdentifier', $form->getIdentifier()); } - /** - * @test - */ + #[Test] public function formObjectWithSubRenderablesIsReturned() { $factory = $this->getArrayFormFactory(); @@ -75,9 +70,7 @@ public function formObjectWithSubRenderablesIsReturned() Assert::assertSame(['options' => ['MyKey' => 'MyValue']], $element1->getProperties()); } - /** - * @test - */ + #[Test] public function renderableWithoutIdentifierThrowsException() { $this->expectException(IdentifierNotValidException::class); diff --git a/Tests/Unit/Persistence/YamlPersistenceManagerTest.php b/Tests/Unit/Persistence/YamlPersistenceManagerTest.php index e2fa7f8f..a128034a 100644 --- a/Tests/Unit/Persistence/YamlPersistenceManagerTest.php +++ b/Tests/Unit/Persistence/YamlPersistenceManagerTest.php @@ -10,7 +10,8 @@ * information, please view the LICENSE file which was distributed with this * source code. */ - +use PHPUnit\Framework\Attributes\CoversClass; +use PHPUnit\Framework\Attributes\Test; use Neos\Flow\Tests\UnitTestCase; use Neos\Form\Exception\PersistenceManagerException; use Neos\Form\Persistence\YamlPersistenceManager; @@ -18,9 +19,7 @@ use org\bovigo\vfs\vfsStreamWrapper; use PHPUnit\Framework\Assert; -/** - * @covers \Neos\Form\Persistence\YamlPersistenceManager - */ +#[CoversClass(YamlPersistenceManager::class)] class YamlPersistenceManagerTest extends UnitTestCase { /** @@ -41,9 +40,7 @@ public function setUp(): void ); } - /** - * @test - */ + #[Test] public function injectSettingsCreatesSaveDirectoryIfItDoesntExist() { Assert::assertFalse(vfsStreamWrapper::getRoot()->hasChild('foo/bar')); @@ -58,9 +55,7 @@ public function injectSettingsCreatesSaveDirectoryIfItDoesntExist() } - /** - * @test - */ + #[Test] public function loadThrowsExceptionIfSavePathIsNotSet() { $this->expectException(PersistenceManagerException::class); @@ -68,9 +63,7 @@ public function loadThrowsExceptionIfSavePathIsNotSet() $yamlPersistenceManager->load('dummy'); } - /** - * @test - */ + #[Test] public function loadThrowsExceptionIfSpecifiedFormDoesNotExist() { $this->expectException(PersistenceManagerException::class); @@ -85,9 +78,7 @@ public function loadThrowsExceptionIfSpecifiedFormDoesNotExist() $yamlPersistenceManager->load('someNonExistingPersistenceIdentifier'); } - /** - * @test - */ + #[Test] public function loadReturnsFormDefinitionAsArray() { $mockYamlFormDefinition = 'type: \'Neos.Form:Form\' @@ -105,9 +96,7 @@ public function loadReturnsFormDefinitionAsArray() Assert::assertEquals($expectedResult, $actualResult); } - /** - * @test - */ + #[Test] public function saveStoresFormDefinitionAsYaml() { $mockArrayFormDefinition = [ @@ -126,17 +115,13 @@ public function saveStoresFormDefinitionAsYaml() Assert::assertEquals($expectedResult, $actualResult); } - /** - * @test - */ + #[Test] public function existsReturnsFalseIfTheSpecifiedFormDoesNotExist() { $this->assertFalse($this->yamlPersistenceManager->exists('someNonExistingPersistenceIdentifier')); } - /** - * @test - */ + #[Test] public function existsReturnsTrueIfTheSpecifiedFormExists() { $mockYamlFormDefinition = 'type: \'Neos.Form:Form\' @@ -147,9 +132,7 @@ public function existsReturnsTrueIfTheSpecifiedFormExists() Assert::assertTrue($this->yamlPersistenceManager->exists('mockFormPersistenceIdentifier')); } - /** - * @test - */ + #[Test] public function listFormsThrowsExceptionIfSavePathIsNotSet() { $this->expectException(PersistenceManagerException::class); @@ -158,17 +141,13 @@ public function listFormsThrowsExceptionIfSavePathIsNotSet() } - /** - * @test - */ + #[Test] public function listFormsReturnsAnEmptyArrayIfNoFormsAreAvailable() { Assert::assertEquals([], $this->yamlPersistenceManager->listForms()); } - /** - * @test - */ + #[Test] public function listFormsReturnsAvailableForms() { $mockYamlFormDefinition1 = 'type: \'Neos.Form:Form\' diff --git a/Tests/Unit/Utility/SupertypeResolverTest.php b/Tests/Unit/Utility/SupertypeResolverTest.php index 342e797c..bc89525c 100644 --- a/Tests/Unit/Utility/SupertypeResolverTest.php +++ b/Tests/Unit/Utility/SupertypeResolverTest.php @@ -10,7 +10,9 @@ * information, please view the LICENSE file which was distributed with this * source code. */ - +use PHPUnit\Framework\Attributes\CoversClass; +use PHPUnit\Framework\Attributes\DataProvider; +use PHPUnit\Framework\Attributes\Test; use Neos\Flow\Tests\UnitTestCase; use Neos\Form\Exception\TypeDefinitionNotFoundException; use Neos\Form\Utility\SupertypeResolver; @@ -18,8 +20,8 @@ /** * Test for Supertype Resolver - * @covers \Neos\Form\Utility\SupertypeResolver */ +#[CoversClass(SupertypeResolver::class)] class SupertypeResolverTest extends UnitTestCase { public function dataProviderForTypeResolving() @@ -124,19 +126,15 @@ public function dataProviderForTypeResolving() ]; } - /** - * @dataProvider dataProviderForTypeResolving - * @test - */ + #[DataProvider('dataProviderForTypeResolving')] + #[Test] public function getMergedTypeDefinitionWorks($types, $typeName, $expected) { $supertypeResolver = new SupertypeResolver($types); Assert::assertSame($expected, $supertypeResolver->getMergedTypeDefinition($typeName)); } - /** - * @test - */ + #[Test] public function getMergedTypeDefinitionThrowsExceptionIfTypeNotFound() { $this->expectException(TypeDefinitionNotFoundException::class); diff --git a/Tests/Unit/ViewHelpers/FormViewHelperTest.php b/Tests/Unit/ViewHelpers/FormViewHelperTest.php index c3e7dad2..f8e1f5f0 100644 --- a/Tests/Unit/ViewHelpers/FormViewHelperTest.php +++ b/Tests/Unit/ViewHelpers/FormViewHelperTest.php @@ -10,7 +10,8 @@ * information, please view the LICENSE file which was distributed with this * source code. */ - +use PHPUnit\Framework\Attributes\DataProvider; +use PHPUnit\Framework\Attributes\Test; use GuzzleHttp\Psr7\Uri; use Neos\Flow\Mvc\ActionRequest; use Neos\Flow\Mvc\Controller\ControllerContext; @@ -66,13 +67,13 @@ public function getFormActionUriDataProvider() } /** - * @test * @param string $requestUri * @param string $sectionArgument * @param string $expectedResult - * @dataProvider getFormActionUriDataProvider * @throws \ReflectionException */ + #[DataProvider('getFormActionUriDataProvider')] + #[Test] public function getFormActionUriTests($requestUri, $sectionArgument, $expectedResult) { $mockActionRequest = $this->getMockBuilder(ActionRequest::class)->disableOriginalConstructor()->getMock(); From d8bf992bc70a35750a7e35f84ea96e12cef5ccf5 Mon Sep 17 00:00:00 2001 From: Karsten Dambekalns Date: Tue, 11 Aug 2026 19:37:10 +0200 Subject: [PATCH 2/5] TASK: Make PhpUnit data providers static PhpUnit 10 deprecated and PhpUnit 11 no longer supports non-static data providers, they are called without instantiating the test case. --- Tests/Unit/Core/Model/AbstractFinisherTest.php | 4 ++-- .../Core/Model/AbstractFormElementTest.php | 4 ++-- Tests/Unit/Core/Model/FormDefinitionTest.php | 2 +- Tests/Unit/Core/Model/PageTest.php | 2 +- Tests/Unit/Factory/AbstractFormFactoryTest.php | 4 ++-- Tests/Unit/Utility/SupertypeResolverTest.php | 2 +- Tests/Unit/ViewHelpers/FormViewHelperTest.php | 18 +++++++++--------- 7 files changed, 18 insertions(+), 18 deletions(-) diff --git a/Tests/Unit/Core/Model/AbstractFinisherTest.php b/Tests/Unit/Core/Model/AbstractFinisherTest.php index 076d6fef..0806358f 100644 --- a/Tests/Unit/Core/Model/AbstractFinisherTest.php +++ b/Tests/Unit/Core/Model/AbstractFinisherTest.php @@ -69,7 +69,7 @@ public function parseOptionReturnsNumbersAndSimpleTypesWithoutModification() Assert::assertSame($obj, $finisher->_call('parseOption', 'baz')); } - public function dataProviderForDefaultOptions() + public static function dataProviderForDefaultOptions() { $defaultOptions = [ 'overridden1' => 'Overridden1Default', @@ -126,7 +126,7 @@ public function parseOptionReturnsDefaultOptionIfNecessary($defaultOptions, $opt Assert::assertSame($expected, $finisher->_call('parseOption', $optionKey)); } - public function dataProviderForPlaceholderReplacement() + public static function dataProviderForPlaceholderReplacement() { $formValues = [ 'foo' => 'My Value', diff --git a/Tests/Unit/Core/Model/AbstractFormElementTest.php b/Tests/Unit/Core/Model/AbstractFormElementTest.php index 61930ad6..192bf536 100644 --- a/Tests/Unit/Core/Model/AbstractFormElementTest.php +++ b/Tests/Unit/Core/Model/AbstractFormElementTest.php @@ -42,7 +42,7 @@ public function constructorSetsIdentifierAndType() Assert::assertSame('Neos.Form:MyType', $element->getType()); } - public function invalidIdentifiers() + public static function invalidIdentifiers() { return [ 'Null Identifier' => [null], @@ -114,7 +114,7 @@ public function getUniqueIdentifierBuildsIdentifierFromRootFormAndElementIdentif Assert::assertSame('foo-bar', $myFormElement->getUniqueIdentifier()); } - public function getUniqueIdentifierReplacesSpecialCharactersByUnderscoresProvider() + public static function getUniqueIdentifierReplacesSpecialCharactersByUnderscoresProvider() { return [ ['foo', 'bar', 'foo-bar'], diff --git a/Tests/Unit/Core/Model/FormDefinitionTest.php b/Tests/Unit/Core/Model/FormDefinitionTest.php index 2b77a96a..a6a04ce6 100644 --- a/Tests/Unit/Core/Model/FormDefinitionTest.php +++ b/Tests/Unit/Core/Model/FormDefinitionTest.php @@ -53,7 +53,7 @@ public function identifierSetInConstructorCanBeReadAgain() Assert::assertSame('bar', $formDefinition->getIdentifier()); } - public function invalidIdentifiers() + public static function invalidIdentifiers() { return [ 'Null Identifier' => [null], diff --git a/Tests/Unit/Core/Model/PageTest.php b/Tests/Unit/Core/Model/PageTest.php index 3408724f..1e058dbf 100644 --- a/Tests/Unit/Core/Model/PageTest.php +++ b/Tests/Unit/Core/Model/PageTest.php @@ -64,7 +64,7 @@ public function typeCanBeOverridden() Assert::assertSame('Neos.Foo:Bar', $page->getType()); } - public function invalidIdentifiers() + public static function invalidIdentifiers() { return [ 'Null Identifier' => [null], diff --git a/Tests/Unit/Factory/AbstractFormFactoryTest.php b/Tests/Unit/Factory/AbstractFormFactoryTest.php index 7940dbf6..64b547c0 100644 --- a/Tests/Unit/Factory/AbstractFormFactoryTest.php +++ b/Tests/Unit/Factory/AbstractFormFactoryTest.php @@ -25,7 +25,7 @@ #[CoversClass(AbstractFormFactory::class)] class AbstractFormFactoryTest extends UnitTestCase { - public function dataProviderForConfigurationMerging() + public static function dataProviderForConfigurationMerging() { $presets = [ 'default' => [ @@ -118,7 +118,7 @@ public function initializeObjectLoadsSettings() ->expects($this->once()) ->method('getConfiguration') ->with(ConfigurationManager::CONFIGURATION_TYPE_SETTINGS, 'Neos.Form') - ->will($this->returnValue('MyConfig')); + ->willReturn('MyConfig'); $abstractFormFactory->_set('configurationManager', $mockConfigurationManager); $abstractFormFactory->_call('initializeObject'); diff --git a/Tests/Unit/Utility/SupertypeResolverTest.php b/Tests/Unit/Utility/SupertypeResolverTest.php index bc89525c..1abcb418 100644 --- a/Tests/Unit/Utility/SupertypeResolverTest.php +++ b/Tests/Unit/Utility/SupertypeResolverTest.php @@ -24,7 +24,7 @@ #[CoversClass(SupertypeResolver::class)] class SupertypeResolverTest extends UnitTestCase { - public function dataProviderForTypeResolving() + public static function dataProviderForTypeResolving() { $types = [ 'typeFoo' => [ diff --git a/Tests/Unit/ViewHelpers/FormViewHelperTest.php b/Tests/Unit/ViewHelpers/FormViewHelperTest.php index f8e1f5f0..808e5f73 100644 --- a/Tests/Unit/ViewHelpers/FormViewHelperTest.php +++ b/Tests/Unit/ViewHelpers/FormViewHelperTest.php @@ -47,7 +47,7 @@ public function setUp(): void /** * @return array */ - public function getFormActionUriDataProvider() + public static function getFormActionUriDataProvider() { return [ ['requestUri' => '', 'sectionArgument' => null, 'expectedResult' => ''], @@ -77,22 +77,22 @@ public function getFormActionUriDataProvider() public function getFormActionUriTests($requestUri, $sectionArgument, $expectedResult) { $mockActionRequest = $this->getMockBuilder(ActionRequest::class)->disableOriginalConstructor()->getMock(); - $this->mockControllerContext->expects($this->any())->method('getRequest')->will($this->returnValue($mockActionRequest)); + $this->mockControllerContext->expects($this->any())->method('getRequest')->willReturn($mockActionRequest); $mockHttpRequest = $this->getMockBuilder(ServerRequestInterface::class)->disableOriginalConstructor()->getMock(); - $mockActionRequest->expects($this->any())->method('getHttpRequest')->will($this->returnValue($mockHttpRequest)); + $mockActionRequest->expects($this->any())->method('getHttpRequest')->willReturn($mockHttpRequest); $mockUri = $this->getMockBuilder(Uri::class)->disableOriginalConstructor()->getMock(); - $mockUri->expects($this->any())->method('withFragment')->will($this->returnCallback(function ($fragment) use ($requestUri, $mockUri) { + $mockUri->expects($this->any())->method('withFragment')->willReturnCallback(function ($fragment) use ($requestUri, $mockUri) { $newUri = explode('#', $requestUri)[0] . '#' . $fragment; $modifiedMockUri = $this->getMockBuilder(Uri::class)->disableOriginalConstructor()->getMock(); - $modifiedMockUri->expects($this->any())->method('__toString')->will($this->returnValue($newUri)); + $modifiedMockUri->expects($this->any())->method('__toString')->willReturn($newUri); return $modifiedMockUri; - })); - $mockUri->expects($this->any())->method('__toString')->will($this->returnValue($requestUri)); - $mockHttpRequest->expects($this->any())->method('getUri')->will($this->returnValue($mockUri)); + }); + $mockUri->expects($this->any())->method('__toString')->willReturn($requestUri); + $mockHttpRequest->expects($this->any())->method('getUri')->willReturn($mockUri); - $this->formViewHelper->expects($this->any())->method('hasArgument')->with('section')->will($this->returnValue($sectionArgument !== null)); + $this->formViewHelper->expects($this->any())->method('hasArgument')->with('section')->willReturn($sectionArgument !== null); $this->formViewHelper->_set('arguments', ['section' => $sectionArgument]); Assert::assertSame($expectedResult, $this->formViewHelper->_call('getFormActionUri')); From bea641f96e5d088bd50a7b821e9312f7de387f95 Mon Sep 17 00:00:00 2001 From: Karsten Dambekalns Date: Tue, 11 Aug 2026 19:37:55 +0200 Subject: [PATCH 3/5] TASK: Use imported class names in tests Replace inline fully qualified and namespace-prefixed class references with `use` imports in test classes. --- Tests/Unit/Core/Model/AbstractFinisherTest.php | 3 ++- Tests/Unit/Core/Model/FormDefinitionTest.php | 11 ++++++----- Tests/Unit/Core/Renderer/FormRuntimeTest.php | 6 ++++-- Tests/Unit/Factory/AbstractFormFactoryTest.php | 3 ++- Tests/Unit/ViewHelpers/FormViewHelperTest.php | 3 ++- 5 files changed, 16 insertions(+), 10 deletions(-) diff --git a/Tests/Unit/Core/Model/AbstractFinisherTest.php b/Tests/Unit/Core/Model/AbstractFinisherTest.php index 0806358f..41a74a44 100644 --- a/Tests/Unit/Core/Model/AbstractFinisherTest.php +++ b/Tests/Unit/Core/Model/AbstractFinisherTest.php @@ -13,6 +13,7 @@ use PHPUnit\Framework\Attributes\CoversClass; use PHPUnit\Framework\Attributes\Test; use PHPUnit\Framework\Attributes\DataProvider; +use PHPUnit\Framework\MockObject\MockObject; use Neos\Flow\Tests\UnitTestCase; use Neos\Form\Core\Model\AbstractFinisher; use Neos\Form\Core\Model\FinisherContext; @@ -193,7 +194,7 @@ public function cancelCanBeSetOnFinisherContext() } /** - * @return AbstractFinisher|\PHPUnit\Framework\MockObject\MockObject + * @return AbstractFinisher|MockObject */ protected function getAbstractFinisher() { diff --git a/Tests/Unit/Core/Model/FormDefinitionTest.php b/Tests/Unit/Core/Model/FormDefinitionTest.php index a6a04ce6..f4a709ca 100644 --- a/Tests/Unit/Core/Model/FormDefinitionTest.php +++ b/Tests/Unit/Core/Model/FormDefinitionTest.php @@ -13,6 +13,7 @@ use PHPUnit\Framework\Attributes\CoversClass; use PHPUnit\Framework\Attributes\Test; use PHPUnit\Framework\Attributes\DataProvider; +use Neos\Form\Tests\Unit\Core\Model\Fixture\EmptyFinisher; use Neos\Flow\Mvc\ActionRequest; use Neos\Flow\Mvc\ActionResponse; use Neos\Flow\Tests\UnitTestCase; @@ -99,7 +100,7 @@ public function constructorSetsFinishers() $formDefinition = new FormDefinition('myForm', [ 'finisherPresets' => [ 'myFinisher' => [ - 'implementationClassName' => $this->buildAccessibleProxy(Fixture\EmptyFinisher::class), + 'implementationClassName' => $this->buildAccessibleProxy(EmptyFinisher::class), 'options' => [ 'foo' => 'bar', 'test' => 'asdf' @@ -122,7 +123,7 @@ public function constructorSetsFinishers() $finishers = $formDefinition->getFinishers(); Assert::assertSame(1, count($finishers)); $finisher = $finishers[0]; - $this->assertInstanceOf(Fixture\EmptyFinisher::class, $finisher); + $this->assertInstanceOf(EmptyFinisher::class, $finisher); /** @noinspection PhpUndefinedMethodInspection */ Assert::assertSame(['foo' => 'baz', 'test' => 'asdf'], $finisher->_get('options')); } @@ -645,7 +646,7 @@ public function createFinisherCreatesFinisherCorrectly() { $formDefinition = $this->getFormDefinitionWithFinisherConfiguration(); $finisher = $formDefinition->createFinisher('email'); - $this->assertInstanceOf(Fixture\EmptyFinisher::class, $finisher); + $this->assertInstanceOf(EmptyFinisher::class, $finisher); Assert::assertSame([$finisher], $formDefinition->getFinishers()); } @@ -678,10 +679,10 @@ protected function getFormDefinitionWithFinisherConfiguration() 'assd' => 'as' ], 'email' => [ - 'implementationClassName' => $this->buildAccessibleProxy(Fixture\EmptyFinisher::class) + 'implementationClassName' => $this->buildAccessibleProxy(EmptyFinisher::class) ], 'emailWithOptions' => [ - 'implementationClassName' => $this->buildAccessibleProxy(Fixture\EmptyFinisher::class), + 'implementationClassName' => $this->buildAccessibleProxy(EmptyFinisher::class), 'options' => [ 'foo' => 'bar', 'name' => 'asdf' diff --git a/Tests/Unit/Core/Renderer/FormRuntimeTest.php b/Tests/Unit/Core/Renderer/FormRuntimeTest.php index 9f1e3eb0..2f89dbdb 100644 --- a/Tests/Unit/Core/Renderer/FormRuntimeTest.php +++ b/Tests/Unit/Core/Renderer/FormRuntimeTest.php @@ -12,6 +12,8 @@ */ use PHPUnit\Framework\Attributes\CoversClass; use PHPUnit\Framework\Attributes\Test; +use Neos\Form\Tests\Unit\Core\Runtime\Renderer\Fixture\DummyFinisher; +use PHPUnit\Framework\MockObject\MockObject; use Neos\Flow\Mvc\ActionRequest; use Neos\Flow\Mvc\ActionResponse; use Neos\Flow\Tests\UnitTestCase; @@ -127,7 +129,7 @@ public function invokeFinishersInvokesFinishersInCorrectOrder() */ protected function getMockFinisher(\Closure $closureToExecute) { - $finisher = new Renderer\Fixture\DummyFinisher(); + $finisher = new DummyFinisher(); $finisher->cb = $closureToExecute; return $finisher; @@ -195,7 +197,7 @@ public function arrayAccessReturnsDefaultValuesIfSet() /** * @param FormDefinition $formDefinition - * @return FormRuntime|\PHPUnit\Framework\MockObject\MockObject + * @return FormRuntime|MockObject */ protected function createFormRuntime(FormDefinition $formDefinition) { diff --git a/Tests/Unit/Factory/AbstractFormFactoryTest.php b/Tests/Unit/Factory/AbstractFormFactoryTest.php index 64b547c0..6c4b6595 100644 --- a/Tests/Unit/Factory/AbstractFormFactoryTest.php +++ b/Tests/Unit/Factory/AbstractFormFactoryTest.php @@ -13,6 +13,7 @@ use PHPUnit\Framework\Attributes\CoversClass; use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\Attributes\Test; +use PHPUnit\Framework\MockObject\MockObject; use Neos\Flow\Configuration\ConfigurationManager; use Neos\Flow\Tests\UnitTestCase; use Neos\Form\Exception\PresetNotFoundException; @@ -126,7 +127,7 @@ public function initializeObjectLoadsSettings() } /** - * @return AbstractFormFactory|\PHPUnit\Framework\MockObject\MockObject + * @return AbstractFormFactory|MockObject */ protected function getAbstractFormFactory() { diff --git a/Tests/Unit/ViewHelpers/FormViewHelperTest.php b/Tests/Unit/ViewHelpers/FormViewHelperTest.php index 808e5f73..1f981a53 100644 --- a/Tests/Unit/ViewHelpers/FormViewHelperTest.php +++ b/Tests/Unit/ViewHelpers/FormViewHelperTest.php @@ -12,6 +12,7 @@ */ use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\Attributes\Test; +use PHPUnit\Framework\MockObject\MockObject; use GuzzleHttp\Psr7\Uri; use Neos\Flow\Mvc\ActionRequest; use Neos\Flow\Mvc\Controller\ControllerContext; @@ -31,7 +32,7 @@ class FormViewHelperTest extends UnitTestCase protected $formViewHelper; /** - * @var ControllerContext|\PHPUnit\Framework\MockObject\MockObject + * @var ControllerContext|MockObject */ protected $mockControllerContext; From a0946ff37c864f9d07c3a862af2f2016ba196989 Mon Sep 17 00:00:00 2001 From: Karsten Dambekalns Date: Tue, 11 Aug 2026 19:39:15 +0200 Subject: [PATCH 4/5] TASK: Replace deprecated PhpUnit mock APIs MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Update the test suites to the mocking API supported by PHPUnit 11: * `->will(self::returnValue(…))` becomes `->willReturn(…)`, the same for `returnCallback`, `returnSelf` and `throwException` * `setMethods()` becomes `onlyMethods()` * `withConsecutive()` is gone, so those expectations are rewritten using an invocation matcher and `willReturnCallback()` that checks `numberOfInvocations()` No test behaviour is changed. --- .../Core/Model/AbstractFormElementTest.php | 6 ++--- Tests/Unit/Core/Model/FormDefinitionTest.php | 4 ++-- Tests/Unit/Core/Model/PageTest.php | 24 +++++++++---------- Tests/Unit/Core/Model/ProcessingRuleTest.php | 4 ++-- Tests/Unit/Core/Renderer/FormRuntimeTest.php | 4 ++-- 5 files changed, 21 insertions(+), 21 deletions(-) diff --git a/Tests/Unit/Core/Model/AbstractFormElementTest.php b/Tests/Unit/Core/Model/AbstractFormElementTest.php index 192bf536..cbb35acc 100644 --- a/Tests/Unit/Core/Model/AbstractFormElementTest.php +++ b/Tests/Unit/Core/Model/AbstractFormElementTest.php @@ -182,7 +182,7 @@ public function isRequiredReturnsTrueIfNotEmptyValidatorIsAdded() */ protected function getFormElement(array $constructorArguments) { - return $this->getMockBuilder(AbstractFormElement::class)->setMethods(['dummy'])->setConstructorArgs($constructorArguments)->getMock(); + return $this->getMockBuilder(AbstractFormElement::class)->addMethods(['dummy'])->setConstructorArgs($constructorArguments)->getMock(); } /** @@ -196,8 +196,8 @@ protected function getFormDefinitionWithProcessingRule($formElementIdentifier) $mockProcessingRule = $this->getAccessibleMock(ProcessingRule::class, ['dummy']); $mockProcessingRule->_set('validator', new ConjunctionValidator()); - $formDefinition = $this->getMockBuilder(FormDefinition::class)->setMethods(['getProcessingRule'])->setConstructorArgs(['foo'])->getMock(); - $formDefinition->expects($this->any())->method('getProcessingRule')->with($formElementIdentifier)->will($this->returnValue($mockProcessingRule)); + $formDefinition = $this->getMockBuilder(FormDefinition::class)->onlyMethods(['getProcessingRule'])->setConstructorArgs(['foo'])->getMock(); + $formDefinition->expects($this->any())->method('getProcessingRule')->with($formElementIdentifier)->willReturn($mockProcessingRule); return $formDefinition; } diff --git a/Tests/Unit/Core/Model/FormDefinitionTest.php b/Tests/Unit/Core/Model/FormDefinitionTest.php index f4a709ca..eac5a40b 100644 --- a/Tests/Unit/Core/Model/FormDefinitionTest.php +++ b/Tests/Unit/Core/Model/FormDefinitionTest.php @@ -710,8 +710,8 @@ protected function getMockFinisher() */ protected function getMockFormElement($identifier) { - $mockFormElement = $this->getMockBuilder(AbstractFormElement::class)->setMethods(['getIdentifier'])->disableOriginalConstructor()->getMock(); - $mockFormElement->expects($this->any())->method('getIdentifier')->will($this->returnValue($identifier)); + $mockFormElement = $this->getMockBuilder(AbstractFormElement::class)->onlyMethods(['getIdentifier'])->disableOriginalConstructor()->getMock(); + $mockFormElement->expects($this->any())->method('getIdentifier')->willReturn($identifier); return $mockFormElement; } diff --git a/Tests/Unit/Core/Model/PageTest.php b/Tests/Unit/Core/Model/PageTest.php index 1e058dbf..e26a0582 100644 --- a/Tests/Unit/Core/Model/PageTest.php +++ b/Tests/Unit/Core/Model/PageTest.php @@ -104,9 +104,9 @@ public function getElementsRecursivelyReturnsFirstLevelFormElements() { $page = new Page('foo'); /** @var AbstractFormElement|MockObject $element1 */ - $element1 = $this->getMockBuilder(AbstractFormElement::class)->setMethods(['dummy'])->disableOriginalConstructor()->getMock(); + $element1 = $this->getMockBuilder(AbstractFormElement::class)->addMethods(['dummy'])->disableOriginalConstructor()->getMock(); /** @var AbstractFormElement|MockObject $element2 */ - $element2 = $this->getMockBuilder(AbstractFormElement::class)->setMethods(['dummy'])->disableOriginalConstructor()->getMock(); + $element2 = $this->getMockBuilder(AbstractFormElement::class)->addMethods(['dummy'])->disableOriginalConstructor()->getMock(); $page->addElement($element1); $page->addElement($element2); Assert::assertSame([$element1, $element2], $page->getElementsRecursively()); @@ -118,17 +118,17 @@ public function getElementsRecursivelyReturnsRecursiveFormElementsInCorrectOrder $page = new Page('foo'); /** @var AbstractFormElement|MockObject $element1 */ - $element1 = $this->getMockBuilder(AbstractFormElement::class)->setMethods(['dummy'])->disableOriginalConstructor()->getMock(); + $element1 = $this->getMockBuilder(AbstractFormElement::class)->addMethods(['dummy'])->disableOriginalConstructor()->getMock(); /** @var Section|MockObject $element2 */ - $element2 = $this->getMockBuilder(Section::class)->setMethods(['dummy'])->disableOriginalConstructor()->getMock(); + $element2 = $this->getMockBuilder(Section::class)->addMethods(['dummy'])->disableOriginalConstructor()->getMock(); /** @var AbstractFormElement|MockObject $element21 */ - $element21 = $this->getMockBuilder(AbstractFormElement::class)->setMethods(['dummy'])->disableOriginalConstructor()->getMock(); + $element21 = $this->getMockBuilder(AbstractFormElement::class)->addMethods(['dummy'])->disableOriginalConstructor()->getMock(); /** @var AbstractFormElement|MockObject $element22 */ - $element22 = $this->getMockBuilder(AbstractFormElement::class)->setMethods(['dummy'])->disableOriginalConstructor()->getMock(); + $element22 = $this->getMockBuilder(AbstractFormElement::class)->addMethods(['dummy'])->disableOriginalConstructor()->getMock(); $element2->addElement($element21); $element2->addElement($element22); /** @var AbstractFormElement|MockObject $element3 */ - $element3 = $this->getMockBuilder(AbstractFormElement::class)->setMethods(['dummy'])->disableOriginalConstructor()->getMock(); + $element3 = $this->getMockBuilder(AbstractFormElement::class)->addMethods(['dummy'])->disableOriginalConstructor()->getMock(); $page->addElement($element1); $page->addElement($element2); @@ -142,7 +142,7 @@ public function aFormElementCanOnlyBeAttachedToASinglePage() $this->expectException(FormDefinitionConsistencyException::class); /** @var AbstractFormElement|MockObject $element */ - $element = $this->getMockBuilder(AbstractFormElement::class)->setMethods(['dummy'])->disableOriginalConstructor()->getMock(); + $element = $this->getMockBuilder(AbstractFormElement::class)->addMethods(['dummy'])->disableOriginalConstructor()->getMock(); $page1 = new Page('bar1'); $page2 = new Page('bar2'); @@ -156,7 +156,7 @@ public function addElementAddsElementAndSetsBackReferenceToPage() { $page = new Page('bar'); /** @var AbstractFormElement|MockObject $element */ - $element = $this->getMockBuilder(AbstractFormElement::class)->setMethods(['dummy'])->disableOriginalConstructor()->getMock(); + $element = $this->getMockBuilder(AbstractFormElement::class)->addMethods(['dummy'])->disableOriginalConstructor()->getMock(); $page->addElement($element); Assert::assertSame([$element], $page->getElements()); Assert::assertSame($page, $element->getParentRenderable()); @@ -306,7 +306,7 @@ public function removeElementThrowsExceptionIfElementIsNotOnCurrentPage() $formDefinition = $this->getDummyFormDefinition(); $page1 = $formDefinition->createPage('myPage1'); /** @var AbstractFormElement|MockObject $element1 */ - $element1 = $this->getMockBuilder(AbstractFormElement::class)->setMethods(['dummy'])->disableOriginalConstructor()->getMock(); + $element1 = $this->getMockBuilder(AbstractFormElement::class)->addMethods(['dummy'])->disableOriginalConstructor()->getMock(); $page1->removeElement($element1); } @@ -319,7 +319,7 @@ public function validatorKeyCorrectlyAddsValidator() $mockProcessingRule = $this->getAccessibleMock(ProcessingRule::class, ['dummy']); /** @noinspection PhpUndefinedMethodInspection */ $mockProcessingRule->_set('validator', new ConjunctionValidator()); - $formDefinition->expects($this->any())->method('getProcessingRule')->with('asdf')->will($this->returnValue($mockProcessingRule)); + $formDefinition->expects($this->any())->method('getProcessingRule')->with('asdf')->willReturn($mockProcessingRule); $page1 = $formDefinition->createPage('myPage1'); /** @var AbstractFormElement|MockObject $element */ @@ -414,7 +414,7 @@ protected function getDummyFormDefinition() ] ]]; - $formDefinition = $this->getMockBuilder(FormDefinition::class)->setMethods(['getProcessingRule'])->setConstructorArgs($formDefinitionConstructorArguments)->getMock(); + $formDefinition = $this->getMockBuilder(FormDefinition::class)->onlyMethods(['getProcessingRule'])->setConstructorArgs($formDefinitionConstructorArguments)->getMock(); return $formDefinition; } } diff --git a/Tests/Unit/Core/Model/ProcessingRuleTest.php b/Tests/Unit/Core/Model/ProcessingRuleTest.php index e82b8c80..fb7c6e79 100644 --- a/Tests/Unit/Core/Model/ProcessingRuleTest.php +++ b/Tests/Unit/Core/Model/ProcessingRuleTest.php @@ -112,8 +112,8 @@ public function processConvertsValueIfDataTypeIsSpecified() $this->processingRule->setDataType('SomeDataType'); $propertyMappingConfiguration = $this->processingRule->getPropertyMappingConfiguration(); - $this->mockPropertyMapper->expects($this->once())->method('convert')->with('Some Value', 'SomeDataType', $propertyMappingConfiguration)->will($this->returnValue('Converted Value')); - $this->mockPropertyMapper->expects($this->any())->method('getMessages')->will($this->returnValue(new Result())); + $this->mockPropertyMapper->expects($this->once())->method('convert')->with('Some Value', 'SomeDataType', $propertyMappingConfiguration)->willReturn('Converted Value'); + $this->mockPropertyMapper->expects($this->any())->method('getMessages')->willReturn(new Result()); Assert::assertEquals('Converted Value', $this->processingRule->process('Some Value')); } } diff --git a/Tests/Unit/Core/Renderer/FormRuntimeTest.php b/Tests/Unit/Core/Renderer/FormRuntimeTest.php index 2f89dbdb..5a5f6f84 100644 --- a/Tests/Unit/Core/Renderer/FormRuntimeTest.php +++ b/Tests/Unit/Core/Renderer/FormRuntimeTest.php @@ -37,9 +37,9 @@ public function valuesSetInConstructorCanBeReadAgain() { $formDefinition = new FormDefinition('foo'); - $mockActionRequest = $this->getMockBuilder(ActionRequest::class)->setMethods(['createSubRequest'])->disableOriginalConstructor()->getMock(); + $mockActionRequest = $this->getMockBuilder(ActionRequest::class)->onlyMethods(['createSubRequest'])->disableOriginalConstructor()->getMock(); - $mockFormSubRequest = $this->getMockBuilder(ActionRequest::class)->setMethods(['getParentRequest'])->disableOriginalConstructor()->getMock(); + $mockFormSubRequest = $this->getMockBuilder(ActionRequest::class)->onlyMethods(['getParentRequest'])->disableOriginalConstructor()->getMock(); $mockFormSubRequest->expects(self::any())->method('getParentRequest')->willReturn($mockActionRequest); $mockActionRequest->expects(self::once())->method('createSubRequest')->willReturn($mockFormSubRequest); From e79fdfb2462d58e77f134854ff722a1e954d686f Mon Sep 17 00:00:00 2001 From: Karsten Dambekalns Date: Wed, 12 Aug 2026 19:21:30 +0200 Subject: [PATCH 5/5] TASK: Require Flow 8.4 or higher Flow 8.0 through 8.3 ship older PhpUnit versions, so the test suite that was updated for PhpUnit 11 can no longer run against them. Drop those branches from the requirement and the CI test matrix. Also update the checkout action to v6. --- .github/workflows/tests.yml | 6 +++--- composer.json | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 4168e10f..7ba8feb5 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -20,7 +20,7 @@ jobs: fail-fast: false matrix: php-versions: ['8.2', '8.3'] - flow-versions: ['8.0', '8.3', '9.0'] + flow-versions: ['8.4', '9.0'] dependencies: ['highest'] defaults: @@ -29,14 +29,14 @@ jobs: steps: - name: Checkout Flow development distribution - uses: actions/checkout@v4 + uses: actions/checkout@v6 with: repository: neos/flow-development-distribution ref: ${{ matrix.flow-versions }} path: ${{ env.FLOW_FOLDER }} - name: Checkout package - uses: actions/checkout@v4 + uses: actions/checkout@v6 with: path: ${{ env.PACKAGE_FOLDER}}/${{ env.PACKAGE_NAME }} diff --git a/composer.json b/composer.json index 56771369..5794f0c8 100755 --- a/composer.json +++ b/composer.json @@ -5,7 +5,7 @@ "description": "Extensible and flexible API for building web forms", "require": { "php": "^8.2", - "neos/flow": "^8.0 || ^9.0" + "neos/flow": "^8.4 || ^9.0" }, "replace": { "typo3/form": "self.version"