Skip to content

Testing & Fixtures: How to fill global fields with data? #11717

Answered by brandonkelly
gddotorg asked this question in Q&A
Discussion options

You must be logged in to vote

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 from UserElementTest: (Although in your case you would be fetching the existing global set first, rather than creating a new one.)

protected function _before(): void
{
parent::_before();
$this->activeUser = new User(
[
'active' => true,
'firstName' => 'active',
'lastName' => 'user',
'username' => 'activeUser',
'email' => 'active@user.com',
'password' => '$2a$13$5j8bSRoKQZipjtIg6FXWR.k…

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by brandonkelly
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants