70489[TASK] Increase unit test coverage of Fluid classes
Commit message
Review
-
Code review CR 0
-
Verified V 0
Issues 1
Files 9
- typo3/sysext/fluid/Classes/View/AbstractTemplateView.php+2 −4
- typo3/sysext/fluid/Tests/Unit/Core/Cache/FluidTemplateCacheTest.php2+14 −1
- typo3/sysext/fluid/Tests/Unit/Core/Rendering/RenderingContextTest.php2+133 −0
- typo3/sysext/fluid/Tests/Unit/Core/ViewHelper/ViewHelperResolverFactoryTest.phpnew+41 −0
- typo3/sysext/fluid/Tests/Unit/Core/ViewHelper/ViewHelperResolverTest.php1+44 −0
- typo3/sysext/fluid/Tests/Unit/View/AbstractTemplateViewTest.php+128 −0
- typo3/sysext/fluid/Tests/Unit/View/StandaloneViewTest.php4new+148 −0
- typo3/sysext/fluid/Tests/Unit/View/TemplatePathsTest.php+14 −0
- typo3/sysext/fluid/Tests/Unit/View/TemplateViewTest.php1new+116 −0
Review log 1419
-
Claus Due uploaded patch set 1 08/12/21, 13:45
-
Wouter Wolters commented on patch set 1 08/12/21, 13:51
-
core-ci voted on patch set 1 V -1 08/12/21, 13:54 Core CI is not happy: https://gitlab.typo3.org/typo3/CI/cms/-/pipelines/14741
-
Claus Due uploaded patch set 2 08/12/21, 14:09
-
Christian Kuhn commented on patch set 2 08/12/21, 14:32
FluidTemplateCacheTest.php:34please avoid changing global state in unit tests. beside: defineBaseConstants() is called by unit test bootstrap, so LF *does* exist.RenderingContextTest.php:85i don't understand the point of this test. what is actually tested here? also looks like a hard whitebox test working heavily with internal knowledge. maybe drop?StandaloneViewTest.php:81smells as if those heavily mocking tests would be better suited as functional tests.TemplateViewTest.php:82Unresolvedturn into functionals to avoid mocking? -
core-ci voted on patch set 2 V -1 08/12/21, 14:38 Core CI is not happy: https://gitlab.typo3.org/typo3/CI/cms/-/pipelines/14754
-
Claus Due uploaded patch set 3 08/13/21, 08:36
-
Claus Due commented on patch set 3 08/13/21, 08:36
FluidTemplateCacheTest.php:34ReplyAckRenderingContextTest.php:85ReplyAck - was intended to assert that the setters were called, but this is of course a chicken/egg problem because expectations cannot be stated *after* the method has been executed and creating the mock immediately executes the method.StandaloneViewTest.php:81ReplyI don't necessarily agree that these are heavy mocks - at most, 4 dependencies are mocked, on average 3 dependencies. A functional test wouldn't be able to assert that the internals of the View classes are delegating correctly and return the expected verdicts based on what's actually going on inside the classes - and this is precisely what I aimed to assert with these tests. Basically, the tests intend to test internal behavior and a functional test would only test external behavior. -
core-ci voted on patch set 3 V -1 08/13/21, 08:40 Core CI is not happy: https://gitlab.typo3.org/typo3/CI/cms/-/pipelines/14895
-
Claus Due uploaded patch set 4 08/13/21, 08:42
-
core-ci voted on patch set 4 V -1 08/13/21, 09:07 Core CI is not happy: https://gitlab.typo3.org/typo3/CI/cms/-/pipelines/14897
-
Christian Kuhn commented on patch set 4 08/13/21, 09:11
StandaloneViewTest.php:81ReplyWhy have a whitebox test then in the first place? Internal magic usually shouldn't be tested. Having a rough look it seems as if a functional could do something like that: new renderingContext(), set controllerActionName and templatePaths on it. new standaloneview(), set the renderingcontext. then ->getTemplatePathAndFilename() and see if your expected paths are returned. -> no mocking, no internal class knowledge, and it's easier to see the intention of the test. what do you think? -
Claus Due commented on patch set 4 08/13/21, 09:33
StandaloneViewTest.php:81Reply Unresolved> Why have a whitebox test then in the first place? Internal magic usually shouldn't be tested. I fundamentally disagree, I strongly believe that internals should in fact be tested (with unit tests) as a way to determine *why* something fails, rather than just determining *if* it fails. Having a functional test does not make a unit test unneceesary, and vice versa. One provides superficial feedback (it works / it doesn't work) while the other provides the explanation why (e.g. the controller name isn't queried from the controller context or isn't passed correctly to the TemplatePaths method, format isn't read and used, etc.). I wouldn't mind having functional tests for these specifics too - but that's not the focus of this patch ;) -
Claus Due uploaded patch set 5 08/13/21, 09:48
-
core-ci voted on patch set 5 V +1 08/13/21, 10:17 Core CI is happy: https://gitlab.typo3.org/typo3/CI/cms/-/pipelines/14917
-
Christian Kuhn commented on patch set 5 10/20/21, 01:39
how to continue here? -
Benni Mack wrote 11/29/21, 10:11
Change destination moved from master to main -
Christian Kuhn commented on patch set 5 12/06/21, 15:05
Will abandon for now - if coverage is raised in this area, it should be done with functional tests. -
Christian Kuhn abandoned the change 12/06/21, 15:05
ViewHelperResolverTest.php:98Unresolved