-
Notifications
You must be signed in to change notification settings - Fork 710
/
Copy pathBaseApplicationTestCase.php
55 lines (45 loc) · 1.47 KB
/
BaseApplicationTestCase.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
<?php
use Illuminate\Container\Container;
use PHPUnit\Framework\TestCase;
use Symfony\Component\Console\Tester\ApplicationTester;
class BaseApplicationTestCase extends TestCase
{
use UsesNullWriter;
protected function setUp(): void
{
$this->prepTestConfig();
$this->setNullWriter();
}
protected function tearDown(): void
{
Mockery::close();
}
/**
* Prepare a test to run using the full application.
*/
public function prepTestConfig(): void
{
require_once __DIR__.'/../cli/includes/helpers.php';
Container::setInstance(new Container); // Reset app container from previous tests
if (Filesystem::isDir(VALET_HOME_PATH)) {
Filesystem::rmDirAndContents(VALET_HOME_PATH);
}
Configuration::createConfigurationDirectory();
Configuration::createDriversDirectory();
Configuration::createLogDirectory();
Configuration::createCertificatesDirectory();
Configuration::writeBaseConfiguration();
// Keep this file empty, as it's tailed in a test
Filesystem::touch(VALET_HOME_PATH.'/Log/nginx-error.log');
}
/**
* Return an array with two items: the application instance and the ApplicationTester.
*/
public function appAndTester(): array
{
$app = require __DIR__.'/../cli/app.php';
$app->setAutoExit(false);
$tester = new ApplicationTester($app);
return [$app, $tester];
}
}