diff --git a/tests/SPT/Config/ConfigTest.php b/tests/SPT/Config/ConfigTest.php deleted file mode 100644 index ce35ce9b..00000000 --- a/tests/SPT/Config/ConfigTest.php +++ /dev/null @@ -1,157 +0,0 @@ -. - */ - -namespace SPT\Config; - -use Defuse\Crypto\Exception\EnvironmentIsBrokenException; -use DI\Container; -use DI\DependencyException; -use DI\NotFoundException; -use PHPUnit\Framework\TestCase; -use SP\Core\Context\ContextException; -use SP\Domain\Config\Adapters\ConfigData; -use SP\Domain\Config\Ports\ConfigFileService; -use SP\Domain\Config\Services\ConfigFile; -use SP\Infrastructure\File\FileException; - -use function SPT\getResource; -use function SPT\recreateDir; -use function SPT\saveResource; -use function SPT\setupContext; - -/** - * Class ConfigTest - * - * Test de integración para comprobar el funcionamiento de la clase SP\Config\Config y sus utilidades - * - * @package SPT - */ -class ConfigTest extends TestCase -{ - /** - * @var Container - */ - protected static $dic; - /** - * @var string - */ - protected static $currentConfig; - - /** - * @throws ContextException - */ - public static function setUpBeforeClass(): void - { - self::$dic = setupContext(); - - // Save current config - self::$currentConfig = getResource('config', 'config.xml'); - } - - /** - * This method is called after the last test of this test class is run. - */ - public static function tearDownAfterClass(): void - { - // Restore to the initial state - saveResource('config', 'config.xml', self::$currentConfig); - recreateDir(CACHE_PATH); - } - - /** - * Comprobar la carga de la configuración - * - * @throws DependencyException - * @throws NotFoundException - */ - public function testLoadClass(): ConfigFileService - { - $config = self::$dic->get(ConfigFile::class); - - $this->assertInstanceOf(ConfigFile::class, $config); - $this->assertFileExists(CONFIG_FILE); - - return $config; - } - - /** - * Comprobar que la configuración se guarda correctamente - * - * @depends testLoadClass - * - * @param ConfigFileService $config - * - * @throws FileException - */ - public function testSaveConfig(ConfigFileService $config) - { - $config->save($config->getConfigData(), false); - - $this->assertFileExists(CONFIG_FILE); - } - - - /** - * Comprobar la carga de la configuración en el contexto - * - * @depends testLoadClass - * - * @param ConfigFileService $config - */ - public function testLoadConfig(ConfigFileService $config) - { - $this->assertInstanceOf(ConfigData::class, $config->reload()); - } - - /** - * Comprobar la actualización de la configuración - * - * @depends testLoadClass - * - * @param ConfigFileService $config - */ - public function testUpdateConfig(ConfigFileService $config) - { - $config->update($config->getConfigData()); - - $this->assertEquals(ConfigFile::getTimeUpdated(), $config->getConfigData()->getConfigDate()); - } - - /** - * Comprobar la generación de una clave de actualización y que su longitud es correcta - * - * @depends testLoadClass - * - * @param ConfigFileService $config - * - * @throws EnvironmentIsBrokenException - * @throws FileException - */ - public function testGenerateUpgradeKey(ConfigFileService $config) - { - $config->generateUpgradeKey(); - - $this->assertEquals(32, strlen($config->getConfigData()->getUpgradeKey())); - } -} diff --git a/tests/phpunit.xml b/tests/phpunit.xml index c9f59043..78155f51 100644 --- a/tests/phpunit.xml +++ b/tests/phpunit.xml @@ -4,7 +4,7 @@ ~ ~ @author nuxsmin ~ @link https://syspass.org - ~ @copyright 2012-2023, Rubén Domínguez nuxsmin@$syspass.org + ~ @copyright 2012-2024, Rubén Domínguez nuxsmin@$syspass.org ~ ~ This file is part of sysPass. ~ @@ -40,21 +40,14 @@ - ./SPT - ./SPT/Modules - ./SPT/Services/Install/ - ./SPT/Services/Backup - ./SPT/Generators - ./SPT/Domain/Account/Search/AccountSearchTokenizerDataTrait.php - ./SPT/DatabaseTestCase.php - ./SPT/DatabaseTrait.php - ./SPT/DatabaseUtil.php - ./SPT/PHPUnitHelper.php - ./SPT/UnitaryTestCase.php - ./SPT/bootstrap.php - ./SPT/Stubs/AccountRepositoryStub.php - ./SPT/Stubs/PublicLinkRepositoryStub.php - ./SPT/WebTestCase.php + ./SPT/Core + ./SPT/Domain + ./SPT/Html + ./SPT/Http + ./SPT/Infrastructure + ./SPT/Mvc + ./SPT/Providers + ./SPT/Util ./SPT/Modules/Api