From a7570a30211bceac557d7daeb63d12fd4f2c6ae2 Mon Sep 17 00:00:00 2001
From: Oliver Klee <typo3-coding@oliverklee.de>
Date: Fri, 11 Aug 2023 14:26:20 +0200
Subject: [PATCH] [TASK] Migrate `getMockForAbstractClass()` calls in
 `EXT:form`

`getMockForAbstractClass` has been (soft-)deprecated in PHPUnit 10.1:
https://github.com/sebastianbergmann/phpunit/issues/5241

Hence, we should replace its usages to follow best practices and
avoid deprecation warnings later with PHPUnit 11.

We do this by creating dedicated fixture subclasses of the affected
abstract classes.

Resolves: #101661
Related: #101601
Releases: main, 12.4
Change-Id: I3b9ba4511620aebf125ff207428adc5483d47154
Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/80944
Reviewed-by: Benjamin Franzke <ben@bnf.dev>
Tested-by: Benjamin Franzke <ben@bnf.dev>
Tested-by: core-ci <typo3@b13.com>
---
 .../FormElements/AbstractFormElementTest.php  | 174 +++++-------------
 .../FormElements/AbstractSectionTest.php      |  89 ++-------
 .../Fixtures/TestingFormElement.php           |  31 ++++
 .../FormElements/Fixtures/TestingSection.php  |  37 ++++
 .../Renderable/AbstractRenderableTest.php     |  44 ++---
 .../Renderable/Fixtures/TestingRenderable.php |  27 +++
 6 files changed, 170 insertions(+), 232 deletions(-)
 create mode 100644 typo3/sysext/form/Tests/Unit/Domain/FormElements/Fixtures/TestingFormElement.php
 create mode 100644 typo3/sysext/form/Tests/Unit/Domain/FormElements/Fixtures/TestingSection.php
 create mode 100644 typo3/sysext/form/Tests/Unit/Domain/Renderable/Fixtures/TestingRenderable.php

diff --git a/typo3/sysext/form/Tests/Unit/Domain/FormElements/AbstractFormElementTest.php b/typo3/sysext/form/Tests/Unit/Domain/FormElements/AbstractFormElementTest.php
index 4c6b255e7245..8527340a444d 100644
--- a/typo3/sysext/form/Tests/Unit/Domain/FormElements/AbstractFormElementTest.php
+++ b/typo3/sysext/form/Tests/Unit/Domain/FormElements/AbstractFormElementTest.php
@@ -20,8 +20,8 @@ namespace TYPO3\CMS\Form\Tests\Unit\Domain\FormElements;
 use TYPO3\CMS\Core\Utility\GeneralUtility;
 use TYPO3\CMS\Form\Domain\Exception\IdentifierNotValidException;
 use TYPO3\CMS\Form\Domain\Model\FormDefinition;
-use TYPO3\CMS\Form\Domain\Model\FormElements\AbstractFormElement;
 use TYPO3\CMS\Form\Domain\Model\FormElements\GenericFormElement;
+use TYPO3\CMS\Form\Tests\Unit\Domain\FormElements\Fixtures\TestingFormElement;
 use TYPO3\TestingFramework\Core\Unit\UnitTestCase;
 
 final class AbstractFormElementTest extends UnitTestCase
@@ -31,7 +31,7 @@ final class AbstractFormElementTest extends UnitTestCase
      */
     public function newInstanceHasNoProperties(): void
     {
-        $subject = $this->getMockForAbstractClass(AbstractFormElement::class, ['an_id', 'a_type']);
+        $subject = new TestingFormElement();
         self::assertNotNull($subject);
         self::assertCount(0, $subject->getProperties());
     }
@@ -41,7 +41,7 @@ final class AbstractFormElementTest extends UnitTestCase
      */
     public function setSimpleProperties(): void
     {
-        $subject = $this->getMockForAbstractClass(AbstractFormElement::class, ['an_id', 'a_type']);
+        $subject = new TestingFormElement();
 
         $subject->setProperty('foo', 'bar');
         $subject->setProperty('buz', 'qax');
@@ -59,7 +59,7 @@ final class AbstractFormElementTest extends UnitTestCase
      */
     public function overrideProperties(): void
     {
-        $subject = $this->getMockForAbstractClass(AbstractFormElement::class, ['an_id', 'a_type']);
+        $subject = new TestingFormElement();
 
         $subject->setProperty('foo', 'bar');
         $subject->setProperty('foo', 'buz');
@@ -75,7 +75,7 @@ final class AbstractFormElementTest extends UnitTestCase
      */
     public function setArrayProperties(): void
     {
-        $subject = $this->getMockForAbstractClass(AbstractFormElement::class, ['an_id', 'a_type']);
+        $subject = new TestingFormElement();
 
         $subject->setProperty('foo', ['bar' => 'baz', 'bla' => 'blubb']);
         $properties = $subject->getProperties();
@@ -95,7 +95,7 @@ final class AbstractFormElementTest extends UnitTestCase
      */
     public function setPropertyUnsetIfValueIsNull(): void
     {
-        $subject = $this->getMockForAbstractClass(AbstractFormElement::class, ['an_id', 'a_type']);
+        $subject = new TestingFormElement();
 
         $expected = ['foo-1' => ['bar-1' => 'foo-2']];
         $subject->setProperty('foo-1', ['bar-1' => 'foo-2']);
@@ -110,7 +110,7 @@ final class AbstractFormElementTest extends UnitTestCase
      */
     public function setPropertyUnsetIfValueIsArrayWithSomeNullVales(): void
     {
-        $subject = $this->getMockForAbstractClass(AbstractFormElement::class, ['an_id', 'a_type']);
+        $subject = new TestingFormElement();
 
         $expected = [
             'foo-1' => [
@@ -144,16 +144,9 @@ final class AbstractFormElementTest extends UnitTestCase
      */
     public function constructMustNotThrowExceptionWhenIdentifierIsNonEmptyString(): void
     {
-        $mock = $this->getMockForAbstractClass(
-            AbstractFormElement::class,
-            ['is_in', 'a_type'],
-            '',
-            true,
-            true,
-            true,
-            []
-        );
-        self::assertInstanceOf(AbstractFormElement::class, $mock);
+        $formElement = new TestingFormElement();
+
+        self::assertInstanceOf(TestingFormElement::class, $formElement);
     }
 
     /**
@@ -161,39 +154,22 @@ final class AbstractFormElementTest extends UnitTestCase
      */
     public function initializeFormElementExpectedCallInitializeFormObjectHooks(): void
     {
-        $abstractFormElementMock = $this->getMockForAbstractClass(
-            AbstractFormElement::class,
-            [],
-            '',
-            false,
-            false,
-            true,
-            []
-        );
-        $secondMock = $this->getMockForAbstractClass(
-            AbstractFormElement::class,
-            [],
-            '',
-            false,
-            false,
-            true,
-            [
-                'initializeFormElement',
-            ]
-        );
+        $formElement = new TestingFormElement();
+        $secondFormElementMock = $this->createMock(TestingFormElement::class);
 
-        $secondMock->
+        $secondFormElementMock->
         expects(self::once())
             ->method('initializeFormElement')
-            ->with($abstractFormElementMock);
+            ->with($formElement);
 
-        GeneralUtility::addInstance(\get_class($secondMock), $secondMock);
+        $secondFormElementMockClassName = \get_class($secondFormElementMock);
+        GeneralUtility::addInstance($secondFormElementMockClassName, $secondFormElementMock);
 
         $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['ext/form']['initializeFormElement'] = [
-            \get_class($secondMock),
+            $secondFormElementMockClassName,
         ];
 
-        $abstractFormElementMock->initializeFormElement();
+        $formElement->initializeFormElement();
     }
 
     /**
@@ -201,51 +177,25 @@ final class AbstractFormElementTest extends UnitTestCase
      */
     public function getUniqueIdentifierExpectedUnique(): void
     {
-        $abstractFormElementMock1 = $this->getMockForAbstractClass(
-            AbstractFormElement::class,
-            [],
-            '',
-            false,
-            false,
-            true,
-            [
-                'getRootForm',
-            ]
-        );
-
-        $abstractFormElementMock2 = $this->getMockForAbstractClass(
-            AbstractFormElement::class,
-            [],
-            '',
-            false,
-            false,
-            true,
-            [
-                'getRootForm',
-            ]
-        );
-
         $formDefinition1 = $this->createMock(FormDefinition::class);
         $formDefinition1
             ->method('getIdentifier')
             ->willReturn('c');
 
-        $abstractFormElementMock1
-            ->method('getRootForm')
-            ->willReturn($formDefinition1);
+        $formElement1 = new TestingFormElement();
+        $formElement1->setParentRenderable($formDefinition1);
 
         $formDefinition2 = $this->createMock(FormDefinition::class);
         $formDefinition2
             ->method('getIdentifier')
             ->willReturn('d');
 
-        $abstractFormElementMock2
-            ->method('getRootForm')
-            ->willReturn($formDefinition2);
+        $formElement2 = new TestingFormElement();
+        $formElement2->setParentRenderable($formDefinition2);
 
         self::assertNotSame(
-            $abstractFormElementMock1->getUniqueIdentifier(),
-            $abstractFormElementMock2->getUniqueIdentifier()
+            $formElement1->getUniqueIdentifier(),
+            $formElement2->getUniqueIdentifier()
         );
     }
 
@@ -255,25 +205,15 @@ final class AbstractFormElementTest extends UnitTestCase
     public function setDefaultValueSetStringValueIfKeyDoesNotExists(): void
     {
         $formDefinitionMock = $this->getAccessibleMock(FormDefinition::class, null, [], '', false);
-        $abstractFormElementMock = $this->getMockForAbstractClass(
-            AbstractFormElement::class,
-            ['is_in', 'a_type'],
-            '',
-            true,
-            true,
-            true,
-            ['getRootForm']
-        );
-        $abstractFormElementMock
-            ->method('getRootForm')
-            ->willReturn($formDefinitionMock);
+        $formElement = new TestingFormElement();
+        $formElement->setParentRenderable($formDefinitionMock);
 
         $input = 'foo';
         $expected = 'foo';
 
-        $abstractFormElementMock->setDefaultValue($input);
+        $formElement->setDefaultValue($input);
 
-        self::assertSame($expected, $abstractFormElementMock->getDefaultValue());
+        self::assertSame($expected, $formElement->getDefaultValue());
     }
 
     /**
@@ -282,25 +222,15 @@ final class AbstractFormElementTest extends UnitTestCase
     public function setDefaultValueSetArrayValueIfKeyDoesNotExists(): void
     {
         $formDefinitionMock = $this->getAccessibleMock(FormDefinition::class, null, [], '', false);
-        $abstractFormElementMock = $this->getMockForAbstractClass(
-            AbstractFormElement::class,
-            ['is_in', 'a_type'],
-            '',
-            true,
-            true,
-            true,
-            ['getRootForm']
-        );
-        $abstractFormElementMock
-            ->method('getRootForm')
-            ->willReturn($formDefinitionMock);
+        $formElement = new TestingFormElement();
+        $formElement->setParentRenderable($formDefinitionMock);
 
         $input = ['foo' => 'bar'];
         $expected = ['foo' => 'bar'];
 
-        $abstractFormElementMock->setDefaultValue($input);
+        $formElement->setDefaultValue($input);
 
-        self::assertSame($expected, $abstractFormElementMock->getDefaultValue());
+        self::assertSame($expected, $formElement->getDefaultValue());
     }
 
     /**
@@ -309,18 +239,8 @@ final class AbstractFormElementTest extends UnitTestCase
     public function setDefaultValueUnsetIfValueIsArrayWithSomeNullVales(): void
     {
         $formDefinitionMock = $this->getAccessibleMock(FormDefinition::class, null, [], '', false);
-        $abstractFormElementMock = $this->getMockForAbstractClass(
-            AbstractFormElement::class,
-            ['is_in', 'a_type'],
-            '',
-            true,
-            true,
-            true,
-            ['getRootForm']
-        );
-        $abstractFormElementMock
-            ->method('getRootForm')
-            ->willReturn($formDefinitionMock);
+        $formElement = new TestingFormElement();
+        $formElement->setParentRenderable($formDefinitionMock);
 
         $input1 = [
             'foo-1' => [
@@ -347,10 +267,10 @@ final class AbstractFormElementTest extends UnitTestCase
             ],
         ];
 
-        $abstractFormElementMock->setDefaultValue($input1);
-        $abstractFormElementMock->setDefaultValue($input2);
+        $formElement->setDefaultValue($input1);
+        $formElement->setDefaultValue($input2);
 
-        self::assertSame($expected, $abstractFormElementMock->getDefaultValue());
+        self::assertSame($expected, $formElement->getDefaultValue());
     }
 
     /**
@@ -359,18 +279,8 @@ final class AbstractFormElementTest extends UnitTestCase
     public function setDefaultValueAddValueIfValueIsArray(): void
     {
         $formDefinitionMock = $this->getAccessibleMock(FormDefinition::class, null, [], '', false);
-        $abstractFormElementMock = $this->getMockForAbstractClass(
-            AbstractFormElement::class,
-            ['is_in', 'a_type'],
-            '',
-            true,
-            true,
-            true,
-            ['getRootForm']
-        );
-        $abstractFormElementMock
-            ->method('getRootForm')
-            ->willReturn($formDefinitionMock);
+        $formElement = new TestingFormElement();
+        $formElement->setParentRenderable($formDefinitionMock);
 
         $input1 = [
             'foo-1' => [
@@ -397,9 +307,9 @@ final class AbstractFormElementTest extends UnitTestCase
             ],
         ];
 
-        $abstractFormElementMock->setDefaultValue($input1);
-        $abstractFormElementMock->setDefaultValue($input2);
+        $formElement->setDefaultValue($input1);
+        $formElement->setDefaultValue($input2);
 
-        self::assertSame($expected, $abstractFormElementMock->getDefaultValue());
+        self::assertSame($expected, $formElement->getDefaultValue());
     }
 }
diff --git a/typo3/sysext/form/Tests/Unit/Domain/FormElements/AbstractSectionTest.php b/typo3/sysext/form/Tests/Unit/Domain/FormElements/AbstractSectionTest.php
index 3c9fd6dc892f..6d4618c66a20 100644
--- a/typo3/sysext/form/Tests/Unit/Domain/FormElements/AbstractSectionTest.php
+++ b/typo3/sysext/form/Tests/Unit/Domain/FormElements/AbstractSectionTest.php
@@ -22,10 +22,11 @@ use TYPO3\CMS\Form\Domain\Exception\IdentifierNotValidException;
 use TYPO3\CMS\Form\Domain\Exception\TypeDefinitionNotFoundException;
 use TYPO3\CMS\Form\Domain\Exception\TypeDefinitionNotValidException;
 use TYPO3\CMS\Form\Domain\Model\FormDefinition;
-use TYPO3\CMS\Form\Domain\Model\FormElements\AbstractFormElement;
 use TYPO3\CMS\Form\Domain\Model\FormElements\AbstractSection;
 use TYPO3\CMS\Form\Domain\Model\FormElements\Section;
 use TYPO3\CMS\Form\Domain\Model\FormElements\UnknownFormElement;
+use TYPO3\CMS\Form\Tests\Unit\Domain\FormElements\Fixtures\TestingFormElement;
+use TYPO3\CMS\Form\Tests\Unit\Domain\FormElements\Fixtures\TestingSection;
 use TYPO3\TestingFramework\Core\Unit\UnitTestCase;
 
 final class AbstractSectionTest extends UnitTestCase
@@ -107,25 +108,10 @@ final class AbstractSectionTest extends UnitTestCase
         $rootForm
             ->method('getTypeDefinitions')
             ->willReturn([]);
-
-        $mockAbstractSection = $this->getMockForAbstractClass(
-            AbstractSection::class,
-            [],
-            '',
-            false,
-            false,
-            true,
-            [
-                'getRootForm',
-            ]
-        );
-
-        $mockAbstractSection
-            ->method('getRootForm')
-            ->willReturn($rootForm);
+        $section = new TestingSection($rootForm);
 
         GeneralUtility::addInstance(UnknownFormElement::class, new UnknownFormElement('foo', 'bar'));
-        $result = $mockAbstractSection->createElement('foo', 'bar');
+        $result = $section->createElement('foo', 'bar');
 
         self::assertInstanceOf(UnknownFormElement::class, $result);
         self::assertSame('foo', $result->getIdentifier());
@@ -147,27 +133,12 @@ final class AbstractSectionTest extends UnitTestCase
         $rootForm
             ->method('getTypeDefinitions')
             ->willReturn(['foobar' => []]);
-
-        $mockAbstractSection = $this->getMockForAbstractClass(
-            AbstractSection::class,
-            [],
-            '',
-            false,
-            false,
-            true,
-            [
-                'getRootForm',
-            ]
-        );
-
-        $mockAbstractSection
-            ->method('getRootForm')
-            ->willReturn($rootForm);
+        $section = new TestingSection($rootForm);
 
         $this->expectException(TypeDefinitionNotFoundException::class);
         $this->expectExceptionCode(1325689855);
 
-        $mockAbstractSection->createElement('id', 'foobar');
+        $section->createElement('id', 'foobar');
     }
 
     /**
@@ -176,18 +147,6 @@ final class AbstractSectionTest extends UnitTestCase
     public function createElementThrowsExceptionIfTypeDefinitionNotInstanceOfFormElementInterface(): void
     {
         $this->resetSingletonInstances = true;
-        $mockAbstractSection = $this->getMockForAbstractClass(
-            AbstractSection::class,
-            [],
-            '',
-            false,
-            false,
-            true,
-            [
-                'getRootForm',
-            ]
-        );
-
         $rootForm = $this->getMockBuilder(FormDefinition::class)
             ->onlyMethods(['getRenderingOptions', 'getTypeDefinitions'])
             ->disableOriginalConstructor()
@@ -204,16 +163,13 @@ final class AbstractSectionTest extends UnitTestCase
                     ],
                 ]
             );
-
-        $mockAbstractSection
-            ->method('getRootForm')
-            ->willReturn($rootForm);
+        $section = new TestingSection($rootForm);
 
         GeneralUtility::addInstance(self::class, $this);
 
         $this->expectException(TypeDefinitionNotValidException::class);
         $this->expectExceptionCode(1327318156);
-        $mockAbstractSection->createElement('id', 'foobar');
+        $section->createElement('id', 'foobar');
     }
 
     /**
@@ -221,15 +177,7 @@ final class AbstractSectionTest extends UnitTestCase
      */
     public function createElementExpectedToAddAndInitializeElement(): void
     {
-        $implementationMock = $this->getMockForAbstractClass(
-            AbstractFormElement::class,
-            [],
-            '',
-            false,
-            false,
-            true,
-            ['setOptions', 'initializeFormElement']
-        );
+        $implementationMock = $this->createPartialMock(TestingFormElement::class, ['setOptions', 'initializeFormElement']);
 
         $typeDefinition = [
             'foo' => 'bar',
@@ -249,18 +197,6 @@ final class AbstractSectionTest extends UnitTestCase
             ->method('setOptions')
             ->with($typeDefinitionWithoutImplementationClassName);
 
-        $mockAbstractSection = $this->getMockForAbstractClass(
-            AbstractSection::class,
-            [],
-            '',
-            false,
-            false,
-            true,
-            [
-                'getRootForm',
-            ]
-        );
-
         $rootForm = $this->getMockBuilder(FormDefinition::class)
             ->onlyMethods(['getRenderingOptions', 'getTypeDefinitions'])
             ->disableOriginalConstructor()
@@ -271,13 +207,10 @@ final class AbstractSectionTest extends UnitTestCase
         $rootForm
             ->method('getTypeDefinitions')
             ->willReturn(['foobar' => $typeDefinition]);
-
-        $mockAbstractSection
-            ->method('getRootForm')
-            ->willReturn($rootForm);
+        $section = new TestingSection($rootForm);
 
         GeneralUtility::addInstance(get_class($implementationMock), $implementationMock);
 
-        $mockAbstractSection->createElement('id', 'foobar');
+        $section->createElement('id', 'foobar');
     }
 }
diff --git a/typo3/sysext/form/Tests/Unit/Domain/FormElements/Fixtures/TestingFormElement.php b/typo3/sysext/form/Tests/Unit/Domain/FormElements/Fixtures/TestingFormElement.php
new file mode 100644
index 000000000000..44eafb194366
--- /dev/null
+++ b/typo3/sysext/form/Tests/Unit/Domain/FormElements/Fixtures/TestingFormElement.php
@@ -0,0 +1,31 @@
+<?php
+
+declare(strict_types=1);
+
+/*
+ * This file is part of the TYPO3 CMS project.
+ *
+ * It is free software; you can redistribute it and/or modify it under
+ * the terms of the GNU General Public License, either version 2
+ * of the License, or any later version.
+ *
+ * For the full copyright and license information, please read the
+ * LICENSE.txt file that was distributed with this source code.
+ *
+ * The TYPO3 project - inspiring people to share!
+ */
+
+namespace TYPO3\CMS\Form\Tests\Unit\Domain\FormElements\Fixtures;
+
+use TYPO3\CMS\Form\Domain\Model\FormElements\AbstractFormElement;
+
+/**
+ * Testing subclass of the abstract class.
+ */
+class TestingFormElement extends AbstractFormElement
+{
+    public function __construct()
+    {
+        parent::__construct('testing_form_element', '');
+    }
+}
diff --git a/typo3/sysext/form/Tests/Unit/Domain/FormElements/Fixtures/TestingSection.php b/typo3/sysext/form/Tests/Unit/Domain/FormElements/Fixtures/TestingSection.php
new file mode 100644
index 000000000000..3e19c2dcc471
--- /dev/null
+++ b/typo3/sysext/form/Tests/Unit/Domain/FormElements/Fixtures/TestingSection.php
@@ -0,0 +1,37 @@
+<?php
+
+declare(strict_types=1);
+
+/*
+ * This file is part of the TYPO3 CMS project.
+ *
+ * It is free software; you can redistribute it and/or modify it under
+ * the terms of the GNU General Public License, either version 2
+ * of the License, or any later version.
+ *
+ * For the full copyright and license information, please read the
+ * LICENSE.txt file that was distributed with this source code.
+ *
+ * The TYPO3 project - inspiring people to share!
+ */
+
+namespace TYPO3\CMS\Form\Tests\Unit\Domain\FormElements\Fixtures;
+
+use TYPO3\CMS\Form\Domain\Model\FormDefinition;
+use TYPO3\CMS\Form\Domain\Model\FormElements\AbstractSection;
+
+/**
+ * Testing subclass of the abstract class.
+ */
+class TestingSection extends AbstractSection
+{
+    public function __construct(private readonly FormDefinition $rootForm)
+    {
+        parent::__construct('testing_section', '');
+    }
+
+    public function getRootForm(): FormDefinition
+    {
+        return $this->rootForm;
+    }
+}
diff --git a/typo3/sysext/form/Tests/Unit/Domain/Renderable/AbstractRenderableTest.php b/typo3/sysext/form/Tests/Unit/Domain/Renderable/AbstractRenderableTest.php
index 70c148c27683..b2081bd3ea60 100644
--- a/typo3/sysext/form/Tests/Unit/Domain/Renderable/AbstractRenderableTest.php
+++ b/typo3/sysext/form/Tests/Unit/Domain/Renderable/AbstractRenderableTest.php
@@ -17,7 +17,7 @@ declare(strict_types=1);
 
 namespace TYPO3\CMS\Form\Tests\Unit\Domain\Renderable;
 
-use TYPO3\CMS\Form\Domain\Model\Renderable\AbstractRenderable;
+use TYPO3\CMS\Form\Tests\Unit\Domain\Renderable\Fixtures\TestingRenderable;
 use TYPO3\TestingFramework\Core\Unit\UnitTestCase;
 
 final class AbstractRenderableTest extends UnitTestCase
@@ -27,12 +27,12 @@ final class AbstractRenderableTest extends UnitTestCase
      */
     public function setRenderingOptionSetStringValueIfKeyDoesNotExists(): void
     {
-        $abstractRenderableMock = $this->getMockForAbstractClass(AbstractRenderable::class);
+        $renderable = new TestingRenderable();
 
         $expected = ['foo' => 'bar'];
-        $abstractRenderableMock->setRenderingOption('foo', 'bar');
+        $renderable->setRenderingOption('foo', 'bar');
 
-        self::assertSame($expected, $abstractRenderableMock->getRenderingOptions());
+        self::assertSame($expected, $renderable->getRenderingOptions());
     }
 
     /**
@@ -40,12 +40,12 @@ final class AbstractRenderableTest extends UnitTestCase
      */
     public function setRenderingOptionSetArrayValueIfKeyDoesNotExists(): void
     {
-        $abstractRenderableMock = $this->getMockForAbstractClass(AbstractRenderable::class);
+        $renderable = new TestingRenderable();
 
         $expected = ['foo-1' => ['bar' => 'foo-2']];
-        $abstractRenderableMock->setRenderingOption('foo-1', ['bar' => 'foo-2']);
+        $renderable->setRenderingOption('foo-1', ['bar' => 'foo-2']);
 
-        self::assertSame($expected, $abstractRenderableMock->getRenderingOptions());
+        self::assertSame($expected, $renderable->getRenderingOptions());
     }
 
     /**
@@ -53,14 +53,14 @@ final class AbstractRenderableTest extends UnitTestCase
      */
     public function setRenderingOptionUnsetIfValueIsNull(): void
     {
-        $abstractRenderableMock = $this->getMockForAbstractClass(AbstractRenderable::class);
+        $renderable = new TestingRenderable();
 
         $expected = ['foo-1' => ['bar-1' => 'foo-2']];
-        $abstractRenderableMock->setRenderingOption('foo-1', ['bar-1' => 'foo-2']);
-        $abstractRenderableMock->setRenderingOption('foo-2', ['bar-2' => 'foo-3']);
-        $abstractRenderableMock->setRenderingOption('foo-2', null);
+        $renderable->setRenderingOption('foo-1', ['bar-1' => 'foo-2']);
+        $renderable->setRenderingOption('foo-2', ['bar-2' => 'foo-3']);
+        $renderable->setRenderingOption('foo-2', null);
 
-        self::assertSame($expected, $abstractRenderableMock->getRenderingOptions());
+        self::assertSame($expected, $renderable->getRenderingOptions());
     }
 
     /**
@@ -68,7 +68,7 @@ final class AbstractRenderableTest extends UnitTestCase
      */
     public function setRenderingOptionUnsetIfValueIsArrayWithSomeNullVales(): void
     {
-        $abstractRenderableMock = $this->getMockForAbstractClass(AbstractRenderable::class);
+        $renderable = new TestingRenderable();
 
         $expected = [
             'foo-1' => [
@@ -78,11 +78,11 @@ final class AbstractRenderableTest extends UnitTestCase
                 'bar-2' => 'foo-3',
             ],
         ];
-        $abstractRenderableMock->setRenderingOption('foo-1', ['bar-1' => 'foo-2']);
-        $abstractRenderableMock->setRenderingOption('foo-2', ['bar-2' => 'foo-3', 'bar-3' => 'foo-4']);
-        $abstractRenderableMock->setRenderingOption('foo-2', ['bar-3' => null]);
+        $renderable->setRenderingOption('foo-1', ['bar-1' => 'foo-2']);
+        $renderable->setRenderingOption('foo-2', ['bar-2' => 'foo-3', 'bar-3' => 'foo-4']);
+        $renderable->setRenderingOption('foo-2', ['bar-3' => null]);
 
-        self::assertSame($expected, $abstractRenderableMock->getRenderingOptions());
+        self::assertSame($expected, $renderable->getRenderingOptions());
     }
 
     /**
@@ -90,7 +90,7 @@ final class AbstractRenderableTest extends UnitTestCase
      */
     public function setRenderingOptionAddValueIfValueIsArray(): void
     {
-        $abstractRenderableMock = $this->getMockForAbstractClass(AbstractRenderable::class);
+        $renderable = new TestingRenderable();
 
         $expected = [
             'foo-1' => [
@@ -101,10 +101,10 @@ final class AbstractRenderableTest extends UnitTestCase
                 'bar-3' => 'foo-4',
             ],
         ];
-        $abstractRenderableMock->setRenderingOption('foo-1', ['bar-1' => 'foo-2']);
-        $abstractRenderableMock->setRenderingOption('foo-2', ['bar-2' => 'foo-3']);
-        $abstractRenderableMock->setRenderingOption('foo-2', ['bar-3' => 'foo-4']);
+        $renderable->setRenderingOption('foo-1', ['bar-1' => 'foo-2']);
+        $renderable->setRenderingOption('foo-2', ['bar-2' => 'foo-3']);
+        $renderable->setRenderingOption('foo-2', ['bar-3' => 'foo-4']);
 
-        self::assertSame($expected, $abstractRenderableMock->getRenderingOptions());
+        self::assertSame($expected, $renderable->getRenderingOptions());
     }
 }
diff --git a/typo3/sysext/form/Tests/Unit/Domain/Renderable/Fixtures/TestingRenderable.php b/typo3/sysext/form/Tests/Unit/Domain/Renderable/Fixtures/TestingRenderable.php
new file mode 100644
index 000000000000..4b30942a1e3d
--- /dev/null
+++ b/typo3/sysext/form/Tests/Unit/Domain/Renderable/Fixtures/TestingRenderable.php
@@ -0,0 +1,27 @@
+<?php
+
+declare(strict_types=1);
+
+/*
+ * This file is part of the TYPO3 CMS project.
+ *
+ * It is free software; you can redistribute it and/or modify it under
+ * the terms of the GNU General Public License, either version 2
+ * of the License, or any later version.
+ *
+ * For the full copyright and license information, please read the
+ * LICENSE.txt file that was distributed with this source code.
+ *
+ * The TYPO3 project - inspiring people to share!
+ */
+
+namespace TYPO3\CMS\Form\Tests\Unit\Domain\Renderable\Fixtures;
+
+use TYPO3\CMS\Form\Domain\Model\Renderable\AbstractRenderable;
+
+/**
+ * Testing subclass of the abstract class.
+ */
+final class TestingRenderable extends AbstractRenderable
+{
+}
-- 
GitLab