I’m working on the test part and I have a question regarding how to set up fixtures. Let’s say we have 2 tables : USER and PROFILE. Table USER has one foreign key called [color="#FF0000"]profile_id[/color].
How is it possible to create fixtures for a user and its profile ? … so when tests begin, a row is inserted in the USER table, with a profile_id refering to a row in the PROFILE table.
Maybe that’s a stupid question, but really I have no idea
<?php
class ProjectTest extends WebTestCase
{
public $fixtures=array(
'clients'=>'Client',
'projects'=>'Project',
);
public function testIndex()
{
$this->open('project');
$this->assertTextPresent('Login');
}
}
Personally, i just went with ‘assumed’ ids. The fixture code in Yii will always reset the counter that gives you primary key ids, so the first row in the fixture will always be id 1, the second id 2, etc. So when i need to relate one fixture to another i just give it the id of whichever row it is in the other fixture