N
N
nepster-web2014-03-02 03:49:03
Yii
nepster-web, 2014-03-02 03:49:03

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

3 answer(s)
V
vyachin, 2015-04-07
@nepster-web

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);
    }
}

and run the test with the command
Your first test is ready

M
Mick Coder, 2015-03-05
@lbondodesc

yii2 uses the phpUnit
Codeception
add-on for testing Check out the documentation!

D
des1roer, 2016-03-23
@des1roer

des1roer.blogspot.com/2016/03/yii-2-codeception.html

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question