Passed
Push — master ( 459b12...1ddf5f )
by Stephen
08:09 queued 05:53
created

InterfaceTest::interface_exist()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 1
c 1
b 0
f 0
nc 1
nop 0
dl 0
loc 3
rs 10
1
<?php
2
3
namespace Sfneal\Testing\Utils\Traits;
4
5
trait InterfaceTest
6
{
7
    // todo: add tests
8
9
    /** @test */
10
    public function interface_exist()
11
    {
12
        $this->assertTrue(interface_exists($this->interface()));
0 ignored issues
show
Bug introduced by
It seems like assertTrue() 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

12
        $this->/** @scrutinizer ignore-call */ 
13
               assertTrue(interface_exists($this->interface()));
Loading history...
13
    }
14
15
    /** @test */
16
    public function interface_is_implemented()
17
    {
18
        foreach ($this->classes() as $class) {
19
            $this->assertArrayHasKey($this->interface(), class_implements($class));
0 ignored issues
show
Bug introduced by
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

19
            $this->/** @scrutinizer ignore-call */ 
20
                   assertArrayHasKey($this->interface(), class_implements($class));
Loading history...
20
        }
21
    }
22
23
    /** @test */
24
    public function interface_methods_exist()
25
    {
26
        foreach ($this->methods() as $method) {
27
            $this->assertTrue(method_exists($this->interface(), $method));
28
        }
29
    }
30
31
    /**
32
     * Retrieve the interface class that should be tested.
33
     *
34
     * @return string
35
     */
36
    abstract public function interface(): string;
37
38
    /**
39
     * Retrieve an array of classes that should implement the interface.
40
     *
41
     * @return array
42
     */
43
    abstract public function classes(): array;
44
45
    /**
46
     * Retrieve an array of method names that should exist in the interface.
47
     *
48
     * @return array
49
     */
50
    abstract public function methods(): array;
51
}
52