I set up codeception tests and copied some fixtures from Craft repository.

Within unit test class, i can access fixtures data of elements, for example for EntryFixture. I use this code, where entries is key of EntryFixture registered inside _fixtures() method:

$entries = $this->tester->grabFixture('entries');

This dumps first entry from fixture datafile.

Hovewer, i cannot get fixtures data of non-elements, with fixtures extending ActiveFixture class, like SitesFixture.

According to yii and codeception docs, this should be done like this, by adding second param to grabFixture which will act as key in datafile array:

$sites = $this->tester->grabFixture('sites', 0);

This however always returns null. How can i access such fixture data?

Or do i just need to access objects created by fixtures using regular Craft methods, like Craft::$app->getSites()->getSiteById for example?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.