Yii Framework Forum: Chapter 7 page no.151-152. - Yii Framework Forum

Jump to content

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

Chapter 7 page no.151-152. Php Unit testing result is Failed asserting that null matches expected

#1 User is offline   hnam 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 49
  • Joined: 19-September 10
  • Location:BSP

Posted 20 December 2011 - 06:50 AM

I am using Yii 1.1.8
and doing Trackstar exercise from Agile web development book, i am on Chapter 7 page no.151-152.
i am following all given instructions as per book but getting unit Testing issue :-

ProjectTest::testCreate
Failed asserting that null matches expected '1'

....

FAILURES !
Tests: 5, Assertions: 13, Failures:1.


To find my PHP Code and PHPunitTest result screen get attached files.

Attached File(s)


On revolutions !
0

#2 User is offline   hnam 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 49
  • Joined: 19-September 10
  • Location:BSP

Posted 20 December 2011 - 07:14 AM

When i delete the line:-

$this->assertEquals(Yii::app()->user->id, $retrievedProject->create_user_id);

or

Yii::app()->user->setId($this->users('user1')->id);

it run without any error but when i put this line again according to book instruction error occur.

This post has been edited by hnam: 22 December 2011 - 10:42 AM

On revolutions !
0

#3 User is offline   Hobbiest 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 13
  • Joined: 13-January 12

Posted 01 February 2012 - 12:58 AM

View Posthnam, on 20 December 2011 - 07:14 AM, said:

When i delete the line:-

$this->assertEquals(Yii::app()->user->id, $retrievedProject->create_user_id);

or

Yii::app()->user->setId($this->users('user1')->id);

it run without any error but when i put this line again according to book instruction error occur.


I am having the same issue. It has to be directly related to a change or changes between Yii 1.1.2 and your Yii 1.1.8 and my Yii 1.1.9.

My error is as follows:
1) ProjectTest::testCreate
Exception: Unknown method 'users' for class 'ProjectTest'.

YiiRoot/framework/test/CDbTestCase.php:78
WebRoot/trackstar/protected/tests/unit/ProjectTest.php:24
WebRoot/trackstar/protected/tests/unit/ProjectTest.php:24

FAILURES!
Tests: 5, Assertions: 8, Errors: 1.


I am planning on trying to sift through CDbTestCase and the Yii change history and class reference to try and determine what changes need to be made. If I find something I will be sure to report back.
0

#4 User is offline   Hobbiest 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 13
  • Joined: 13-January 12

Posted 04 February 2012 - 01:15 PM

View Posthnam, on 20 December 2011 - 07:14 AM, said:

When i delete the line:-

$this->assertEquals(Yii::app()->user->id, $retrievedProject->create_user_id);

or

Yii::app()->user->setId($this->users('user1')->id);

it run without any error but when i put this line again according to book instruction error occur.



It appears I am not having the same issue.

View PostHobbiest, on 01 February 2012 - 12:58 AM, said:

My error is as follows:
1) ProjectTest::testCreate
Exception: Unknown method 'users' for class 'ProjectTest'.

YiiRoot/framework/test/CDbTestCase.php:78
WebRoot/trackstar/protected/tests/unit/ProjectTest.php:24
WebRoot/trackstar/protected/tests/unit/ProjectTest.php:24

FAILURES!
Tests: 5, Assertions: 8, Errors: 1.



So it seems the issue is related to my fixtures but I cannot seem to figure out what is wrong. For some reason I cannot acces my 'users' fixture.

Turns out I had my users fixture file name as 'tbl_users' when it needs to be 'tbl_user' to be the equivalent of the database table name.
0

#5 User is offline   DamarisBQ 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 2
  • Joined: 04-April 12

Posted 09 April 2012 - 01:14 PM

Hi,
I have the same problem when i try to run phpunit/ProjectTest.php


1) ProjectTest::testCreate
Exception: Unknown method 'users' for class 'ProjectTest'.

/var/www/yii/framework/test/CDbTestCase.php:78
/var/www/trackstar/protected/tests/unit/ProjectTest.php:22
/var/www/trackstar/protected/tests/unit/ProjectTest.php:22

FAILURES!
Tests: 4, Assertions: 7, Errors: 1.


Did you solve this problem? Please Help!
0

#6 User is offline   Hobbiest 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 13
  • Joined: 13-January 12

Posted 10 April 2012 - 08:34 AM

View PostDamarisBQ, on 09 April 2012 - 01:14 PM, said:

Hi,
I have the same problem when i try to run phpunit/ProjectTest.php


1) ProjectTest::testCreate
Exception: Unknown method 'users' for class 'ProjectTest'.

/var/www/yii/framework/test/CDbTestCase.php:78
/var/www/trackstar/protected/tests/unit/ProjectTest.php:22
/var/www/trackstar/protected/tests/unit/ProjectTest.php:22

FAILURES!
Tests: 4, Assertions: 7, Errors: 1.


Did you solve this problem? Please Help!


My issue was directly related to my fixtures and file name.

Hobbiest said:

Turns out I had my users fixture file name as 'tbl_users' when it needs to be 'tbl_user' to be the equivalent of the database table name.


What is on your line number 22 of ProjectTest.php where the error is occurring?



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