Reputation: 240
Its a parent child relation, In childGroup1, getting error during accessing 'PARENT_ID' attribute. The given error is Trying to get property of non-object.
I am having access dynamically.
How to get PARENT_ID in such case.
return array(
'group1'=>array(
'ID' => 1,
'NAME' => 'Test',
'STATUS' => 1,
),
'childGroup1'=>array(
'ID' => 2,
'PARENT_ID' => $this->getRecord('groups','group1')->ID,
'NAME' => 'Child Test group1',
'STATUS' => 1,
),
);
Upvotes: 0
Views: 108
Reputation: 5187
Since the records are not loaded yet, you cannot use $this->getRecord()
to acquire a record. As such, just use plain old array logic to get the record's ID.
$records = array();
$records['group1'] = array(
'ID' => 1,
'NAME' => 'Test',
'STATUS' => 1,
);
$records['childGroup1'] = array(
'ID' => 2,
'PARENT_ID' => $records['group1']['ID'],
'NAME' => 'Child Test group1',
'STATUS' => 1,
);
return $records;
If you need records from other fixtures, just require
them.
$groups = require __DIR__.'/group.php';
This, of course, would be what you put at the top of files OTHER than groups.php
, in order to gain access to the groups models.
Upvotes: 2