Completed
Push — master ( 187d97...118e30 )
by Tõnis
04:16
created

TestBase::baseObject()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 7
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 4
dl 0
loc 7
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
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;
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
}