Issues (36)

src/test/StaticModelTestTrait.php (1 issue)

Labels
Severity
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
    public function testAttributeLabelsForExistingAttributesOnly() {
15
        // labels only for actually existing attributes
16
        foreach ($this->model->attributeLabels() as $key => $label) {
17
            $this->assertArrayHasKey($key, $this->model->attributes);
0 ignored issues
show
It seems like assertArrayHasKey() must be provided by classes using this trait. How about adding it as abstract method to this trait? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

17
            $this->/** @scrutinizer ignore-call */ 
18
                   assertArrayHasKey($key, $this->model->attributes);
Loading history...
18
        }
19
    }
20
    public function testAttributeHintsForExistingAttributesOnly() {
21
        // labels only for actually existing attributes
22
        foreach ($this->model->attributeHints() as $key => $label) {
23
            $this->assertArrayHasKey($key, $this->model->attributes);
24
        }
25
    }
26
    public function testRulesForExistingAttributesOnly() {
27
        // labels only for actually existing attributes
28
        foreach ($this->model->rules() as $rule) {
29
            foreach ($rule[0] as $attribute) {
30
                $this->assertArrayHasKey($attribute, $this->model->attributes);
31
            }
32
        }
33
    }
34
35
36
}