helpers.php
820 Bytes
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
<?php
namespace Roots\Acorn\Tests;
use Mockery;
use Mockery\MockInterface;
use Spatie\TemporaryDirectory\TemporaryDirectory;
function acorn_root(?string $path = null)
{
return dirname(__DIR__) . ($path ? "/{$path}" : '');
}
function plugin_entrypoint()
{
return __DIR__ . '/../acorn.php';
}
/**
* Get a temporary directory
*
* @param string|null $path
* @return string|TemporaryDirectory
*/
function temp(?string $path = null)
{
static $temp;
if (! $temp) {
$temp = (new TemporaryDirectory())->create();
register_shutdown_function(function () use ($temp) {
$temp->delete();
});
}
if ($path !== null) {
return $temp->path($path);
}
return $temp;
}
function mock(string $class): MockInterface
{
return Mockery::mock($class);
}