Answer the question
In order to leave comments, you need to log in
How to write tests in Yii?
For the second day I have been trying to figure out how to write tests in Yii and nothing comes of it.
According to this manual
php-md5.blogspot.com/2013/05/phpunit-selenium-rc-y...
I installed the whole thing with phpunit
Go to the folder:
\yii2\apps\advanced\frontend\tests\unit
Create my own first test MyOneTest.php :
use \yii\codeception\TestCase;
class MyOneTest extends TestCase
{
public function testFailure()
{
$this->assertTrue(true);
}
}
F:\OpenServer\domains\portf.ru\yii2\apps\advanced\frontend\tests\unit>phpunit My
OneTest.php
PHP Fatal error: Class 'yii\codeception\TestCase' not found in F:\OpenServer\do
mains\portf.ru\yii2\apps\advanced\frontend\tests\unit\MyOneTest.php on line 6
Fatal error: Class 'yii\codeception\TestCase' not found in F:\OpenServer\domains
\portf.ru\yii2\apps\advanced\frontend\tests\unit\MyOneTest.php on line 6
class MyOneTest extends PHPUnit_Framework_TestCase
{
public function testFailure()
{
$this->assertTrue(true);
}
}
PHPUnit 3.7.32 by Sebastian Bergmann.
.
Time: 72 ms, Memory: 1.75Mb
OK (1 test, 1 assertion)
Answer the question
In order to leave comments, you need to log in
well, you can't find the class \yii\codeception\TestCase. You probably didn't connect the YIi autoloader.
I don't know about Yii.
phpunit has a config - phpunit.de/manual/current/en/appendixes.configurat...
There you can specify bootstrap, a file that will be included when phpunit starts.
In it, apparently, you need to register autoload.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question