Files
Php-Template/tests/Unit.php
Ron Rise de0c95db2a
All checks were successful
🧪✨ Tests Workflow / 🛡️ 🔒 License Check (push) Successful in 2m40s
🧪✨ Tests Workflow / 📝 ✨ Code Lint (push) Successful in 2m42s
🧪✨ Tests Workflow / 🛡️ 🔒 Library Audit (push) Successful in 2m53s
🧪✨ Tests Workflow / 🧪 ✨ Database Migrations (push) Successful in 2m55s
🧪✨ Tests Workflow / 🐙 🔍 Code Sniffer (push) Successful in 2m42s
🧪✨ Tests Workflow / 🧪 ✅ Unit Tests (push) Successful in 1m24s
feat: enhance service providers with provides method and integrate command bus in handlers
2025-12-22 13:18:13 -05:00

49 lines
1.1 KiB
PHP

<?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();
}
}