/
Expector.php
93 lines (75 loc) · 2.36 KB
/
Expector.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
<?php
class Expector
{
private $actual;
private $message;
function __construct($actual, $message = '')
{
$this->actual = $actual;
$this->message = $message;
}
public function arrayToHaveKey($key)
{
\PHPUnit\Framework\Assert::assertArrayHasKey($key, $this->actual);
}
public function arrayToNotHaveKey($key)
{
\PHPUnit\Framework\Assert::assertArrayNotHasKey($key, $this->actual);
}
public function classToHaveAttribute($attributeName)
{
\PHPUnit\Framework\Assert::assertClassHasAttribute($attributeName, $this->actual);
}
public function toBe($expected)
{
\PHPUnit\Framework\Assert::assertSame($expected, $this->actual);
}
public function toBeFalse()
{
\PHPUnit\Framework\Assert::assertFalse($this->actual);
}
public function toBeGreaterThan($expected)
{
\PHPUnit\Framework\Assert::assertGreaterThan($expected, $this->actual);
}
public function toBeInstanceOf($expected)
{
\PHPUnit\Framework\Assert::assertInstanceOf($expected, $this->actual);
}
public function toBeLessThan($expected)
{
\PHPUnit\Framework\Assert::assertLessThan($expected, $this->actual);
}
public function toBeTrue()
{
\PHPUnit\Framework\Assert::assertTrue($this->actual);
}
public function toContain($needle)
{
\PHPUnit\Framework\Assert::assertContains($needle, $this->actual);
}
public function toContainAll(array $expected)
{
\PHPUnit\Framework\Assert::assertEquals($expected, $this->actual, "\$canonicalize = true", $delta = 0.0, $maxDepth = 10, $canonicalize = true);
}
public function toEqual($expected)
{
\PHPUnit\Framework\Assert::assertEquals($expected, $this->actual);
}
public function toHaveAttribute($attributeName)
{
\PHPUnit\Framework\Assert::assertObjectHasAttribute($attributeName, $this->actual);
}
public function toMatch($regex)
{
\PHPUnit\Framework\Assert::assertRegExp($regex, $this->actual);
}
public function toNotEqual($expected)
{
\PHPUnit\Framework\Assert::assertNotEquals($expected, $this->actual);
}
public function toNotHaveAttribute($attributeName)
{
\PHPUnit\Framework\Assert::assertObjectNotHasAttribute($attributeName, $this->actual);
}
}