Hi. I’m learning how to use Yii, and i am trying to make a simple test with PHPUnit, but i get the following error:
PHP Warning: require_once(PHPUnit/Extensions/SeleniumTestCase.php): failed to open stream: No such file or directory in /opt/lampp/htdocs/yii/framework/test/CWebTestCase.php on line 12
My class only contains:
<?php
class DbTest extends CTestCase {
public function testConnection() {
$this->assertTrue(true);
}
}
I was a bit irritated by this so instead of skipping the test, I looked around for a shortcut solution on this. Luckily for the presented test in the book Web Application Development with Yii and PHP on page 53 you don’t need the class CWebTestCase extended in WebTestCase.php which in turn loads ‘PHPUnit/Extensions/SeleniumTestCase.php’).
You can change WebTestCase.php in
/**
* Change the following URL based on your server configuration
* Make sure the URL ends with a slash so that we can use relative URLs in test cases
*/
//define('TEST_BASE_URL','h t t p : / / localhost/testdrive/index-test.php/'); << commented out
/**
* The base class for functional test cases.
* In this class, we set the base URL for the test application.
* We also provide some common methods to be used by concrete test classes.
*/
class TestCase extends CTestCase << changed
{
/**
* Sets up before each test method runs.
* This mainly sets the base URL for the test application.
*/
protected function setUp()
{
parent::setUp();
//$this->setBrowserUrl(TEST_BASE_URL); << commented out
}
}
BTW: I hope that the YII people will adept the new way of using PHPUnit as suggested by Sebastian Bergmann. Not via PEAR but as a PHPUnit.phar (php archive).