I can't for the life of me figure out how to setup EntryFixtures in craft to populate with custom fields. I'm using the project config which already has the sections and fields defined in my tests. I'm trying to set a field, gmbId
, that's set on a locations
entry type. Here's my code. I feel like I'm missing something basic here.
codeception.yml
actor: Tester
paths:
tests: tests
log: tests/_output
data: tests/_data
support: tests/_support
envs: tests/_envs
bootstrap: _bootstrap.php
params:
- tests/.env
modules:
config:
\craft\test\Craft:
configFile: "tests/_craft/config/test.php"
entryUrl: "http://host.docker.internal/index.php"
projectConfig: {
folder: "config/project",
reset: true
}
migrations: []
plugins: []
cleanup: true
transaction: true
dbSetup: { clean: true, setupCraft: true }
LocationFixture.php
<?php
namespace tests\fixtures;
use craft\test\fixtures\elements\EntryFixture;
class LocationFixture extends EntryFixture
{
public $dataFile = __DIR__ . '/data/locations.php';
}
locations.php
<?php
return [
[
'sectionId' => $this->sectionIds['locations'],
'typeId' => $this->typeIds['locations']['locations'],
'title' => 'Location 1',
'gmbId' => '123' # this is the custom field I'm trying to set.
],
[
'sectionId' => $this->sectionIds['locations'],
'typeId' => $this->typeIds['locations']['locations'],
'title' => 'Location 2',
'gmbId' => '123'
],
[
'sectionId' => $this->sectionIds['locations'],
'typeId' => $this->typeIds['locations']['locations'],
'title' => 'Location 3',
'gmbId' => '123'
]
];