Running unit tests on windows problem

I created unit test, that should select * from Project table and that selection should be exactly one row, which I’ll compare with fixture. Purpose is to verify DB connection and illustrate testing.

Here’s the class:


class ApplicationTest extends CDbTestCase

{

    public $fixtures=array(

		'projects'=>':Project',

	);


	public function testSelect()

	{

		$command = Yii::app()->db->createCommand('SELECT * FROM Project');

		$result = $command->query();

		$this->assertEquals($this->projects['row1'], $result);

	}

}

Here’s the command I’m running:

First 2 lines translated into English:

That message does not actually matte, it’s some bug that appear all the time.

But CTestCase is not found for some reason… Any ideas why?

Also, if I run phpunit unit\ApplicationTest.php without bootstrap key I get error:

What’s wrong and how can I fix this?

Maybe this one can help: http://www.yiiframework.com/forum/index.php?/topic/4717-netbeans-68-phpunit-and-yii/

I’m working with 1.1 SVN version.

It has built-in unit testing framework that is based on phpunit and selenium.

selenium tests run OK, but phpunit ones - don’t

the difference between 1.0.9 and 1.1 is that in 1.1 there is a special fie yiit.php, that should be included when testing.

And since I’m covering 11.1 version in my writing, I can’t ignore the existance of the unit testing framework :)

Are you able to run the unit tests under demos/blog successfully?

No, the problem remains the same :(

I just updated the code from SVN and the problem persists.

That’s strange. It works fine here (also Windows).

As you may notice, there is a file demos/blog/protected/tests/bootstrap.php. This is the file that is automatically loaded when you run tests under that folder. In this file, yiit.php is included which further imports all necessary class files including CTestCase.php.

Yes, I explored the file and found that. And I can’t understand why it doesn’t load CTestCase and does load CDbTestCase. Very strange…

For those who maybe encountered the problem


PHP Fatal error:  Class 'CTestCase' not found in

 

For me the solution was: change current directory in your command line to a ‘tests’ folder, so you’ll have


$ phpunit unit/SomeTest.php

instead of


$ phpunit tests/unit/SomeTest.php

,

for example.

Yuga