Passed
Push — master ( 117d80...68f275 )
by Tõnis
04:24
created

TestBase   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 38
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 2
eloc 10
dl 0
loc 38
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A _before() 0 3 1
A baseObject() 0 7 1
1
<?php
2
3
namespace andmemasin\surveybasemodels\tests;
4
5
use Codeception\Stub;
6
use Codeception\Test\Unit;
7
use yii;
8
use andmemasin\myabstract\test\ModelTestTrait;
9
10
11
abstract class TestBase extends Unit
12
{
13
    use ModelTestTrait;
0 ignored issues
show
Bug introduced by
The trait andmemasin\myabstract\test\ModelTestTrait requires the property $attributes which is not provided by andmemasin\surveybasemodels\tests\TestBase.
Loading history...
14
15
    /** @var yii\base\Model */
16
    public $model;
17
18
    /** @var string */
19
    public $modelClass;
20
21
    /**
22
     * @var \UnitTester
23
     */
24
    protected $tester;
25
26
27
    protected function _before()
28
    {
29
        $this->model = $this->baseObject();
30
    }
31
32
33
    /**
34
     * @return array
35
     */
36
    abstract public function baseModelAttributes();
37
38
39
    /**
40
     * @return yii\base\Model
41
     */
42
    public function baseObject(){
43
        /** @var yii\base\Model $model */
44
        $model = Stub::make($this->modelClass, [
45
            'attributes' => array_keys($this->baseModelAttributes()),
46
        ]);
47
        $model->setAttributes($this->baseModelAttributes());
48
        return $model;
49
    }
50
51
}