Chapter 6 - undefined method IssueTest::issues()

Hi,

I have some problems in chapter 6.

…PHP Fatal error: Call to undefined method IssueTest::issues() in /var/www/trackstar/protected/tests/unit/IssueTest.php on line 23

my fixture-data

/protected/tests/fixtures/tbl_issue.php




<?php 


return array(


	'issueBug'	=> array(

		'name'			=> 'test bug 1',

		'description'	=> 'dasdadadasd',

		'project_id'	=> 1,

		'type_id' 		=> 0,

		'status_id'		=> 1,

		'owner_id'		=> 1,

		'request_id'	=> 2,

		'create_time'		=> '',

		'create_user_id'	=> '',

		'update_time'		=> '',

		'update_user_id'	=> '',

	),


	'issueFeature'	=> array(

		'name'			=> 'test bug 2',

		'description'	=> 'cvxcvxvxcvxcvcvxxcv',

		'project_id'	=> 2,

		'type_id' 		=> 1,

		'status_id'		=> 0,

		'owner_id'		=> 2,

		'request_id'	=> 1,

		'create_time'		=> '',

		'create_user_id'	=> '',

		'update_time'		=> '',

		'update_user_id'	=> '',

	),

);


?>

 

/protected/tests/unit/IssueTest.php




<?php


class IssueTest extends CTestCase

{

	public $fixtures = array(

		'projects'	=> 'Project',

		'issues'	=> 'Issue',

	);

	

	public function testGetTypes()

	{

		$options = Issue::model()->TypeOptions;

		$this->assertTrue(is_array($options));

		

		$this->assertTrue(3 == count($options));

		$this->assertTrue(in_array('Bug', $options));

		$this->assertTrue(in_array('Feature', $options));

		$this->assertTrue(in_array('Task', $options));

	}


	public function testGetStatusText()

	{

		$this->assertTrue('Started' == $this->issues('issueBug')->getStatusText());

	}


	public function testGetTypeText()

	{

		$this->assertTrue('Bug' == $this->issues('issueBug')->getTypeText());

	}

}	



my trackstar_test - SQL Code for trackstar_test




<?php


class IssueTest extends CTestCase

{

	public $fixtures = array(

		'projects'	=> 'Project',

		'issues'	=> 'Issue',

	);

	

	public function testGetTypes()

	{

		$options = Issue::model()->TypeOptions;

		$this->assertTrue(is_array($options));

		

		$this->assertTrue(3 == count($options));

		$this->assertTrue(in_array('Bug', $options));

		$this->assertTrue(in_array('Feature', $options));

		$this->assertTrue(in_array('Task', $options));

	}


	public function testGetStatusText()

	{

		$this->assertTrue('Started' == $this->issues('issueBug')->getStatusText());

	}


	public function testGetTypeText()

	{

		$this->assertTrue('Bug' == $this->issues('issueBug')->getTypeText());

	}

}



who can help me?

thx

P.s.:

Yes I have read http://www.yiiframework.com/forum/index.php?/topic/11903-chapter-6-issuetest/

It looks as if your unit test class is not extending CDbTestCase. It should be:


<?php

class IssueTest extends CDbTestCase

{

   ...

rather than extending CTestCase

Bingo.

Thanks, guy, i solved the same problem, just change CTestCase to CDbTestCase.

;)

Regards,

gavin