Completed
Branch master (60648a)
by Randy
03:56
created

ObjectEnsuranceTest::testHasMethod()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 3
nc 1
nop 0
dl 0
loc 6
rs 9.4285
c 0
b 0
f 0
1
<?php
2
3
use PHPUnit\Framework\TestCase;
4
use function Dgame\Ensurance\ensure;
5
6
class EA
7
{
8
    public $test;
9
10
    public function foo()
11
    {
12
    }
13
}
14
15
class EB extends EA
16
{
17
}
18
19
interface EI
20
{
21
}
22
23
class EC implements EI
24
{
25
}
26
27
trait ET
28
{
29
}
30
31
class ED
32
{
33
    use ET;
34
}
35
36
class ObjectEnsuranceTest extends TestCase
37
{
38
    public function testIsInstanceOf()
39
    {
40
        $ea = new EA();
41
42
        ensure($ea)->isObject()->isInstanceOf(EA::class);
43
    }
44
45
    public function testIs()
46
    {
47
        $ea = new EA();
48
49
        ensure($ea)->isObject()->is(EA::class);
50
    }
51
52
    public function testIsSome()
53
    {
54
        $eb = new EB();
55
56
        ensure($eb)->isObject()->isSome(EA::class);
57
    }
58
59
    public function testExtends()
60
    {
61
        $eb = new EB();
62
63
        ensure($eb)->isObject()->extends(EA::class);
64
    }
65
66
    public function testImplements()
67
    {
68
        $ec = new EC();
69
70
        ensure($ec)->isObject()->implements(EI::class);
71
    }
72
73
    public function testIsParentOf()
74
    {
75
        $ea = new EA();
76
77
        ensure($ea)->isObject()->isParentOf(EB::class);
78
    }
79
80
    public function testUses()
81
    {
82
        $ed = new ED();
83
84
        ensure($ed)->isObject()->uses(ET::class);
85
    }
86
87
    public function testHasProperty()
88
    {
89
        $ea = new EA();
90
91
        ensure($ea)->isObject()->hasProperty('test');
92
    }
93
94
    public function testHasMethod()
95
    {
96
        $ea = new EA();
97
98
        ensure($ea)->isObject()->hasMethod('foo');
99
    }
100
}