http://www.yiiframew...g-foreign-keys/
I want to create a fixture for my TimeEntry ActiveRecord. But I can't seem to be able to do it.
The following unit test passes however I had to set all foreign keys to safe:
public function testSaveViaAttributesWithForeignKeys(){ $timeEntry = new TimeEntry(); $timeEntry->attributes = array( 'student_id' => 4, 'date' => 1387152001, 'hours_worked' => 8.00, 'hours_type_id' => 1, 'status_id' => 1 ); $this->assertTrue($timeEntry->save()); }
I have a fixture in TimeEntry.php :
return array( 'monday' => array( 'student_id' => 4, 'date' => 1387152000, 'hours_worked' => 8.00, 'hours_type_id' => 1, 'status_id' => 1 ) );
But the following test throws an exception:
class TimeEntryTest extends CDbTestCase { public $fixtures = array( 'tes' => 'TimeEntry', ); public function testFixture(){ $timeEntry = $this->tes; $this->assertExists($timeEntry); } }
Exception and stack:
1) TimeEntryTest::testFixture Exception: unknown property 'tes' for class 'TimeEntryTest'. C:\...\yii\framework\test\CDbTestCase.php:62 C:\...\protected\tests\unit\TimeEntryTest.php:10
I checked the DB and nothing was added to it. (So somehow I cannot create entries with the fixture manager)
What can I do about this?