Chapter 7 page no.151-152.

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.

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.

It appears I am not having the same issue.

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.

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.

[quote name=‘Hobbiest’][color=#1C2837][size=2]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.[/size][/color]
[/quote]

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