-
Notifications
You must be signed in to change notification settings - Fork 653
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
We have a decent test coverage of view helpers, especially those within ext:fluid. This is an important asset and we're sure all main functionality works. Most of the tests rely on ViewHelperBaseTestcase from the testing framework. This class prepares the main mocking of view helper dependencies. Reading the code it becomes obvious that this approach is kinda unfortunate: View helpers are part of a bigger system - they have some general dependencies like the rendering context, the request and render children. This leads to a mocking party in many unit tests, making the test goal hard to understand and follow. The mock preparations and assumptions of internal handling actively block further separation of concern patches within ext:fluid since the ViewHelperBaseTestcase breaks all the time. The patch refactors all unit tests that extend ViewHelperBaseTestcase towards functional tests: Most of them simply create a StandaloneView, feed a template string for the specific view helper and string compare the render result. Some FE related VH tests additionally set up a full frontend and retrieve a rendered fluid view as sub request. This makes the tests much easier to read, follow and understand. The functional tests are now good examples to show the various features of single VH's. Change-Id: I6c5d4eeb0c79ba66a18398a5623a591381a6d707 Resolves: #94580 Releases: master Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/69857 Tested-by: core-ci <typo3@b13.com> Tested-by: Jochen <rothjochen@gmail.com> Tested-by: Benni Mack <benni@typo3.org> Tested-by: Christian Kuhn <lolli@schwarzbu.ch> Reviewed-by: Jochen <rothjochen@gmail.com> Reviewed-by: Benni Mack <benni@typo3.org> Reviewed-by: Christian Kuhn <lolli@schwarzbu.ch>
- Loading branch information
Showing
116 changed files
with
4,488 additions
and
8,444 deletions.
There are no files selected for viewing
47 changes: 47 additions & 0 deletions
47
typo3/sysext/core/Tests/Functional/ViewHelpers/IconForRecordViewHelperTest.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,47 @@ | ||
<?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\Core\Tests\Functional\ViewHelpers; | ||
|
||
use Prophecy\Argument; | ||
use TYPO3\CMS\Core\Imaging\Icon; | ||
use TYPO3\CMS\Core\Imaging\IconFactory; | ||
use TYPO3\CMS\Core\Utility\GeneralUtility; | ||
use TYPO3\CMS\Fluid\View\StandaloneView; | ||
use TYPO3\TestingFramework\Core\Functional\FunctionalTestCase; | ||
|
||
class IconForRecordViewHelperTest extends FunctionalTestCase | ||
{ | ||
/** | ||
* @test | ||
*/ | ||
public function renderRendersIconCallingIconFactoryAccordingToGivenArguments(): void | ||
{ | ||
$iconProphecy = $this->prophesize(Icon::class); | ||
$iconProphecy->render(Argument::any())->willReturn('icon html'); | ||
$iconFactoryProphecy = $this->prophesize(IconFactory::class); | ||
$iconFactoryProphecy->getIconForRecord(Argument::cetera())->willReturn($iconProphecy->reveal()); | ||
GeneralUtility::addInstance(IconFactory::class, $iconFactoryProphecy->reveal()); | ||
|
||
$view = new StandaloneView(); | ||
$view->setTemplateSource('<core:iconForRecord table="tt_content" row="{uid: 123}" size="large" alternativeMarkupIdentifier="inline" />'); | ||
$view->render(); | ||
|
||
$iconFactoryProphecy->getIconForRecord('tt_content', ['uid' => 123], Icon::SIZE_LARGE)->shouldHaveBeenCalled(); | ||
$iconProphecy->render('inline')->shouldHaveBeenCalled(); | ||
} | ||
} |
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
80 changes: 0 additions & 80 deletions
80
typo3/sysext/core/Tests/Unit/ViewHelpers/IconForRecordViewHelperTest.php
This file was deleted.
Oops, something went wrong.
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
2 changes: 1 addition & 1 deletion
2
typo3/sysext/fluid/Tests/Functional/Fixtures/Extensions/fluid_test/README.md
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 |
---|---|---|
@@ -1,2 +1,2 @@ | ||
# Fluid Rendering Test Extension for TYPO3 [![Build Status](https://travis-ci.org/helhum/fluid_test.svg?branch=master)](https://travis-ci.org/helhum/fluid_test) | ||
# Fluid rendering test extension, used in various fluid functional tests | ||
|
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
Binary file added
BIN
+22.3 KB
typo3/sysext/fluid/Tests/Functional/Fixtures/ViewHelpers/ImageViewHelperTest.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
File renamed without changes.
File renamed without changes
File renamed without changes
File renamed without changes.
Oops, something went wrong.