/
TestCase.php
52 lines (41 loc) · 1.17 KB
/
TestCase.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
<?php
namespace Tatter\Assets\Test;
use CodeIgniter\Test\CIUnitTestCase;
use org\bovigo\vfs\vfsStream;
use org\bovigo\vfs\vfsStreamDirectory;
use Tatter\Assets\Asset;
use Tatter\Assets\Config\Assets as AssetsConfig;
abstract class TestCase extends CIUnitTestCase
{
/**
* Virtual workspace
*
* @var vfsStreamDirectory
*/
protected $root;
/**
* @var AssetsConfig
*/
protected $config;
/**
* Preps the config and VFS.
*/
protected function setUp(): void
{
parent::setUp();
$this->root = vfsStream::setup('root');
// Create the config
$this->config = config('Assets');
$this->config->directory = $this->root->url() . DIRECTORY_SEPARATOR;
$this->config->useTimestamps = false; // These make testing much harder
Asset::useConfig($this->config);
// Add VFS as an allowed Publisher directory
config('Publisher')->restrictions[$this->config->directory] = '*';
}
protected function tearDown(): void
{
parent::tearDown();
$this->root = null; // @phpstan-ignore-line
$this->resetServices();
}
}