/
Specify.php
70 lines (61 loc) · 1.85 KB
/
Specify.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
<?php declare(strict_types=1);
namespace Codeception;
use Closure;
use Codeception\Specify\SpecifyHooks;
use PHPUnit\Framework\TestCase;
trait Specify
{
use SpecifyHooks {
afterSpecify as public;
beforeSpecify as public;
cleanSpecify as public;
getCurrentSpecifyTest as public;
}
public function specify(string $thing, Closure $code = null, $examples = []): ?self
{
if ($code instanceof Closure) {
$this->runSpec($thing, $code, $examples);
return null;
}
return $this;
}
public function describe(string $feature, Closure $code = null): ?self
{
if ($code instanceof Closure) {
$this->runSpec($feature, $code);
return null;
}
return $this;
}
public function it(string $specification, Closure $code = null, $examples = []): self
{
if ($code instanceof Closure) {
$this->runSpec($specification, $code, $examples);
return $this;
}
TestCase::markTestIncomplete();
return $this;
}
public function its(string $specification, Closure $code = null, $examples = []): self
{
return $this->it($specification, $code, $examples);
}
public function should(string $behavior, Closure $code = null, $examples = []): self
{
if ($code instanceof Closure) {
$this->runSpec('should ' . $behavior, $code, $examples);
return $this;
}
TestCase::markTestIncomplete();
return $this;
}
public function shouldNot(string $behavior, Closure $code = null, $examples = []): self
{
if ($code instanceof Closure) {
$this->runSpec('should not ' . $behavior, $code, $examples);
return $this;
}
TestCase::markTestIncomplete();
return $this;
}
}