Fatal error: Class 'WebTestCase' not found

Hi everyone

I’m trying to run a testunit for a post, but the application is not able to locale the WebTestCase file.

I’m using Yii 1.1.2 and PHPunit.

Here’s my PostTest.php located in the functional folder:

class PostTest extends WebTestCase {     

       public $fixtures=array(         



      public function testShow()



        // verify the sample post title exists


        // verify comment form exists

        $this->assertTextPresent('Leave a Comment');


Here’s my test.php which is in the config folder:


return CMap::mergeArray(








                       'connectionString' => 'mysql:host=localhost;dbname=forum',

                            'emulatePrepare' => true,

                            'username' => 'root',

                            'password' => 'pass55',

                            'charset' => 'utf8',

                            'tablePrefix' => '',





And the bootstrap.php is located in the tests folder.

What i’m missing ? it’s look like the application is not able to initiate the bootstrap.php file !! and if i should initialize it, where i should do this ? because i read the tutorial about the TestUnit, and i didn’t see where the bootstrap should be initialized.

Thanks :)

I have the same problem. I don’t know why. :-[

I had this problem when my version of phpunit was too old. Should be >= 3.4.

I got same problem too. I use phpunit 3.5.14

any suggestion?

Just wrote out a reply to this, only to have the website tell me (after I’d written the reply) “Sorry, please wait 10 minutes before replying” - and then it destroyed my reply. How annoying / poor is that?

Is it a regular occurrence to have no answer to questions posted over a year ago? I really hope not as it will making using Yii a nightmare.

I’m also having the same problem and using PHPUnit 3.5.14.

There’s also another similar question here: phpunit-functionalsitetest-error

The answer there seems to be ‘upgrade PHPUnit’ - which I have done… still no joy. :angry:

To try and help out, I seem to be having some luck by doing the following:

My PHPUnit install is located at:


So from my Command Prompt I have just:

Changed Directory to go to my testing folder:

So, from Command Prompt I typed:

CD C:\xampp\htdocs\yiiweb\protected\tests

  • my WebTestCase.php is located here

And then after the directory has changed I ran the PHPUnit command, referring to PHPUnit absolutely, so:

C:\xampp\php\phpunit functional\SiteTest.php

  • This seemed to run the test for me, hope this is of some use to people.

In my case the functional tests didn’t run cause i had a to old phpunit version (=>I update to 3.5.14 via sudo pear upgrade) and had not installed the selenium extension for phpunit.

See my post in this thread and install PHPUnit_Selenium extension via pear.

For me it solves the problem to be not able to run functional tests.

I had the same issue and I figured it out the problem occurs when I try to run the tests outside of the tests folder. call the command from there works like it should be.

1 Like

Ty all for your posts. All of them helped me. Yours one was the missing chief’s cherry.