. */ namespace SP\Tests; use Faker\Factory; use Faker\Generator; use PHPUnit\Framework\TestCase; use SP\Config\Config; use SP\Core\Context\StatelessContext; use SP\Services\Config\ConfigBackupService; use SP\Services\User\UserLoginResponse; use SP\Storage\File\FileCache; use SP\Storage\File\XmlHandler; /** * A class to test using a mocked Dependency Injection Container */ abstract class UnitaryTestCase extends TestCase { protected static Generator $faker; protected Config $config; public static function setUpBeforeClass(): void { self::$faker = Factory::create(); parent::setUpBeforeClass(); } /** * @throws \SP\Core\Exceptions\ConfigException * @throws \SP\Core\Context\ContextException */ protected function setUp(): void { $this->config = $this->getConfig(); parent::setUp(); } /** * @throws \SP\Core\Exceptions\ConfigException * @throws \SP\Core\Context\ContextException */ private function getConfig(): Config { $userLogin = new UserLoginResponse(); $userLogin->setLogin(self::$faker->userName); $context = new StatelessContext(); $context->initialize(); $context->setUserData($userLogin); return new Config( $this->createStub(XmlHandler::class), $this->createStub(FileCache::class), $context, $this->createStub(ConfigBackupService::class) ); } }