Answer the question
In order to leave comments, you need to log in
How to write a unit test for Yii2?
I’m getting familiar with the new Yii2, I pulled up this repository:
https://github.com/yiisoft/yii2
Then I pulled up the files using composer in the advanced
application
I started looking towards tests, I had never worked with them before, so I had difficulty understanding this affairs.
So
we have folders with tests in the following directories: backend, common, console
, frontend for the test.
The contents of this folder is: https://github.com/yiisoft/yii2/tree/master/apps/a...
Honestly, I almost didn’t understand what we have here and why, most likely different test frameworks are used, but I saw the familiar name unit and got there.
Well, and then my powers are all. Ie, please tell me how to write your first test, what is going on there?
Answer the question
In order to leave comments, you need to log in
Codeception is good, but not required. You can only use phpunit, especially since you have already installed it. Create file FirstTest.php in tests\unit folder with this content
<?php
namespace tests\unit;
class FirstTest extends \PHPUnit_Framework_TestCase
{
public function testTrue()
{
$this->assertTrue(true);
}
}
yii2 uses the phpUnit
Codeception
add-on for testing
Check out the documentation!
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question