Test Failed
Branch master (5e8424)
by Randy
02:43
created

EnsuranceTest::testIsNotEmpty()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 3
nc 1
nop 0
dl 0
loc 5
rs 9.4285
c 0
b 0
f 0
1
<?php
2
3
use Dgame\Ensurance\Exception\EnsuranceException;
4
use PHPUnit\Framework\TestCase;
5
use function Dgame\Ensurance\ensure;
6
7
class EnsuranceTest extends TestCase
0 ignored issues
show
Coding Style Compatibility introduced by
PSR1 recommends that each class must be in a namespace of at least one level to avoid collisions.

You can fix this by adding a namespace to your class:

namespace YourVendor;

class YourClass { }

When choosing a vendor namespace, try to pick something that is not too generic to avoid conflicts with other libraries.

Loading history...
8
{
9
    public function testIsNull()
10
    {
11
        ensure(null)->isNull();
12
    }
13
14
    public function testIsNotNull()
15
    {
16
        ensure('')->isNotNull();
17
    }
18
19
    public function testIsEmpty()
20
    {
21
        ensure('')->isEmpty();
22
    }
23
24
    public function testIsNotEmpty()
25
    {
26
        ensure(42)->isNotEmpty();
27
        ensure(' ')->isNotEmpty();
28
    }
29
30
    public function testIsEqual()
31
    {
32
        ensure(42)->isEqualTo('42');
33
    }
34
35
    public function testIsNotEqual()
36
    {
37
        ensure('42')->isNotEqualTo(4.2);
38
    }
39
40
    public function testIsSame()
41
    {
42
        ensure('foo')->isSameAs('foo');
43
        ensure(42)->isSameAs(2 * 21);
44
    }
45
46
    public function testIsNotSame()
47
    {
48
        ensure('foo')->isNotSameAs('bar');
49
        ensure('foo')->isNotSameAs(42);
50
    }
51
52
    public function testIsResource()
53
    {
54
        $ch = curl_init();
55
        ensure($ch)->isResource();
56
        curl_close($ch);
57
58
        $this->expectException(EnsuranceException::class);
59
60
        ensure(null)->isResource();
61
    }
62
63
    public function testArray()
64
    {
65
        ensure('foo')->isIn(['foo', 'bar']);
66
        ensure('foo')->isKeyOf(['foo' => 'bar']);
67
    }
68
69
    public function testVerify()
70
    {
71
        $this->assertTrue(ensure('foo')->isIn(['foo', 'bar'])->verify());
72
        $this->assertFalse(ensure('foo')->isIn(['bar'])->verify());
73
        $this->assertTrue(ensure('foo')->isKeyOf(['foo' => 'bar'])->verify());
74
        $this->assertFalse(ensure('foo')->isKeyOf(['foo', 'bar'])->verify());
75
    }
76
}