78217[TASK] Migrate ColumnMapFactory unit to functional tests
Commit message
Review
-
Code review CR +2 Done
- Stefan Bürk +2
- Alexander Schnitzler +1
- Christian Kuhn +1
-
Verified V +2 Done
- Stefan Bürk +2
- Oliver Klee +1
- Alexander Schnitzler +1
- Christian Kuhn +1
- core-ci +1 CI
Issues 1
Files 3
- typo3/sysext/extbase/Tests/Functional/Persistence/Generic/Mapper/Fixtures/ColumnMapFactoryEntityFixture.phpnew+37 −0
- typo3/sysext/extbase/Tests/Functional/Persistence/Generic/Mapper/ColumnMapFactoryTest.php8new+516 −0
- typo3/sysext/extbase/Tests/Unit/Persistence/Generic/Mapper/ColumnMapFactoryTest.phpdeleted+0 −425
Review log 2125
-
Alexander Schnitzler uploaded patch set 1 03/22/23, 18:41
-
Alexander Schnitzler wrote 03/22/23, 18:42
Topic set to extbase -
Alexander Schnitzler commented on patch set 1 03/22/23, 18:49
Benefits of this change: Subject under test is no longer mocked. Complete input/output test. Makes it possible to refactor the internal logic in follow-up patches while keeping test coverage as safety net. -
core-ci voted on patch set 1 V +1 03/22/23, 18:49 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/39409
-
Benni Mack voted on patch set 1 V +1 CR +1 03/22/23, 20:39
-
Oliver Klee voted on patch set 1 V +1 03/22/23, 21:10
-
Stefan Bürk commented on patch set 1 03/23/23, 00:27
ColumnMapFactoryTest.php:444That is basically the same code as in the test method before, only commented out. The only difference I can is another assertment. Why should the same setup return another result for the same method call lateron? Maybe copied wrong code as outcommetd from old unit test here ? -
Alexander Schnitzler commented on patch set 1 03/23/23, 05:00
ColumnMapFactoryTest.php:444Reply> Why should the same setup return another result for the same method call lateron? Only if GLOBALS['TCA'] would be modified in this test setup, which I don't want to do. This converted code tells me, as the one who is working on it, what to refactor next: Remove access to global state. Until this cannot be achieved without mocking, the unit test is left in place. We can change the commented out test if you think it has any benefits but this code will only live a short time anyway. As soon as global state is passed from the outside, all those tests here will change eventually. -
Alexander Schnitzler uploaded patch set 2
CR +1V +103/23/23, 09:29 -
Alexander Schnitzler commented on patch set 2 03/23/23, 09:31
ColumnMapFactoryTest.php:444ReplyI moved the test back the unit test suite. Goal is to not have ColumnMapFactory access `$GLOBALS['TCA']`. It only does so because `ColumnMap` holds information that is not found in the column definition of the TCA but of the control section. Refactoring will be to remove pid information from the `ColumnMap` into `DataMap` or a new class. -
Christian Kuhn commented on patch set 1 CR -1 03/23/23, 09:35
on it. -
core-ci voted on patch set 2 V +1 03/23/23, 09:37 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/39447
-
Christian Kuhn commented on patch set 2 03/23/23, 09:48
ColumnMapFactoryTest.php:444ReplyI don't agree to skip the test, just because we don't want to override TCA in a functional: The functionals are designed to deal with this, we're for instance fiddling with globals-tca in DataHandler Scenario tests as well in a couple of places. I agree that isn't beautiful, but it can be done. Also, `$GLOBALS['TCA']` is the longest living global we have: while all others are shrinking / being removed over time, there is still no good substitution for TCA on the horizon. We shouldn't work forward towards something we don't even have a concept at hand right now. As such, I'll now enable the test in question and will remove the unit test that keeps this last one: I rate it higher that everything is moved towards functionals here, the debt to set globals tca for a single test is smaller. In case this class gets the dependency to TCA resolved soon: Even better, even though I don't think that should be a priority since access to globals TCA is literally "everywhere" and accepted as the current way to go, until we really add the huge effort to change this at some point in the future. -
Alexander Schnitzler commented on patch set 2 03/23/23, 09:53
ColumnMapFactoryTest.php:444ReplyFine with the change. > In case this class gets the dependency to TCA resolved soon: Even better, even though I don't think that should be a priority since access to globals TCA is literally "everywhere" and accepted as the current way to go, until we really add the huge effort to change this at some point in the future. The dependency to TCA will be removed from the ColumnMapFactory and only exists in DataMapFactory afterwards. I don't aim to get rid of globals for good, only the ColumnMap should be affected by it any more because it should only deal with the column configuration and not with the control section. A follow-up patch set is quickly done. -
Christian Kuhn uploaded patch set 3
V +103/23/23, 09:53 -
Alexander Schnitzler commented on patch set 3 03/23/23, 10:01
ColumnMapFactoryTest.php:431I think this foo->bar assignment is a bit misleading. `getControlSection()` only evaluates if `$GLOBALS['TCA']['tx_myextension_mm']['ctrl']` exists and is an array. If we want to have a test for this whole case, let's implement it properly, please. -
core-ci voted on patch set 3 V +1 03/23/23, 10:01 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/39450
-
Christian Kuhn uploaded patch set 4
V +103/23/23, 10:02 -
Christian Kuhn commented on patch set 3 03/23/23, 10:03
ColumnMapFactoryTest.php:431Replyah good point. just setting it to empty array now. -
Alexander Schnitzler commented on patch set 4 V +1 CR +1 03/23/23, 10:03
ColumnMapFactoryTest.php:431ReplyDone -
Christian Kuhn voted on patch set 4 V +1 CR +1 03/23/23, 10:04
-
Oliver Klee voted on patch set 4 V +1 03/23/23, 10:06
-
core-ci voted on patch set 4 V +1 03/23/23, 10:11 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/39452
-
Stefan Bürk voted on patch set 4 V +2 CR +2 03/23/23, 10:12
-
Stefan Bürk merged patch set 5 03/23/23, 10:12