Skip to content

Commit

Permalink
[TASK] Prepare Node implementation tests for v13 operation (#2219)
Browse files Browse the repository at this point in the history
  • Loading branch information
NamelessCoder authored Jan 23, 2025
1 parent 9f02f1c commit 6e41674
Show file tree
Hide file tree
Showing 6 changed files with 80 additions and 35 deletions.
22 changes: 14 additions & 8 deletions Tests/Unit/Integration/FormEngine/ClearValueWizardTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,19 +11,25 @@
use FluidTYPO3\Flux\Integration\FormEngine\ClearValueWizard;
use FluidTYPO3\Flux\Tests\Unit\AbstractTestCase;
use TYPO3\CMS\Backend\Form\NodeFactory;
use TYPO3\CMS\Core\Utility\VersionNumberUtility;

class ClearValueWizardTest extends AbstractTestCase
{
public function test(): void
{
$data = [
'elementBaseName' => '[foo][bar][baz]',
];
$nodeFactory = $this->getMockBuilder(NodeFactory::class)->disableOriginalConstructor()->getMock();
$subject = $this->getMockBuilder(ClearValueWizard::class)
->onlyMethods(['translate'])
->setConstructorArgs([$nodeFactory, $data])
->getMock();
$data = ['elementBaseName' => '[foo][bar][baz]'];
if (version_compare(VersionNumberUtility::getCurrentTypo3Version(), '13.4', '>=')) {
$subject = $this->getMockBuilder(ClearValueWizard::class)
->onlyMethods(['translate'])
->getMock();
$subject->setData($data);
} else {
$nodeFactory = $this->getMockBuilder(NodeFactory::class)->disableOriginalConstructor()->getMock();
$subject = $this->getMockBuilder(ClearValueWizard::class)
->onlyMethods(['translate'])
->setConstructorArgs([$nodeFactory, $data])
->getMock();
}

$result = $subject->render();

Expand Down
19 changes: 14 additions & 5 deletions Tests/Unit/Integration/FormEngine/ColumnPositionNodeTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,19 +13,28 @@
use FluidTYPO3\Flux\Tests\Unit\AbstractTestCase;
use TYPO3\CMS\Backend\Form\NodeFactory;
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Core\Utility\VersionNumberUtility;

class ColumnPositionNodeTest extends AbstractTestCase
{
public function testRender(): void
{
$nodeFactory = $this->getMockBuilder(NodeFactory::class)->disableOriginalConstructor()->getMock();
$data = [
'parameterArray' => [],
];
$subject = $this->getMockBuilder(ColumnPositionNode::class)
->setMethods(['initializeResultArray'])
->setConstructorArgs([$nodeFactory, $data])
->getMock();
if (version_compare(VersionNumberUtility::getCurrentTypo3Version(), '13.4', '>=')) {
$subject = $this->getMockBuilder(ColumnPositionNode::class)
->setMethods(['initializeResultArray'])
->getMock();
$subject->setData($data);
} else {
$nodeFactory = $this->getMockBuilder(NodeFactory::class)->disableOriginalConstructor()->getMock();
$subject = $this->getMockBuilder(ColumnPositionNode::class)
->setMethods(['initializeResultArray'])
->setConstructorArgs([$nodeFactory, $data])
->getMock();
}

$subject->method('initializeResultArray')->willReturn([]);

$userFunction = $this->getMockBuilder(UserFunctions::class)
Expand Down
18 changes: 13 additions & 5 deletions Tests/Unit/Integration/FormEngine/ContentTypeValidatorNodeTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,20 +13,28 @@
use FluidTYPO3\Flux\Tests\Unit\AbstractTestCase;
use TYPO3\CMS\Backend\Form\NodeFactory;
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Core\Utility\VersionNumberUtility;

class ContentTypeValidatorNodeTest extends AbstractTestCase
{
public function testRender(): void
{
$nodeFactory = $this->getMockBuilder(NodeFactory::class)->disableOriginalConstructor()->getMock();
$data = [
'parameterArray' => ['foo' => 'bar'],
'databaseRow' => ['uid' => 123],
];
$subject = $this->getMockBuilder(ContentTypeValidatorNode::class)
->setMethods(['initializeResultArray'])
->setConstructorArgs([$nodeFactory, $data])
->getMock();
if (version_compare(VersionNumberUtility::getCurrentTypo3Version(), '13.4', '>=')) {
$subject = $this->getMockBuilder(ContentTypeValidatorNode::class)
->setMethods(['initializeResultArray'])
->getMock();
$subject->setData($data);
} else {
$nodeFactory = $this->getMockBuilder(NodeFactory::class)->disableOriginalConstructor()->getMock();
$subject = $this->getMockBuilder(ContentTypeValidatorNode::class)
->setMethods(['initializeResultArray'])
->setConstructorArgs([$nodeFactory, $data])
->getMock();
}
$subject->method('initializeResultArray')->willReturn([]);

$userFunction = $this->getMockBuilder(ContentTypeValidator::class)
Expand Down
19 changes: 13 additions & 6 deletions Tests/Unit/Integration/FormEngine/HtmlOutputNodeTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,21 +13,28 @@
use FluidTYPO3\Flux\Tests\Unit\AbstractTestCase;
use TYPO3\CMS\Backend\Form\NodeFactory;
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Core\Utility\VersionNumberUtility;

class HtmlOutputNodeTest extends AbstractTestCase
{
public function testRender(): void
{
$nodeFactory = $this->getMockBuilder(NodeFactory::class)->disableOriginalConstructor()->getMock();
$data = [
'parameterArray' => ['foo' => 'bar'],
'databaseRow' => ['uid' => 123],
];
$subject = $this->getMockBuilder(HtmlOutputNode::class)
->setMethods(['initializeResultArray'])
->setConstructorArgs([$nodeFactory, $data])
->getMock();
$subject->method('initializeResultArray')->willReturn([]);
if (version_compare(VersionNumberUtility::getCurrentTypo3Version(), '13.4', '>=')) {
$subject = $this->getMockBuilder(HtmlOutputNode::class)
->onlyMethods(['initializeResultArray'])
->getMock();
$subject->setData($data);
} else {
$nodeFactory = $this->getMockBuilder(NodeFactory::class)->disableOriginalConstructor()->getMock();
$subject = $this->getMockBuilder(HtmlOutputNode::class)
->onlyMethods(['initializeResultArray'])
->setConstructorArgs([$nodeFactory, $data])
->getMock();
}

$userFunction = $this->getMockBuilder(UserFunctions::class)
->onlyMethods(['renderHtmlOutputField'])
Expand Down
19 changes: 13 additions & 6 deletions Tests/Unit/Integration/FormEngine/ProtectValueWizardTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@
* LICENSE.md file that was distributed with this source code.
*/

use FluidTYPO3\Flux\Integration\FormEngine\ClearValueWizard;
use FluidTYPO3\Flux\Integration\FormEngine\ProtectValueWizard;
use FluidTYPO3\Flux\Tests\Unit\AbstractTestCase;
use TYPO3\CMS\Backend\Form\NodeFactory;
use TYPO3\CMS\Core\Utility\VersionNumberUtility;

class ProtectValueWizardTest extends AbstractTestCase
{
Expand All @@ -20,11 +20,18 @@ public function test(): void
$data = [
'elementBaseName' => '[foo][bar][baz]',
];
$nodeFactory = $this->getMockBuilder(NodeFactory::class)->disableOriginalConstructor()->getMock();
$subject = $this->getMockBuilder(ProtectValueWizard::class)
->onlyMethods(['translate'])
->setConstructorArgs([$nodeFactory, $data])
->getMock();
if (version_compare(VersionNumberUtility::getCurrentTypo3Version(), '13.4', '>=')) {
$subject = $this->getMockBuilder(ProtectValueWizard::class)
->onlyMethods(['translate'])
->getMock();
$subject->setData($data);
} else {
$nodeFactory = $this->getMockBuilder(NodeFactory::class)->disableOriginalConstructor()->getMock();
$subject = $this->getMockBuilder(ProtectValueWizard::class)
->onlyMethods(['translate'])
->setConstructorArgs([$nodeFactory, $data])
->getMock();
}

$result = $subject->render();

Expand Down
18 changes: 13 additions & 5 deletions Tests/Unit/Integration/FormEngine/TemplateSourceDumperNodeTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,20 +13,28 @@
use FluidTYPO3\Flux\Tests\Unit\AbstractTestCase;
use TYPO3\CMS\Backend\Form\NodeFactory;
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Core\Utility\VersionNumberUtility;

class TemplateSourceDumperNodeTest extends AbstractTestCase
{
public function testRender(): void
{
$nodeFactory = $this->getMockBuilder(NodeFactory::class)->disableOriginalConstructor()->getMock();
$data = [
'parameterArray' => ['foo' => 'bar'],
'databaseRow' => ['uid' => 123],
];
$subject = $this->getMockBuilder(TemplateSourceDumperNode::class)
->setMethods(['initializeResultArray'])
->setConstructorArgs([$nodeFactory, $data])
->getMock();
if (version_compare(VersionNumberUtility::getCurrentTypo3Version(), '13.4', '>=')) {
$subject = $this->getMockBuilder(TemplateSourceDumperNode::class)
->setMethods(['initializeResultArray'])
->getMock();
$subject->setData($data);
} else {
$nodeFactory = $this->getMockBuilder(NodeFactory::class)->disableOriginalConstructor()->getMock();
$subject = $this->getMockBuilder(TemplateSourceDumperNode::class)
->setMethods(['initializeResultArray'])
->setConstructorArgs([$nodeFactory, $data])
->getMock();
}
$subject->method('initializeResultArray')->willReturn([]);

$userFunction = $this->getMockBuilder(ContentTypeFluxTemplateDumper::class)
Expand Down

0 comments on commit 6e41674

Please sign in to comment.