/
SomeFeature.php
80 lines (62 loc) · 1.71 KB
/
SomeFeature.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
<?php
namespace Vehikl\Flip\Tests;
use PHPUnit\Framework\TestCase;
use PHPUnit\Framework\TestResult;
use Vehikl\Flip\Feature;
class SomeFeature extends Feature
{
private $enabled = false;
private $invokedMethod;
public function toggles(): array
{
return ['someToggle' => ['on' => 'whenSomeToggleIsOn', 'off' => 'whenSomeToggleIsOff'], 'anotherToggle' => ['on' => 'whenAnotherToggleIsOn', 'off' => 'whenAnotherToggleIsOff',], 'staticToggle' => ['on' => 'whenStaticToggleIsOn', 'off' => 'whenStaticToggleIsOff',], 'bustedToggle' => ['on' => 'whenBustedToggleIsOn', 'off' => 'whenBustedToggleIsOff',]];
}
public function enabled(): bool
{
return $this->enabled;
}
public function turnOn(): self
{
$this->enabled = true;
return $this;
}
public function turnOff(): self
{
$this->enabled = false;
return $this;
}
public function whenSomeToggleIsOn(): string
{
return $this->invokedMethod = 'whenOn';
}
public function whenSomeToggleIsOff(): string
{
return $this->invokedMethod = 'whenOff';
}
public function invokedMethod(): string
{
return $this->invokedMethod;
}
public function whenAnotherToggleIsOn(): string
{
return $this->toString();
}
public function whenAnotherToggleIsOff(): TestResult
{
return $this->createResult();
}
public function whenStaticToggleIsOn(): void
{
}
public function whenStaticToggleIsOff(): TestCase
{
return $this->caller;
}
public function whenBustedToggleIsOn(): void
{
}
public function whenBustedToggleIsOff(): void
{
$this->nope();
}
}