Skip to content

Commit

Permalink
[BUGFIX] Decouple implementations from parent classes (#2187)
Browse files Browse the repository at this point in the history
  • Loading branch information
NamelessCoder authored Oct 24, 2024
1 parent d8cb50b commit baf6013
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 3 deletions.
2 changes: 1 addition & 1 deletion Classes/Backend/BackendLayoutDataProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
use TYPO3\CMS\Backend\View\BackendLayout\DataProviderInterface;
use TYPO3\CMS\Backend\View\BackendLayout\DefaultDataProvider;

class BackendLayoutDataProvider extends DefaultDataProvider implements DataProviderInterface
class BackendLayoutDataProvider implements DataProviderInterface
{
protected ProviderResolver $providerResolver;
protected WorkspacesAwareRecordService $recordService;
Expand Down
8 changes: 6 additions & 2 deletions Classes/Integration/HookSubscribers/DynamicFlexForm.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,10 @@
use TYPO3\CMS\Core\Configuration\FlexForm\FlexFormTools;
use TYPO3\CMS\Core\Utility\GeneralUtility;

class DynamicFlexForm extends FlexFormTools
class DynamicFlexForm
{
protected FlexFormBuilder $flexFormBuilder;
protected FlexFormTools $flexFormTools;

protected static bool $recursed = false;

Expand All @@ -23,6 +24,9 @@ public function __construct()
/** @var FlexFormBuilder $flexFormBuilder */
$flexFormBuilder = GeneralUtility::makeInstance(FlexFormBuilder::class);
$this->flexFormBuilder = $flexFormBuilder;
/** @var FlexFormTools $flexFormTools */
$flexFormTools = GeneralUtility::makeInstance(FlexFormTools::class);
$this->flexFormTools = $flexFormTools;
}

/**
Expand All @@ -41,7 +45,7 @@ public function getDataStructureIdentifierPreProcess(
}
static::$recursed = true;
/** @var string|array $originalIdentifier */
$originalIdentifier = $this->getDataStructureIdentifier(
$originalIdentifier = $this->flexFormTools->getDataStructureIdentifier(
[ 'config' => $GLOBALS['TCA'][$tableName]['columns'][$fieldName]['config']],
$tableName,
$fieldName,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
use FluidTYPO3\Flux\Builder\FlexFormBuilder;
use FluidTYPO3\Flux\Integration\HookSubscribers\DynamicFlexForm;
use FluidTYPO3\Flux\Tests\Unit\AbstractTestCase;
use TYPO3\CMS\Core\Configuration\FlexForm\FlexFormTools;
use TYPO3\CMS\Core\Utility\GeneralUtility;

/**
Expand All @@ -19,6 +20,7 @@
class DynamicFlexFormTest extends AbstractTestCase
{
protected ?FlexFormBuilder $flexFormBuilder = null;
protected ?FlexFormTools $flexFormTools = null;

protected function setUp(): void
{
Expand All @@ -27,7 +29,13 @@ protected function setUp(): void
->disableOriginalConstructor()
->getMock();

$this->flexFormTools = $this->getMockBuilder(FlexFormTools::class)
->onlyMethods(['getDataStructureIdentifier'])
->disableOriginalConstructor()
->getMock();

GeneralUtility::addInstance(FlexFormBuilder::class, $this->flexFormBuilder);
GeneralUtility::addInstance(FlexFormTools::class, $this->flexFormTools);

parent::setUp();
}
Expand All @@ -51,6 +59,7 @@ public function testGetDataStructureIdentifierPreProcessDelegatesToFlexFormBuild
$this->flexFormBuilder->method('resolveDataStructureIdentifier')
->with()
->willReturn(['foo' => 'bar']);
$this->flexFormTools->method('getDataStructureIdentifier')->willReturn('{"id": 123}');
$output = $subject->getDataStructureIdentifierPreProcess([], 'table', 'field', ['uid' => 1]);
self::assertSame(['foo' => 'bar'], $output);
}
Expand Down

0 comments on commit baf6013

Please sign in to comment.