/
PHPUnitAssets.php
70 lines (53 loc) · 1.62 KB
/
PHPUnitAssets.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
/**
* JBZoo Toolbox - Assets.
*
* This file is part of the JBZoo Toolbox project.
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*
* @license MIT
* @copyright Copyright (C) JBZoo.com, All rights reserved.
* @see https://github.com/JBZoo/Assets
*/
declare(strict_types=1);
namespace JBZoo\PHPUnit;
use JBZoo\Assets\Collection;
use JBZoo\Assets\Factory;
use JBZoo\Assets\Manager;
use JBZoo\Path\Path;
use Symfony\Component\Filesystem\Filesystem;
/**
* @SuppressWarnings(PHPMD.Superglobals)
*/
abstract class PHPUnitAssets extends PHPUnit
{
protected Manager $manager;
protected Factory $factory;
protected Collection $collection;
protected Path $path;
protected Filesystem $fs;
protected string $fixtPath;
protected string $cachePath;
/**
* Setup test data.
*/
protected function setUp(): void
{
$_SERVER['HTTP_HOST'] = 'test.dev';
$_SERVER['REQUEST_URI'] = '/request';
$this->fixtPath = PROJECT_ROOT . '/tests/fixtures';
$this->cachePath = PROJECT_ROOT . '/build/cache';
// cleanup
$this->fs = new Filesystem();
$this->fs->remove($this->cachePath);
$this->fs->mkdir($this->cachePath);
// Prepare lib
$this->path = new Path();
$this->path->setRoot($this->fixtPath);
$this->path->set('assets', 'root:assets');
$this->manager = new Manager($this->path);
$this->factory = $this->manager->getFactory();
$this->collection = $this->manager->getCollection();
}
}