Problem/Motivation
We need to test PropTypeInterface::normalize() function
We already have a test for LinksPropType : LinksPropTypeNormalizationTest
But this is not enough
Proposed resolution
At least, add similar tests for the 2 other prop types using the mehtod:
- SlotPropType
- AttributesPropType
If possible, fix an issue in LinksPropTypeNormalizationTest where 2 tests where disabled (commented) because they need the service container:
"Standardized structure, flat, only primitives" => self::standardizedFlatPrimitives(),
// "Standardized structure, flat, with objects" => self::standardizedFlatObjects(),
"Breadcrumb structure, as generated by the core service" => self::breadcrumb(),
"Mini pager, as generated by the Views module" => self::viewsMiniPager(),
"Pager's pages, as generated by the Views module" => self::pagerPages(),
"Pager's navigation links, as generated by the Views module" => self::pagesNavigationLinks(),
// "Menu, as generated by the Menu module" => self::menu(),
"Where link_attributes is already manually set" => self::linkAttributes(),
Do you know how to use teh service container in such tests?
Issue fork ui_patterns-3469665
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #2
oldebComment #3
oldebIf you need the service container then you need a KernelTest instead of a UnitTest.
Should I change the whole test class into a KernelTest or should I split the it into 2 tests (1 unit test and one kernel test) ?
Comment #4
pdureau commentedSingle KernelTest. Maybe all 3 tests can become kernel tests (to keep them in the same folder)
Comment #5
oldebThe issue in fact is that the container is called from a static method which is not aware of the container.
What I think we should do :
Comment #6
pdureau commentedCareful, i did some changes in https://git.drupalcode.org/project/ui_patterns/-/blob/a1cba969c36e3891ab...
https://git.drupalcode.org/project/ui_patterns/-/merge_requests/188/diffs
Comment #7
oldebComment #8
pdureau commentedComment #9
just_like_good_vibesComment #10
pdureau commentedPostponed because I am doing that first #3474822: [2.0.0-beta4] Normalize attributes values. and introduce the unit tests for URL, Attributes, and many other prop types.
So, this ticket will keep the following tasks
Comment #11
pdureau commentedThere are 3 unit tests:
However, they don't cover everything because of limitation of Unit tests. For example:
Also, we need tests for
SlotPropType::normalize()Comment #12
pdureau commentedComment #13
pdureau commentedComment #14
oldebComment #15
pdureau commentedMikael, because you have added
tests/src/Kernel/PropTypesNormalizationTest.phpin beta6Do we still need?
Can we consolidate those in a single collection of kernel tests?
Mikael's answer:
Can we have a
tests/src/Kernel/PropTypeNormalization/folder, with one file per prop type? a bit like what have been done intests/src/Unit/PropTypeNormalization/?Comment #18
just_like_good_vibesdid some massive work over there, please review :)
i think we should improve two prop types : ListPropType and NumberPropType.
A the moment, their normalization is not strong enough imho.
let's tackle this in separate tickets.
Comment #19
pdureau commentedOK for me to be merged.
However, some tests are still commented:
https://git.drupalcode.org/project/ui_patterns/-/blob/cb853ea951afe89b24...
It would be great to uncomment before merging
Comment #20
just_like_good_vibesok i added them :)
Comment #22
pdureau commented