1 | <?php |
||
2 | |||
3 | namespace andmemasin\myabstract\test; |
||
4 | use yii\base\Model; |
||
5 | |||
6 | /** |
||
7 | * Trait ModelTestTrait |
||
8 | * @package andmemasin\myabstract\traits |
||
9 | * @author Tõnis Ormisson <[email protected]> |
||
10 | * @property Model $model |
||
11 | */ |
||
12 | trait ModelTestTrait |
||
13 | { |
||
14 | use InvokeProtectedTrait; |
||
15 | |||
16 | public function testAttributeLabelsForExistingAttributesOnly() { |
||
17 | // labels only for actually existing attributes |
||
18 | foreach ($this->model->attributeLabels() as $key => $label) { |
||
19 | $this->assertArrayHasKey($key, array_merge(get_object_vars($this->model), $this->model->attributes)); |
||
0 ignored issues
–
show
Bug
introduced
by
![]() |
|||
20 | } |
||
21 | } |
||
22 | public function testAttributeHintsForExistingAttributesOnly() { |
||
23 | // labels only for actually existing attributes |
||
24 | foreach ($this->model->attributeHints() as $key => $label) { |
||
25 | $this->assertArrayHasKey($key, array_merge(get_object_vars($this->model), $this->model->attributes)); |
||
26 | } |
||
27 | } |
||
28 | public function testRulesForExistingAttributesOnly() { |
||
29 | // labels only for actually existing attributes |
||
30 | foreach ($this->model->rules() as $rule) { |
||
31 | $rules = (is_array($rule[0]) ? $rule[0] : [$rule[0]] ); |
||
32 | foreach ($rules as $attribute) { |
||
33 | $this->assertArrayHasKey($attribute, array_merge(get_object_vars($this->model), $this->model->attributes)); |
||
34 | } |
||
35 | } |
||
36 | } |
||
37 | |||
38 | /** |
||
39 | * @return array |
||
40 | */ |
||
41 | public function baseUserStringsAttributes() { |
||
42 | return [ |
||
43 | 'user_created' => 1, |
||
44 | 'user_updated' => 1, |
||
45 | 'user_closed' => null, |
||
46 | 'time_created' => "2018-11-10 10:10:10", |
||
47 | 'time_updated' => "2018-11-10 10:10:10", |
||
48 | 'time_closed' => "3333-11-10 10:10:10", |
||
49 | ]; |
||
50 | } |
||
51 | |||
52 | |||
53 | } |