forked from nette/application
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbootstrap.php
70 lines (50 loc) · 1.18 KB
/
bootstrap.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);
// The Nette Tester command-line runner can be
// invoked through the command: ../vendor/bin/tester .
if (@!include __DIR__ . '/../vendor/autoload.php') {
echo 'Install Nette Tester using `composer install`';
exit(1);
}
// configure environment
Tester\Environment::setup();
date_default_timezone_set('Europe/Prague');
// output buffer level check
register_shutdown_function(function ($level): void {
Tester\Assert::same($level, ob_get_level());
}, ob_get_level());
function getTempDir(): string
{
$dir = __DIR__ . '/tmp/' . getmypid();
if (empty($GLOBALS['\\lock'])) {
// garbage collector
$GLOBALS['\\lock'] = $lock = fopen(__DIR__ . '/lock', 'w');
if (rand(0, 100)) {
flock($lock, LOCK_SH);
@mkdir(dirname($dir));
} elseif (flock($lock, LOCK_EX)) {
Tester\Helpers::purge(dirname($dir));
}
@mkdir($dir);
}
return $dir;
}
function test(\Closure $function): void
{
$function();
Mockery::close();
}
class Notes
{
public static $notes = [];
public static function add($message): void
{
self::$notes[] = $message;
}
public static function fetch(): array
{
$res = self::$notes;
self::$notes = [];
return $res;
}
}