Passed
Push — master ( f43c0a...452f90 )
by Alexander
34s
created

AbstractTestCase   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 29
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 3

Importance

Changes 0
Metric Value
wmc 3
c 0
b 0
f 0
lcom 0
cbo 3
dl 0
loc 29
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A setUp() 0 12 2
A tearDown() 0 5 1
1
<?php
2
3
namespace Horat1us\Yii\Tests;
4
5
use \PHPUnit\Framework\TestCase;
6
use yii\di\Container;
7
use yii\web\Application;
8
9
/**
10
 * Class ApplicationTest
11
 * @package Horat1us\Yii\Tests
12
 */
13
abstract class AbstractTestCase extends TestCase
14
{
15
    /**
16
     * Create new application instance if it doesn't exist.
17
     * @return void
18
     */
19
    public function setUp()
20
    {
21
        if (isset(\Yii::$app)) {
22
            return;
23
        }
24
        \Yii::$container = new Container();
25
        \Yii::createObject([
26
            'class' => Application::class,
27
            'id' => mt_rand(),
28
            'basePath' => __DIR__,
29
        ]);
30
    }
31
32
    /**
33
     * Clear created application.
34
     * @return void
35
     */
36
    public function tearDown()
37
    {
38
        \Yii::$app = null;
39
        \Yii::$container = new Container();
40
    }
41
}