forked from FluidTYPO3/flux
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[TASK] Cover FormEngine integration scope with tests
- Loading branch information
1 parent
34654c0
commit 039af27
Showing
24 changed files
with
781 additions
and
57 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
56 changes: 56 additions & 0 deletions
56
Tests/Unit/Integration/Event/AfterLocalizationControllerColumnsEventListenerTest.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
<?php | ||
namespace FluidTYPO3\Flux\Tests\Unit\Integration\Event; | ||
|
||
/* | ||
* This file is part of the FluidTYPO3/Flux project under GPLv2 or later. | ||
* | ||
* For the full copyright and license information, please read the | ||
* LICENSE.md file that was distributed with this source code. | ||
*/ | ||
|
||
use FluidTYPO3\Flux\Integration\Event\AfterLocalizationControllerColumnsEventListener; | ||
use FluidTYPO3\Flux\Tests\Unit\AbstractTestCase; | ||
use TYPO3\CMS\Backend\Controller\Event\AfterPageColumnsSelectedForLocalizationEvent; | ||
use TYPO3\CMS\Backend\View\BackendLayout\BackendLayout; | ||
|
||
class AfterLocalizationControllerColumnsEventListenerTest extends AbstractTestCase | ||
{ | ||
protected function setUp(): void | ||
{ | ||
parent::setUp(); | ||
|
||
if (!class_exists(AfterPageColumnsSelectedForLocalizationEvent::class)) { | ||
self::markTestSkipped('Event implementation not available on current TYPO3 version'); | ||
} | ||
} | ||
|
||
/** | ||
* @dataProvider getTestModifyColumnsManifestTestValues | ||
*/ | ||
public function testModifyColumnsManifest(array $expectedColumns, array $expectedColumnList, array $records): void | ||
{ | ||
$columns = []; | ||
$columnList = []; | ||
$backendLayout = $this->getMockBuilder(BackendLayout::class)->disableOriginalConstructor()->getMock(); | ||
$subject = new AfterLocalizationControllerColumnsEventListener(); | ||
$event = new AfterPageColumnsSelectedForLocalizationEvent( | ||
$columns, | ||
$columnList, | ||
$backendLayout, | ||
$records, | ||
[] | ||
); | ||
$subject->modifyColumnsManifest($event); | ||
self::assertSame($expectedColumns, $event->getColumns(), 'Columns do not match'); | ||
self::assertSame($expectedColumnList, $event->getColumnList(), 'Column list does not match'); | ||
} | ||
|
||
public function getTestModifyColumnsManifestTestValues(): array | ||
{ | ||
return [ | ||
'without records' => [[], [], []], | ||
'records only in page columns' => [[], [], [['uid' => 123, 'colPos' => 1]]], | ||
'records in nested content' => [[12301 => 'Nested'], ['12301'], [['uid' => 123, 'colPos' => 12301]]], | ||
]; | ||
} | ||
} |
41 changes: 41 additions & 0 deletions
41
Tests/Unit/Integration/FormEngine/ColumnPositionNodeTest.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
<?php | ||
namespace FluidTYPO3\Flux\Tests\Unit\Integration\FormEngine; | ||
|
||
/* | ||
* This file is part of the FluidTYPO3/Flux project under GPLv2 or later. | ||
* | ||
* For the full copyright and license information, please read the | ||
* LICENSE.md file that was distributed with this source code. | ||
*/ | ||
|
||
use FluidTYPO3\Flux\Integration\FormEngine\ColumnPositionNode; | ||
use FluidTYPO3\Flux\Integration\FormEngine\UserFunctions; | ||
use FluidTYPO3\Flux\Tests\Unit\AbstractTestCase; | ||
use TYPO3\CMS\Backend\Form\NodeFactory; | ||
use TYPO3\CMS\Core\Utility\GeneralUtility; | ||
|
||
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(); | ||
$subject->method('initializeResultArray')->willReturn([]); | ||
|
||
$userFunction = $this->getMockBuilder(UserFunctions::class) | ||
->setMethods(['renderColumnPositionField']) | ||
->disableOriginalConstructor() | ||
->getMock(); | ||
$userFunction->method('renderColumnPositionField')->willReturn('html'); | ||
GeneralUtility::addInstance(UserFunctions::class, $userFunction); | ||
|
||
$output = $subject->render(); | ||
self::assertSame(['html' => 'html'], $output); | ||
} | ||
} |
45 changes: 45 additions & 0 deletions
45
Tests/Unit/Integration/FormEngine/ContentTypeValidatorNodeTest.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
<?php | ||
namespace FluidTYPO3\Flux\Tests\Unit\Integration\FormEngine; | ||
|
||
/* | ||
* This file is part of the FluidTYPO3/Flux project under GPLv2 or later. | ||
* | ||
* For the full copyright and license information, please read the | ||
* LICENSE.md file that was distributed with this source code. | ||
*/ | ||
|
||
use FluidTYPO3\Flux\Content\ContentTypeValidator; | ||
use FluidTYPO3\Flux\Integration\FormEngine\ContentTypeValidatorNode; | ||
use FluidTYPO3\Flux\Tests\Unit\AbstractTestCase; | ||
use TYPO3\CMS\Backend\Form\NodeFactory; | ||
use TYPO3\CMS\Core\Utility\GeneralUtility; | ||
|
||
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(); | ||
$subject->method('initializeResultArray')->willReturn([]); | ||
|
||
$userFunction = $this->getMockBuilder(ContentTypeValidator::class) | ||
->setMethods(['validateContentTypeRecord']) | ||
->disableOriginalConstructor() | ||
->getMock(); | ||
$userFunction->expects(self::once()) | ||
->method('validateContentTypeRecord') | ||
->with($data['parameterArray'] + ['row' => $data['databaseRow']]) | ||
->willReturn('html'); | ||
GeneralUtility::addInstance(ContentTypeValidator::class, $userFunction); | ||
|
||
$output = $subject->render(); | ||
self::assertSame(['html' => 'html'], $output); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
<?php | ||
namespace FluidTYPO3\Flux\Tests\Unit\Integration\FormEngine; | ||
|
||
/* | ||
* This file is part of the FluidTYPO3/Flux project under GPLv2 or later. | ||
* | ||
* For the full copyright and license information, please read the | ||
* LICENSE.md file that was distributed with this source code. | ||
*/ | ||
|
||
use FluidTYPO3\Flux\Integration\FormEngine\HtmlOutputNode; | ||
use FluidTYPO3\Flux\Integration\FormEngine\UserFunctions; | ||
use FluidTYPO3\Flux\Tests\Unit\AbstractTestCase; | ||
use TYPO3\CMS\Backend\Form\NodeFactory; | ||
use TYPO3\CMS\Core\Utility\GeneralUtility; | ||
|
||
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([]); | ||
|
||
$userFunction = $this->getMockBuilder(UserFunctions::class) | ||
->setMethods(['renderHtmlOutputField']) | ||
->disableOriginalConstructor() | ||
->getMock(); | ||
$userFunction->method('renderHtmlOutputField')->willReturn('html'); | ||
GeneralUtility::addInstance(UserFunctions::class, $userFunction); | ||
|
||
$output = $subject->render(); | ||
self::assertSame(['html' => 'html'], $output); | ||
} | ||
} |
Oops, something went wrong.