[Solved] Getting ID from fixture in testCase

Dear,

This is about writing unit test.

Here is my fixture.




return array(

	// 1

	'sample1'=>array(

		'name' => 'the sample 1',

	), // 2

	'sample2'=>array(

		'name' => 'the sample 2',

	),

	

);



and here is my unit test code.




class SampleTest extends CDbTestCase

{

	public $fixtures = array(

	    'samples' => 'sample',

	);

	public function testCreate()

	{

            // this doesn't work

            echo $this->samples['sample1']['id'];

            // this work

            echo $this->samples['sample1']['name'];

        }

}



I had a problem getting id from those fixtures.

Any ideas?

Thanks in advance.

I finally found something :

Here is how I solved it




class SampleTest extends CDbTestCase

{

        public $fixtures = array(

            'samples' => 'sample',

        );

        public function testCreate()

        {

            // this doesn't work

            echo $this->samples['sample1']['sample_id'];

            // this work

            echo $this->samples['sample1']['name'];

        }

}



Gave it a class name as prefix before _id