Review main Abandoned

70489[TASK] Increase unit test coverage of Fluid classes

Claus Due CR 0 V 0 Hard +640 −5 updated 12/06/21, 15:05

Commit message

Increases the unit test coverage of Fluid classes, with
the exception of ViewHelper classes which are to be
covered with functional tests instead.

Review

  • Code review CR 0
  • Verified V 0

Issues 1

Files 9

Review log 1419

  1. Claus Due uploaded patch set 1 08/12/21, 13:45

  2. Wouter Wolters commented on patch set 1 08/12/21, 13:51

    ViewHelperResolverTest.php:98 Unresolved

    empty line
  3. 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

  4. Claus Due uploaded patch set 2 08/12/21, 14:09

  5. Christian Kuhn commented on patch set 2 08/12/21, 14:32

    FluidTemplateCacheTest.php:34

    please avoid changing global state in unit tests. beside: defineBaseConstants() is called by unit test bootstrap, so LF *does* exist.

    RenderingContextTest.php:85

    i 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:81

    smells as if those heavily mocking tests would be better suited as functional tests.

    TemplateViewTest.php:82 Unresolved

    turn into functionals to avoid mocking?
  6. 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

  7. Claus Due uploaded patch set 3 08/13/21, 08:36

  8. Claus Due commented on patch set 3 08/13/21, 08:36

    FluidTemplateCacheTest.php:34 Reply

    Ack

    RenderingContextTest.php:85 Reply

    Ack - 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:81 Reply

    I 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.
  9. 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

  10. Claus Due uploaded patch set 4 08/13/21, 08:42

  11. 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

  12. Christian Kuhn commented on patch set 4 08/13/21, 09:11

    StandaloneViewTest.php:81 Reply

    Why 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?
  13. Claus Due commented on patch set 4 08/13/21, 09:33

    StandaloneViewTest.php:81 Reply 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 ;)
  14. Claus Due uploaded patch set 5 08/13/21, 09:48

  15. 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

  16. Christian Kuhn commented on patch set 5 10/20/21, 01:39

    how to continue here?
  17. Benni Mack wrote 11/29/21, 10:11

    Change destination moved from master to main
  18. 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.
  19. Christian Kuhn abandoned the change 12/06/21, 15:05