Yii Framework Forum: Chapter 5, Page 90 - Using Fixtures - Yii Framework Forum

Jump to content

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

Chapter 5, Page 90 - Using Fixtures

#1 User is offline   xdolving 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 6
  • Joined: 01-October 10

Posted 01 October 2010 - 08:22 AM

Hi everyone,

I can't seem to read values from the fixtures array in ProjectTest.php.

What am I doing wrong?

My code looks as follows:

$retrievedProject = $this->projects['project1'];


and the output for the unit test says this

1) ProjectTest::testRead
Exception: Unknown property 'projects' for class 'ProjectTest'.


where am I going wrong? any help would be appreciated.

Greetings,

Andre
0

#2 User is offline   jefftulsa 

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

Posted 01 October 2010 - 08:44 AM

Hello Andre,

Please first take a look at both of these threads to see if they help you with your problem:

http://www.yiiframew...er-6-issuetest/

and

http://www.yiiframew...ssuetestissues/
0

#3 User is offline   xdolving 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 6
  • Joined: 01-October 10

Posted 01 October 2010 - 09:45 AM

Hi again,

I solved the problem.
Somehow it matters if you have blank lines in this piece of code.

public $fixtures = array(

        'projects'=>'Project', 

    );


the code lines above raise errors while this:

public $fixtures = array(
        'projects'=>'Project', 
    );


works perfectly fine.

Seems a little weird to me, but at least I figured it out :)

Greetings,

Andre
0

#4 User is offline   pantopita 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 5
  • Joined: 19-September 10

Posted 25 October 2010 - 07:15 AM

Hi,

I have exactly the same problem . I tried solution above but nothing works. Also I check and double check code inside ProjectTest.php, fixtures data and seems to be no typo errors but non of above didn't work.
Please if anyone cn help to resolve this problem I'm stuck here.
I'm on yii-1.1.2.r2086.

Thanks in advance
0

#5 User is offline   Backslider 

  • Advanced Member
  • PipPipPip
  • Yii
  • Group: Members
  • Posts: 363
  • Joined: 23-July 09

Posted 25 October 2010 - 10:04 AM

Perhaps one needs to create tests for their tests? :lol:

One good reason that I do not use the TDD approach.
We were all once expert at....... nothing.

yii-language-behavior

My Blog
0

#6 User is offline   aphelio 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 7
  • Joined: 04-October 10

Posted 17 January 2011 - 10:11 PM

I would like to agree with Backslider's first statement/question. There should absolutely be tests written for core framework functionality in Yii, including the testing framework. Second statement respectfully disagree. No reason to quit unit testing when it gets difficult, tests are almost always more difficult to write than the models being tested.

As for the specific problem that we are addressing in this thread, my strong advice is to make sure that your table name in the model that you are testing is exactly the same as the fixture file name. For example, if my model's table name is LOOKUP, then my fixture file name should be 'LOOKUP.php' <-- note that the capitalization matters.

Maybe it shouldn't?
2

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