-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsuite_setup_spec.php
49 lines (38 loc) · 1.17 KB
/
suite_setup_spec.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
<?php
/*
* How to use suite_setup.
*/
namespace Preview\DSL\TDD;
require_once __DIR__.'/../ok.php';
suite("suite_setup", function () {
suite_setup(function () {
$this->usage = "run suite_setup the current test suite";
});
suite_setup(function () {
$this->note_1 = "suite_setup hooks are run in order";
});
suite_setup(function () {
$this->ref = new \stdClass;
$this->ref->name = "wenjun.yan";
$this->value = "string";
});
test("can access the variable set in suite_setup hooks", function () {
ok($this->note_1);
ok($this->note_2);
ok($this->value);
ok($this->ref->name);
$this->value = null;
$this->ref->name = null;
});
test("suite_setup hooks run only once in current test suite", function () {
/*
* run tests in order, this will pass.
*/
ok($this->value); // string is passed by value
ok(empty($this->ref->name)); // object is passed by "ref".
});
suite_setup(function () {
$this->note_2 = "wherever you put the suite_setup each hook, ".
"it will run suite_setup this suite";
});
});