You've already forked php-auth
generated from siteworxpro/Php-Template
Initial commit
This commit is contained in:
48
tests/Unit.php
Normal file
48
tests/Unit.php
Normal file
@@ -0,0 +1,48 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Siteworxpro\Tests;
|
||||
|
||||
use Illuminate\Container\Container;
|
||||
use Mockery;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use Siteworx\Config\Config as SWConfig;
|
||||
use Siteworxpro\App\Kernel;
|
||||
use Siteworxpro\App\Services\Facade;
|
||||
use Siteworxpro\App\Services\Facades\Config;
|
||||
|
||||
abstract class Unit extends TestCase
|
||||
{
|
||||
protected function getContainer(): Container
|
||||
{
|
||||
$container = Facade::getFacadeContainer();
|
||||
if ($container === null) {
|
||||
$container = new Container();
|
||||
Facade::setFacadeContainer($container);
|
||||
|
||||
return $container;
|
||||
}
|
||||
|
||||
return $container;
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws \ReflectionException
|
||||
*/
|
||||
protected function setUp(): void
|
||||
{
|
||||
$container = $this->getContainer();
|
||||
|
||||
$container->bind(SWConfig::class, function () {
|
||||
return SWConfig::load(__DIR__ . '/../config.php');
|
||||
});
|
||||
}
|
||||
|
||||
protected function tearDown(): void
|
||||
{
|
||||
Config::clearResolvedInstances();
|
||||
Facade::setFacadeContainer(null);
|
||||
Mockery::close();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user