Yii Framework Forum: Chapter 6 - undefined method IssueTest::issues() - Yii Framework Forum

Jump to content

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

Chapter 6 - undefined method IssueTest::issues()

#1 User is offline   yii 

  • Advanced Member
  • PipPipPip
  • Yii
  • Group: Members
  • Posts: 440
  • Joined: 25-July 09

Posted 27 September 2010 - 08:51 AM

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.yiiframew...er-6-issuetest/
Meine Fragen stelle ich öffentlich und baue somit eine Wissensdatenbank für andere auf!
0

#2 User is offline   jefftulsa 

  • Advanced Member
  • Yii
  • Group: Yii Dev Team
  • Posts: 168
  • Joined: 06-October 08
  • Location:Austin, TX

Posted 27 September 2010 - 10:01 PM

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

<?php
class IssueTest extends CDbTestCase
{
   ...


rather than extending CTestCase
0

#3 User is offline   WisdomFusion 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 1
  • Joined: 12-November 10

Posted 19 December 2010 - 03:40 AM

View Postjefftulsa, on 27 September 2010 - 10:01 PM, said:

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
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