Yii Framework Forum: Mass Assignment And Fixtures - Yii Framework Forum

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

Mass Assignment And Fixtures Rate Topic: -----

#1 User is offline   charlespwd 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 3
  • Joined: 31-May 13

Posted 20 December 2013 - 08:15 AM

Somehow a followup of :
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?
0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users