-
Notifications
You must be signed in to change notification settings - Fork 1
/
proofofconcept.php
73 lines (60 loc) · 1.29 KB
/
proofofconcept.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
<?php
class FluentAssertion
{
public $result;
function assert($result)
{
$this->result = $result;
return $this;
}
function should()
{
return $this;
}
function be($expected)
{
if ($this->result === $expected)
{
echo "Pass <br />" . PHP_EOL;
}
else
{
echo "Fail: expected '{$this->result}' to be '{$expected}' <br />" . PHP_EOL;
}
}
}
class ClassUnderTest
{
public $firstProp;
public $secondProp;
function __construct()
{
$this->firstProp = "PROPERTY";
$this->secondProp = "SECOND PROP";
}
function testMethod()
{
return $this->firstProp;
}
}
class TestClass extends FluentAssertion
{
public $sut;
function __construct()
{
$this->sut = new ClassUnderTest();
}
function checkProperties()
{
$this->assert($this->sut->firstProp)->should()->be("PROPERTY");
$this->assert($this->sut->secondProp)->should()->be("SECOND PROP");
$this->assert($this->sut->testMethod())->should()->be("test123");
}
function genericCheck()
{
$this->assert(1024)->should()->be(1024);
}
}
$tester = new TestClass();
$tester->checkProperties();
$tester->genericCheck();