Testing & Fixtures: How to fill global fields with data? #11717
-
Hi, I am currently working on fixtures for our API tests. The Project Config already sets up a GlobalSet "Global options" with the necessary fields. Now I would like to fill out these fields with dummy data. As I understand the examples in the Craft core, GlobalSetFixture is intended for the setup, i.e. in my example the structure for "Global options". What I'm looking for, however, is a way to fill the global field "globalImprintPageText" with data. I tried using BaseElementFixture and EntryFixture, but my setup always failed. Does anyone have an idea? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
Currently there’s no way to set content to existing elements a la carte using fixtures. The best way to do it would probably be from cms/tests/unit/elements/UserElementTest.php Lines 314 to 343 in cf3f399 |
Beta Was this translation helpful? Give feedback.
Currently there’s no way to set content to existing elements a la carte using fixtures.
The best way to do it would probably be from
_before()
, such as how we’re doing it fromUserElementTest
: (Although in your case you would be fetching the existing global set first, rather than creating a new one.)cms/tests/unit/elements/UserElementTest.php
Lines 314 to 343 in cf3f399