4

Background: I have experience with vanilla PHPUnit testing of projects, but this the first attempt at both testing a Craft project and using Codeception for testing.

Case: I have a section of type structure of maximum 2 levels deep. The URL I want to test, i.e. /some-section/some-entry shows content of both the parent and children, which is aggregated through some business logic.

Problem: I am having trouble setting this up in fixture files. I created a fixture class the extends the EntryFixture class. But I have not figured out how to create a data file that creates the parent-child relation.

When I go through the code, that relationship would normally be made through setting the newParentId. But no ID exists. I have not figured out a way to define this in the data file. For now I am going to use two fixture classes, one for the parent entries, and one for the child entries. In the fixture class for the child entries I then overrule the getData-method so that I can resolve the actual parentId by querying the database for the previously loaded fixture records.

However this does not seem the cleanest way and I wonder if I am missing the obvious solution here?

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.