diff --git a/composer.json b/composer.json
index 32b10b58..bc9f90a9 100644
--- a/composer.json
+++ b/composer.json
@@ -32,14 +32,15 @@
},
"require-dev": {
"squizlabs/php_codesniffer": "3.*",
- "phpunit/phpunit": "^6"
+ "phpunit/phpunit": "^6",
+ "phpunit/dbunit": "^3"
},
"autoload": {
"psr-4": {
"SP\\": "lib/SP/",
"SP\\Modules\\Web\\": "app/modules/web/",
"SP\\Modules\\Api\\": "app/modules/api/",
- "Tests\\": "tests"
+ "SP\\Tests\\": "tests"
}
},
"config": {
diff --git a/lib/BaseFunctions.php b/lib/BaseFunctions.php
index 1d8dd867..677fe3be 100644
--- a/lib/BaseFunctions.php
+++ b/lib/BaseFunctions.php
@@ -140,6 +140,7 @@ function mb_ucfirst($string)
*
* @param float $from
* @returns float con el tiempo actual
+ * @return float
*/
function getElapsedTime($from)
{
diff --git a/lib/SP/Config/Config.php b/lib/SP/Config/Config.php
index f4c964ae..d48bff7f 100644
--- a/lib/SP/Config/Config.php
+++ b/lib/SP/Config/Config.php
@@ -28,9 +28,7 @@ use DI\Container;
use ReflectionObject;
use SP\Core\Context\ContextInterface;
use SP\Core\Exceptions\ConfigException;
-use SP\Core\Exceptions\FileNotFoundException;
use SP\Services\Config\ConfigBackupService;
-use SP\Storage\FileCache;
use SP\Storage\FileException;
use SP\Storage\XmlFileStorageInterface;
use SP\Util\Util;
@@ -42,10 +40,6 @@ defined('APP_ROOT') || die();
*/
class Config
{
- /**
- * Cache file name
- */
- const CONFIG_CACHE_FILE = CACHE_PATH . DIRECTORY_SEPARATOR . 'config.cache';
/**
* @var int
*/
@@ -54,10 +48,6 @@ class Config
* @var bool
*/
private static $configLoaded = false;
- /**
- * @var FileCache
- */
- private $fileCache;
/**
* @var ConfigData
*/
@@ -82,15 +72,12 @@ class Config
* @param ContextInterface $session
* @param Container $dic
* @throws ConfigException
- * @throws \DI\DependencyException
- * @throws \DI\NotFoundException
*/
public function __construct(XmlFileStorageInterface $fileStorage, ContextInterface $session, Container $dic)
{
$this->context = $session;
$this->fileStorage = $fileStorage;
$this->dic = $dic;
- $this->fileCache = $dic->get(FileCache::class);
$this->initialize();
}
@@ -104,7 +91,7 @@ class Config
try {
$this->configData = $this->loadConfigFromFile();
- } catch (FileNotFoundException $e) {
+ } catch (FileException $e) {
processException($e);
$this->configData = new ConfigData();
@@ -126,7 +113,7 @@ class Config
*
* @return ConfigData
* @throws ConfigException
- * @throws FileNotFoundException
+ * @throws FileException
*/
public function loadConfigFromFile()
{
@@ -206,7 +193,7 @@ class Config
}
/**
- * Cargar la configuración desde el archivo
+ * Cargar la configuración desde el contexto
*
* @param ContextInterface $context
* @param bool $reload
@@ -261,44 +248,4 @@ class Config
return $this;
}
-
- /**
- * Saves config into the cache file
- */
- private function saveConfigToCache()
- {
- try {
- $this->fileCache->save(self::CONFIG_CACHE_FILE, $this->configData);
-
- debugLog('Saved config cache');
- } catch (FileException $e) {
- processException($e);
- }
- }
-
- /**
- * Loads config from the cache file
- *
- * @return bool
- */
- private function loadConfigFromCache()
- {
- try {
- $configData = $this->fileCache->load(self::CONFIG_CACHE_FILE);
-
- if (!$configData instanceof ConfigData) {
- return false;
- }
-
- $this->configData = $configData;
-
- debugLog('Loaded config cache');
-
- return true;
- } catch (FileException $e) {
- processException($e);
- }
-
- return false;
- }
}
diff --git a/lib/SP/Config/ConfigCache.php b/lib/SP/Config/ConfigCache.php
new file mode 100644
index 00000000..5bfcef1e
--- /dev/null
+++ b/lib/SP/Config/ConfigCache.php
@@ -0,0 +1,94 @@
+.
+ */
+
+namespace SP\Config;
+
+use SP\Storage\FileCache;
+use SP\Storage\FileException;
+
+/**
+ * Class ConfigCache
+ *
+ * @package SP\Config
+ */
+class ConfigCache
+{
+ /**
+ * Cache file name
+ */
+ const CONFIG_CACHE_FILE = CACHE_PATH . DIRECTORY_SEPARATOR . 'config.cache';
+ /**
+ * @var FileCache
+ */
+ private $fileCache;
+
+
+ /**
+ * ConfigCache constructor.
+ *
+ * @param FileCache $fileCache
+ */
+ public function __construct(FileCache $fileCache)
+ {
+ $this->fileCache = $fileCache;
+ }
+
+ /**
+ * Saves config into the cache file
+ *
+ * @param ConfigData $configData
+ */
+ public function saveConfigToCache(ConfigData $configData)
+ {
+ try {
+ $this->fileCache->save(self::CONFIG_CACHE_FILE, $configData);
+
+ debugLog('Saved config cache');
+ } catch (FileException $e) {
+ processException($e);
+ }
+ }
+
+ /**
+ * Loads config from the cache file
+ *
+ * @return ConfigData
+ */
+ public function loadConfigFromCache()
+ {
+ try {
+ $configData = $this->fileCache->load(self::CONFIG_CACHE_FILE);
+
+ if ($configData instanceof ConfigData) {
+ debugLog('Loaded config cache');
+
+ return $configData;
+ }
+ } catch (FileException $e) {
+ processException($e);
+ }
+
+ return null;
+ }
+}
\ No newline at end of file
diff --git a/lib/SP/Services/Install/Installer.php b/lib/SP/Services/Install/Installer.php
index 70c3955a..644003b3 100644
--- a/lib/SP/Services/Install/Installer.php
+++ b/lib/SP/Services/Install/Installer.php
@@ -56,7 +56,7 @@ class Installer extends Service
*/
const VERSION = [3, 0, 0];
const VERSION_TEXT = '3.0-beta';
- const BUILD = 18042501;
+ const BUILD = 18052901;
/**
* @var ConfigService
diff --git a/lib/SP/Storage/FileHandler.php b/lib/SP/Storage/FileHandler.php
index 0c8fc8e5..1e4f88f1 100644
--- a/lib/SP/Storage/FileHandler.php
+++ b/lib/SP/Storage/FileHandler.php
@@ -148,7 +148,7 @@ class FileHandler
*/
public function checkIsWritable()
{
- if (!is_writable($this->file)) {
+ if (!is_writable($this->file) && @touch($this->file) === false) {
throw new FileException(sprintf(__('No es posible escribir el archivo (%s)'), $this->file));
}
diff --git a/lib/SP/Storage/XmlFileStorageInterface.php b/lib/SP/Storage/XmlFileStorageInterface.php
index a4950c94..ece4e2b8 100644
--- a/lib/SP/Storage/XmlFileStorageInterface.php
+++ b/lib/SP/Storage/XmlFileStorageInterface.php
@@ -24,8 +24,6 @@
namespace SP\Storage;
-use SP\Core\Exceptions\FileNotFoundException;
-
/**
* Interface StorageInterface
*
@@ -37,7 +35,7 @@ interface XmlFileStorageInterface
* @param string $node
*
* @return XmlFileStorageInterface
- * @throws FileNotFoundException
+ * @throws FileException
*/
public function load($node = '');
diff --git a/lib/SP/Storage/XmlHandler.php b/lib/SP/Storage/XmlHandler.php
index 3ffd06ae..409fcb16 100644
--- a/lib/SP/Storage/XmlHandler.php
+++ b/lib/SP/Storage/XmlHandler.php
@@ -71,6 +71,7 @@ class XmlHandler implements XmlFileStorageInterface
* @param string $node
* @return XmlFileStorageInterface
* @throws FileException
+ * @throws RuntimeException
*/
public function load($node = 'root')
{
@@ -152,6 +153,7 @@ class XmlHandler implements XmlFileStorageInterface
* @param string $node
* @return XmlFileStorageInterface
* @throws FileException
+ * @throws RuntimeException
*/
public function save($data, $node = 'root')
{
@@ -272,10 +274,12 @@ class XmlHandler implements XmlFileStorageInterface
* Establecer los elementos
*
* @param $items
- * @return mixed
+ * @return XmlHandler
*/
public function setItems($items)
{
$this->items = $items;
+
+ return $this;
}
}
\ No newline at end of file
diff --git a/tests/AccountRepositoryTest.php b/tests/AccountRepositoryTest.php
new file mode 100644
index 00000000..e9dfe4b8
--- /dev/null
+++ b/tests/AccountRepositoryTest.php
@@ -0,0 +1,210 @@
+.
+ */
+
+namespace SP\Tests;
+
+use PHPUnit\DbUnit\Database\Connection;
+use PHPUnit\DbUnit\Database\DefaultConnection;
+use PHPUnit\DbUnit\DataSet\IDataSet;
+use PHPUnit\DbUnit\TestCaseTrait;
+use PHPUnit\Framework\TestCase;
+use SP\Storage\DatabaseConnectionData;
+use SP\Storage\MySQLHandler;
+
+/**
+ * Class AccountRepositoryTest
+ *
+ * Tests unitarios para comprobar las consultas a la BBDD relativas a las cuentas
+ *
+ * @package SP\Tests
+ */
+class AccountRepositoryTest extends TestCase
+{
+ use TestCaseTrait;
+
+ /**
+ * @var \PDO
+ */
+ private static $pdo = null;
+
+ /**
+ * @var DefaultConnection
+ */
+ private $conn = null;
+
+ public function testDelete()
+ {
+
+ }
+
+ public function testEditRestore()
+ {
+
+ }
+
+ public function testEditPassword()
+ {
+
+ }
+
+ public function testGetPasswordForId()
+ {
+
+ }
+
+ public function testCheckInUse()
+ {
+
+ }
+
+ public function testGetById()
+ {
+
+ }
+
+ public function testUpdate()
+ {
+
+ }
+
+ public function testCheckDuplicatedOnAdd()
+ {
+
+ }
+
+ public function testDeleteByIdBatch()
+ {
+
+ }
+
+ public function testSearch()
+ {
+
+ }
+
+ public function testGetLinked()
+ {
+
+ }
+
+ public function testIncrementViewCounter()
+ {
+
+ }
+
+ public function testGetAll()
+ {
+
+ }
+
+ public function testUpdatePassword()
+ {
+
+ }
+
+ public function testIncrementDecryptCounter()
+ {
+
+ }
+
+ public function testGetTotalNumAccounts()
+ {
+
+ }
+
+ public function testGetDataForLink()
+ {
+
+ }
+
+ public function testGetForUser()
+ {
+
+ }
+
+ public function testGetAccountsPassData()
+ {
+
+ }
+
+ public function testCreate()
+ {
+
+ }
+
+ public function testGetByIdBatch()
+ {
+
+ }
+
+ public function testCheckDuplicatedOnUpdate()
+ {
+
+ }
+
+ public function testGetPasswordHistoryForId()
+ {
+
+ }
+
+ public function testGetByFilter()
+ {
+
+ }
+
+ /**
+ * Returns the test database connection.
+ *
+ * @return Connection
+ * @throws \SP\Core\Exceptions\SPException
+ */
+ protected function getConnection()
+ {
+ if ($this->conn === null) {
+ if (self::$pdo === null) {
+ $data = new DatabaseConnectionData();
+ $data->setDbHost('172.19.0.2');
+ $data->setDbName('syspass');
+ $data->setDbUser('root');
+ $data->setDbPass('syspass');
+
+ self::$pdo = (new MySQLHandler($data))->getConnection();
+ }
+
+ $this->conn = $this->createDefaultDBConnection(self::$pdo, 'syspass');
+ }
+
+ return $this->conn;
+ }
+
+ /**
+ * Returns the test dataset.
+ *
+ * @return IDataSet
+ */
+ protected function getDataSet()
+ {
+ return $this->createMySQLXMLDataSet(RESOURCE_DIR . DIRECTORY_SEPARATOR . 'datasets' . DIRECTORY_SEPARATOR . 'syspass.xml');
+ }
+}
diff --git a/tests/ConfigTest.php b/tests/ConfigTest.php
new file mode 100644
index 00000000..240c25fa
--- /dev/null
+++ b/tests/ConfigTest.php
@@ -0,0 +1,157 @@
+.
+ */
+
+namespace SP\Tests;
+
+use DI\Container;
+use DI\ContainerBuilder;
+use DI\DependencyException;
+use DI\NotFoundException;
+use Doctrine\Common\Cache\ArrayCache;
+use PHPUnit\Framework\TestCase;
+use SP\Config\Config;
+use SP\Config\ConfigData;
+use SP\Core\Context\ContextInterface;
+
+/**
+ * Class ConfigTest
+ *
+ * Test de integración para comprobar el funcionamiento de la clase SP\Config\Config y sus utilidades
+ *
+ * @package SP\Tests
+ */
+class ConfigTest extends TestCase
+{
+ /**
+ * @var Container
+ */
+ protected static $dic;
+ /**
+ * @var Config
+ */
+ protected $config;
+
+ /**
+ * @throws DependencyException
+ * @throws NotFoundException
+ * @throws \SP\Core\Context\ContextException
+ */
+ public static function setUpBeforeClass()
+ {
+ // Instancia del contenedor de dependencias con las definiciones de los objetos necesarios
+ // para la aplicación
+ $builder = new ContainerBuilder();
+ $builder->setDefinitionCache(new ArrayCache());
+ $builder->addDefinitions(APP_ROOT . DIRECTORY_SEPARATOR . 'lib' . DIRECTORY_SEPARATOR . 'Definitions.php');
+
+ self::$dic = $builder->build();
+
+ // Inicializar el contexto
+ self::$dic->get(ContextInterface::class)->initialize();
+ }
+
+ /**
+ * This method is called after the last test of this test class is run.
+ */
+ public static function tearDownAfterClass()
+ {
+ @unlink(CONFIG_FILE);
+ }
+
+ /**
+ * Comprobar la carga de la configuración
+ *
+ * @covers \SP\Config\ConfigUtil::checkConfigDir()
+ * @covers \SP\Config\Config::loadConfigFromFile()
+ * @throws DependencyException
+ * @throws NotFoundException
+ */
+ public function testLoadClass()
+ {
+ $config = self::$dic->get(Config::class);
+
+ $this->assertInstanceOf(Config::class, $config);
+ $this->assertFileExists(CONFIG_FILE);
+
+ return $config;
+ }
+
+ /**
+ * Comprobar que la configuración se guarda correctamente
+ *
+ * @depends testLoadClass
+ * @param Config $config
+ */
+ public function testSaveConfig($config)
+ {
+ $config->saveConfig(new ConfigData(), false);
+
+ $this->assertFileExists(CONFIG_FILE);
+ }
+
+
+ /**
+ * Comprobar la carga de la configuración en el contexto
+ *
+ * @depends testLoadClass
+ * @param Config $config
+ * @throws DependencyException
+ * @throws NotFoundException
+ */
+ public function testLoadConfig($config)
+ {
+ $context = self::$dic->get(ContextInterface::class);
+
+ $config->loadConfig($context);
+
+ $this->assertInstanceOf(ConfigData::class, $context->getConfig());
+ }
+
+ /**
+ * Comprobar la actualización de la configuración
+ *
+ * @depends testLoadClass
+ * @param Config $config
+ */
+ public function testUpdateConfig($config)
+ {
+ $config->updateConfig(new ConfigData());
+
+ $this->assertEquals(Config::getTimeUpdated(), $config->getConfigData()->getConfigDate());
+ }
+
+ /**
+ * Comprobar la generación de una clave de actualización y que su longitud es correcta
+ *
+ * @depends testLoadClass
+ * @param Config $config
+ * @throws \Defuse\Crypto\Exception\EnvironmentIsBrokenException
+ */
+ public function testGenerateUpgradeKey($config)
+ {
+ $config->generateUpgradeKey();
+
+ $this->assertEquals(32, strlen($config->getConfigData()->getUpgradeKey()));
+ }
+}
diff --git a/tests/CryptTest.php b/tests/CryptTest.php
index ad700f64..a125e205 100644
--- a/tests/CryptTest.php
+++ b/tests/CryptTest.php
@@ -22,7 +22,7 @@
* along with sysPass. If not, see .
*/
-namespace Tests;
+namespace SP\Tests;
use Defuse\Crypto\Exception\CryptoException;
use PHPUnit\Framework\TestCase;
@@ -33,7 +33,7 @@ use SP\Core\Crypt\Crypt;
*
* Tests unitarios para comprobar el funcionamiento de la clase SP\Core\Crypt\Crypt
*
- * @package Tests
+ * @package SP\Tests
*/
class CryptTest extends TestCase
{
diff --git a/tests/FileHandlerTest.php b/tests/FileHandlerTest.php
index e6ccf5dd..ed712240 100644
--- a/tests/FileHandlerTest.php
+++ b/tests/FileHandlerTest.php
@@ -22,7 +22,7 @@
* along with sysPass. If not, see .
*/
-namespace Tests;
+namespace SP\Tests;
use PHPUnit\Framework\TestCase;
use SP\Storage\FileException;
@@ -32,30 +32,37 @@ use SP\Storage\FileHandler;
* Class FileHandlerTest
*
* Tests unitarios para comprobar el funcionamiento de la clase SP\Storage\FileHandler
+ *
+ * @package SP\Tests
*/
class FileHandlerTest extends TestCase
{
/**
* @var string Archvivo de prueba válido
*/
- protected $validFile;
+ protected static $validFile = RESOURCE_DIR . DIRECTORY_SEPARATOR . 'valid_file.test';
/**
- * @var string Archvivo de prueba inválido
+ * @var string Archvivo de prueba inmutable
*/
- protected $invalidFile;
+ protected static $immutableFile = RESOURCE_DIR . DIRECTORY_SEPARATOR . 'immutable_file.test';
+ /**
+ * @var string Archivo de prueba no existente
+ */
+ protected static $missingFile = RESOURCE_DIR . DIRECTORY_SEPARATOR . 'missing_file.test';
/**
* Comprobar la escritura de texto en un archivo
*
- * @doesNotPerformAssertions
* @throws FileException
*/
public function testWrite()
{
- $handler = new FileHandler($this->validFile);
+ $handler = new FileHandler(self::$validFile);
$handler->write('valid_file');
$this->assertEquals('valid_file', $handler->readString());
$handler->close();
+
+ $this->assertFileExists(self::$validFile);
}
/**
@@ -67,13 +74,13 @@ class FileHandlerTest extends TestCase
*/
public function testCheckIsWritable()
{
- (new FileHandler($this->validFile))
+ (new FileHandler(self::$validFile))
->clearCache()
->checkIsWritable();
$this->expectException(FileException::class);
- (new FileHandler($this->invalidFile))
+ (new FileHandler(self::$immutableFile))
->clearCache()
->checkIsWritable();
}
@@ -86,7 +93,7 @@ class FileHandlerTest extends TestCase
*/
public function testGetFileSize()
{
- $size = (new FileHandler($this->validFile))->getFileSize();
+ $size = (new FileHandler(self::$validFile))->getFileSize();
$this->assertEquals(10, $size);
}
@@ -100,13 +107,13 @@ class FileHandlerTest extends TestCase
*/
public function testCheckFileExists()
{
- (new FileHandler($this->validFile))
+ (new FileHandler(self::$validFile))
->clearCache()
->checkFileExists();
$this->expectException(FileException::class);
- (new FileHandler($this->invalidFile))
+ (new FileHandler(self::$missingFile))
->clearCache()
->checkFileExists();
}
@@ -119,7 +126,7 @@ class FileHandlerTest extends TestCase
*/
public function testOpenAndRead()
{
- $handler = new FileHandler($this->validFile);
+ $handler = new FileHandler(self::$validFile);
$handler->open('rb');
$this->assertEquals('valid_file', $handler->read());
$this->assertEquals('valid_file', $handler->readString());
@@ -133,7 +140,7 @@ class FileHandlerTest extends TestCase
*/
public function testClose()
{
- $handler = new FileHandler($this->validFile);
+ $handler = new FileHandler(self::$validFile);
$handler->open('rb');
$handler->close();
@@ -150,13 +157,11 @@ class FileHandlerTest extends TestCase
*/
public function testCheckIsReadable()
{
- (new FileHandler($this->validFile))
+ (new FileHandler(self::$validFile))
->clearCache()
->checkIsReadable();
- $this->expectException(FileException::class);
-
- (new FileHandler($this->invalidFile))
+ (new FileHandler(self::$immutableFile))
->clearCache()
->checkIsReadable();
}
@@ -170,16 +175,10 @@ class FileHandlerTest extends TestCase
*/
public function testDelete()
{
- (new FileHandler($this->validFile))->delete();
+ (new FileHandler(self::$validFile))->delete();
$this->expectException(FileException::class);
- (new FileHandler($this->invalidFile))->delete();
- }
-
- protected function setUp()
- {
- $this->validFile = TEST_ROOT . DIRECTORY_SEPARATOR . 'res' . DIRECTORY_SEPARATOR . 'valid_file.test';
- $this->invalidFile = TEST_ROOT . DIRECTORY_SEPARATOR . 'res' . DIRECTORY_SEPARATOR . 'invalid_file.test';
+ (new FileHandler(self::$immutableFile))->delete();
}
}
diff --git a/tests/XmlHandlerTest.php b/tests/XmlHandlerTest.php
index d30116ab..472d4f0a 100644
--- a/tests/XmlHandlerTest.php
+++ b/tests/XmlHandlerTest.php
@@ -22,7 +22,7 @@
* along with sysPass. If not, see .
*/
-namespace Tests;
+namespace SP\Tests;
use PHPUnit\Framework\TestCase;
use SP\Storage\FileException;
@@ -34,22 +34,33 @@ use SP\Storage\XmlHandler;
*
* Tests unitarios para comprobar el funcionamiento de la clase SP\Storage\XmlHandler
*
- * @package Tests
+ * @package SP\Tests
*/
class XmlHandlerTest extends TestCase
{
- /**
- * @var array Elementos del archivo XML
- */
- protected $items;
/**
* @var XmlHandler
*/
- protected $xmlHandler;
+ protected static $xmlHandler;
/**
* @var object Objeto con los datos a guardar en el archivo XML
*/
- protected $itemsData;
+ protected static $itemsData;
+ /**
+ * @var array Elementos del archivo XML
+ */
+ protected $items;
+
+ public static function setUpBeforeClass()
+ {
+ $file = RESOURCE_DIR . DIRECTORY_SEPARATOR . 'config.xml';
+ self::$xmlHandler = new XmlHandler(new FileHandler($file));
+
+ self::$itemsData = new \stdClass();
+ self::$itemsData->configString = 'Hello world.';
+ self::$itemsData->configNumber = 1;
+ self::$itemsData->configArray = [1, 2, 3, 4];
+ }
/**
* Test para comprobar el guardado de un archivo XML
@@ -59,7 +70,7 @@ class XmlHandlerTest extends TestCase
*/
public function testSave()
{
- $this->xmlHandler->save($this->itemsData, 'config');
+ self::$xmlHandler->save(self::$itemsData, 'config');
}
/**
@@ -71,7 +82,7 @@ class XmlHandlerTest extends TestCase
{
$this->expectException(\RuntimeException::class);
- $this->xmlHandler->load('root')->getItems();
+ self::$xmlHandler->load('root')->getItems();
}
/**
@@ -82,16 +93,16 @@ class XmlHandlerTest extends TestCase
*/
public function testLoad()
{
- $this->items = $this->xmlHandler->load('config')->getItems();
+ $this->items = self::$xmlHandler->load('config')->getItems();
$this->assertTrue(is_array($this->items));
$this->assertCount(3, $this->items);
- $this->assertSame($this->itemsData->configString, $this->items['configString']);
- $this->assertSame($this->itemsData->configNumber, $this->items['configNumber']);
+ $this->assertSame(self::$itemsData->configString, $this->items['configString']);
+ $this->assertSame(self::$itemsData->configNumber, $this->items['configNumber']);
$this->assertTrue(is_array($this->items['configArray']));
- $this->assertCount(count($this->itemsData->configArray), $this->items['configArray']);
+ $this->assertCount(count(self::$itemsData->configArray), $this->items['configArray']);
}
/**
@@ -104,17 +115,6 @@ class XmlHandlerTest extends TestCase
{
$this->expectException(\RuntimeException::class);
- $this->xmlHandler->save(null, 'config');
- }
-
- protected function setUp()
- {
- $file = TEST_ROOT . DIRECTORY_SEPARATOR . 'res' . DIRECTORY_SEPARATOR . 'config.xml';
- $this->xmlHandler = new XmlHandler(new FileHandler($file));
-
- $this->itemsData = new \stdClass();
- $this->itemsData->configString = 'Hello world.';
- $this->itemsData->configNumber = 1;
- $this->itemsData->configArray = [1, 2, 3, 4];
+ self::$xmlHandler->save(null, 'config');
}
}
\ No newline at end of file
diff --git a/tests/bootstrap.php b/tests/bootstrap.php
index 16aa5f10..11a7585b 100644
--- a/tests/bootstrap.php
+++ b/tests/bootstrap.php
@@ -22,11 +22,19 @@
* along with sysPass. If not, see .
*/
+define('APP_MODULE', 'tests');
+
define('APP_ROOT', dirname(__DIR__));
define('TEST_ROOT', dirname(__DIR__) . DIRECTORY_SEPARATOR . 'tests');
+define('RESOURCE_DIR', TEST_ROOT . DIRECTORY_SEPARATOR . 'res');
+
+define('CONFIG_PATH', RESOURCE_DIR . DIRECTORY_SEPARATOR . 'config');
+define('CONFIG_FILE', CONFIG_PATH . DIRECTORY_SEPARATOR . 'config.xml');
+
+define('ACTIONS_FILE', CONFIG_PATH . DIRECTORY_SEPARATOR . 'actions.xml');
-require APP_ROOT . DIRECTORY_SEPARATOR . 'lib' . DIRECTORY_SEPARATOR . 'BaseFunctions.php';
require APP_ROOT . DIRECTORY_SEPARATOR . 'vendor' . DIRECTORY_SEPARATOR . 'autoload.php';
+require APP_ROOT . DIRECTORY_SEPARATOR . 'lib' . DIRECTORY_SEPARATOR . 'BaseFunctions.php';
/**
* Función para llamadas a gettext
diff --git a/tests/res/config/actions.xml b/tests/res/config/actions.xml
new file mode 100644
index 00000000..26205c98
--- /dev/null
+++ b/tests/res/config/actions.xml
@@ -0,0 +1,832 @@
+
+
+
+
+ 1
+ ACCOUNT_SEARCH
+ Buscar Cuentas
+ account/search
+
+
+ 10
+ ACCOUNT
+ Cuentas
+ account/index
+
+
+ 11
+ ACCOUNT_FILE
+ Archivos
+ account/listFile
+
+
+ 12
+ ACCOUNT_REQUEST
+ Peticiones
+ account/requestAccess
+
+
+ 13
+ ACCOUNT_FAVORITE
+ Favoritos
+ favorite/index
+
+
+ 20
+ WIKI
+ Wiki
+ wiki/index
+
+
+ 60
+ ITEMS_MANAGE
+ Elementos y Personalización
+ itemManager/index
+
+
+ 61
+ CATEGORY
+ Gestión Categorías
+ category/index
+
+
+ 62
+ CLIENT
+ Gestión Clientes
+ client/index
+
+
+ 63
+ AUTHTOKEN
+ Gestión Autorizaciones API
+ authToken/index
+
+
+ 64
+ CUSTOMFIELD
+ Gestión Campos Personalizados
+ customField/index
+
+
+ 65
+ PUBLICLINK
+ Enlaces Públicos
+ publicLink/index
+
+
+ 66
+ FILE
+ Gestión de Archivos
+ file/index
+
+
+ 67
+ ACCOUNTMGR
+ Gestión de Cuentas
+ accountManager/index
+
+
+ 68
+ TAG
+ Gestión de Etiquetas
+ tag/index
+
+
+ 69
+ PLUGIN
+ Gestión Plugins
+ plugin/index
+
+
+ 70
+ ACCESS_MANAGE
+ Usuarios y Accesos
+ accessManager/index
+
+
+ 71
+ USER
+ Gestión Usuarios
+ user/index
+
+
+ 72
+ GROUP
+ Gestión Grupos
+ group/index
+
+
+ 73
+ PROFILE
+ Gestión Perfiles
+ profile/index
+
+
+ 90
+ EVENTLOG
+ Registro de Eventos
+ eventlog/index
+
+
+ 905
+ EVENTLOG_SEARCH
+ Buscar Eventos
+ eventlog/search
+
+
+ 906
+ EVENTLOG_CLEAR
+ Limpiar Eventos
+ eventlog/clear
+
+
+ 100
+ ACCOUNT_VIEW
+ Ver Cuenta
+ account/view
+
+
+ 101
+ ACCOUNT_CREATE
+ Nueva Cuenta
+ account/create
+
+
+ 102
+ ACCOUNT_EDIT
+ Editar Cuenta
+ account/edit
+
+
+ 103
+ ACCOUNT_DELETE
+ Eliminar Cuenta
+ account/delete
+
+
+ 104
+ ACCOUNT_VIEW_PASS
+ Ver Clave
+ account/viewPass
+
+
+ 106
+ ACCOUNT_EDIT_PASS
+ Editar Clave de Cuenta
+ account/editPass
+
+
+ 107
+ ACCOUNT_EDIT_RESTORE
+ Restaurar Cuenta
+ account/restore
+
+
+ 108
+ ACCOUNT_COPY
+ Copiar Cuenta
+ account/copy
+
+
+ 109
+ ACCOUNT_COPY_PASS
+ Copiar Clave
+ account/copyPass
+
+
+ 111
+ ACCOUNT_FILE_VIEW
+ Ver Archivo
+ accountFile/view
+
+
+ 112
+ ACCOUNT_FILE_UPLOAD
+ Subir Archivo
+ accountFile/upload
+
+
+ 113
+ ACCOUNT_FILE_DOWNLOAD
+ Descargar Archivo
+ accountFile/download
+
+
+ 114
+ ACCOUNT_FILE_DELETE
+ Eliminar Archivo
+ accountFile/delete
+
+
+ 115
+ ACCOUNT_FILE_SEARCH
+ Buscar Archivos
+ accountFile/search
+
+
+ 116
+ ACCOUNT_FILE_LIST
+ Listar Archivos
+ accountFile/list
+
+
+ 130
+ ACCOUNT_FAVORITE_VIEW
+ Ver Favoritos
+ favorite/view
+
+
+ 131
+ ACCOUNT_FAVORITE_ADD
+ Añadir Favorito
+ accountFavorite/mark
+
+
+ 133
+ ACCOUNT_FAVORITE_DELETE
+ Eliminar Favorito
+ accountFavorite/unmark
+
+
+ 140
+ ACCOUNT_HISTORY_VIEW
+ Ver Historial
+ account/viewHistory
+
+
+ 141
+ ACCOUNT_HISTORY_VIEW_PASS
+ Ver Clave
+ account/viewPassHistory
+
+
+ 142
+ ACCOUNT_HISTORY_COPY_PASS
+ Copiar Clave
+ account/copyPassHistory
+
+
+ 200
+ WIKI_VIEW
+ Ver Wiki
+ wiki/view
+
+
+ 201
+ WIKI_NEW
+ Añadir Wiki
+ wiki/create
+
+
+ 202
+ WIKI_EDIT
+ Editar Wiki
+ wiki/edit
+
+
+ 203
+ WIKI_DELETE
+ Eliminar Wiki
+ wiki/delete
+
+
+ 610
+ CATEGORY_VIEW
+ Ver Categoría
+ category/view
+
+
+ 611
+ CATEGORY_CREATE
+ Nueva Categoría
+ category/create
+
+
+ 612
+ CATEGORY_EDIT
+ Editar Categoría
+ category/edit
+
+
+ 613
+ CATEGORY_DELETE
+ Eliminar Categoría
+ category/delete
+
+
+ 615
+ CATEGORY_SEARCH
+ Buscar Categoría
+ category/search
+
+
+ 620
+ CLIENT_VIEW
+ Ver Cliente
+ client/view
+
+
+ 621
+ CLIENT_CREATE
+ Nuevo CLiente
+ client/create
+
+
+ 622
+ CLIENT_EDIT
+ Editar Cliente
+ client/edit
+
+
+ 623
+ CLIENT_DELETE
+ Eliminar Cliente
+ client/delete
+
+
+ 625
+ CLIENT_SEARCH
+ Buscar Cliente
+ client/search
+
+
+ 630
+ AUTHTOKEN_CREATE
+ Nuevo Token API
+ authToken/create
+
+
+ 631
+ AUTHTOKEN_VIEW
+ Ver Token API
+ authToken/view
+
+
+ 632
+ AUTHTOKEN_EDIT
+ Editar Token API
+ authToken/edit
+
+
+ 633
+ AUTHTOKEN_DELETE
+ Eliminar Token API
+ authToken/delete
+
+
+ 635
+ AUTHTOKEN_SEARCH
+ Buscar Token API
+ authToken/search
+
+
+ 640
+ CUSTOMFIELD_CREATE
+ Nuevo Campo Personalizado
+ customField/create
+
+
+ 641
+ CUSTOMFIELD_VIEW
+ Ver Campo Personalizado
+ customField/view
+
+
+ 642
+ CUSTOMFIELD_EDIT
+ Editar Campo Personalizado
+ customField/edit
+
+
+ 643
+ CUSTOMFIELD_DELETE
+ Eliminar Campo Personalizado
+ customField/delete
+
+
+ 645
+ CUSTOMFIELD_SEARCH
+ Buscar Campo Personalizado
+ customField/search
+
+
+ 650
+ PUBLICLINK_CREATE
+ Crear Enlace Público
+ publicLink/create
+
+
+ 651
+ PUBLICLINK_VIEW
+ Ver Enlace Público
+ publicLink/view
+
+
+ 653
+ PUBLICLINK_DELETE
+ Eliminar Enlace Público
+ publicLink/delete
+
+
+ 654
+ PUBLICLINK_REFRESH
+ Actualizar Enlace Público
+ publicLink/refresh
+
+
+ 655
+ PUBLICLINK_SEARCH
+ Buscar Enlace Público
+ publicLink/search
+
+
+ 661
+ FILE_VIEW
+ Ver Archivo
+ file/view
+
+
+ 662
+ FILE_DOWNLOAD
+ Descargar Archivo
+ file/download
+
+
+ 663
+ FILE_DELETE
+ Eliminar Archivo
+ file/delete
+
+
+ 664
+ FILE_UPLOAD
+ Subir Archivo
+ file/upload
+
+
+ 665
+ FILE_SEARCH
+ Buscar Archivo
+ file/search
+
+
+ 671
+ ACCOUNTMGR_VIEW
+ Ver Cuenta
+ accountManager/view
+
+
+ 673
+ ACCOUNTMGR_DELETE
+ Eliminar Cuenta
+ accountManager/delete
+
+
+ 675
+ ACCOUNTMGR_SEARCH
+ Buscar Cuenta
+ accountManager/search
+
+
+ 680
+ TAG_CREATE
+ Nueva Etiqueta
+ tag/create
+
+
+ 681
+ TAG_VIEW
+ Ver Etiqueta
+ tag/view
+
+
+ 682
+ TAG_EDIT
+ Editar Etiqueta
+ tag/edit
+
+
+ 683
+ TAG_DELETE
+ Eliminar Etiqueta
+ tag/delete
+
+
+ 685
+ TAG_SEARCH
+ Buscar Etiqueta
+ tag/search
+
+
+ 690
+ PLUGIN_NEW
+ Nuevo Plugin
+ plugin/create
+
+
+ 691
+ PLUGIN_VIEW
+ Ver Plugin
+ plugin/view
+
+
+ 695
+ PLUGIN_SEARCH
+ Buscar Plugin
+ plugin/search
+
+
+ 696
+ PLUGIN_ENABLE
+ Habilitar Plugin
+ plugin/enable
+
+
+ 697
+ PLUGIN_DISABLE
+ Deshabilitar Plugin
+ plugin/disable
+
+
+ 698
+ PLUGIN_RESET
+ Restablecer Plugin
+ plugin/reset
+
+
+ 710
+ USER_VIEW
+ Ver Usuario
+ user/view
+
+
+ 711
+ USER_CREATE
+ Nuevo Usuario
+ user/create
+
+
+ 712
+ USER_EDIT
+ Editar Usuario
+ user/edit
+
+
+ 713
+ USER_DELETE
+ Eliminar Usuario
+ user/delete
+
+
+ 714
+ USER_EDIT_PASS
+ Editar Clave Usuario
+ user/editPass
+
+
+ 715
+ USER_SEARCH
+ Buscar Usuario
+ user/search
+
+
+ 720
+ GROUP_VIEW
+ Ver Grupo
+ userGroup/view
+
+
+ 721
+ GROUP_CREATE
+ Nuevo Grupo
+ userGroup/create
+
+
+ 722
+ GROUP_EDIT
+ Editar Grupo
+ userGroup/edit
+
+
+ 723
+ GROUP_DELETE
+ Eliminar Grupo
+ userGroup/delete
+
+
+ 725
+ GROUP_SEARCH
+ Buscar Grupo
+ userGroup/search
+
+
+ 730
+ PROFILE_VIEW
+ Ver Perfil
+ userProfile/view
+
+
+ 731
+ PROFILE_CREATE
+ Nuevo Perfil
+ userProfile/create
+
+
+ 732
+ PROFILE_EDIT
+ Editar Perfil
+ userProfile/edit
+
+
+ 733
+ PROFILE_DELETE
+ Eliminar Perfil
+ userProfile/delete
+
+
+ 735
+ PROFILE_SEARCH
+ Buscar Perfil
+ userProfile/search
+
+
+ 74
+ USERSETTINGS
+ Configuración Usuario
+ userSettingsManager/index
+
+
+ 741
+ USERSETTINGS_GENERAL
+ Preferencias General
+ userSettings/general
+
+
+ 76
+ NOTIFICATION
+ Notificaciones
+ notification/index
+
+
+ 1000
+ CONFIG
+ Configuración
+ configManager/index
+
+
+ 1001
+ CONFIG_GENERAL
+ Configuración General
+ configManager/general
+
+
+ 1010
+ ACCOUNT_CONFIG
+ Configuración Cuentas
+ account/config
+
+
+ 1020
+ WIKI_CONFIG
+ Configuración Wiki
+ wiki/config
+
+
+ 1030
+ ENCRYPTION_CONFIG
+ Configuración Encriptación
+ encryption/config
+
+
+ 1031
+ ENCRYPTION_REFRESH
+ Actualizar Hash
+ encryption/updateHash
+
+
+ 1032
+ ENCRYPTION_TEMPPASS
+ Clave Maestra Temporal
+ encryption/createTempPass
+
+
+ 1040
+ BACKUP_CONFIG
+ Configuración Copia de Seguridad
+ backup/config
+
+
+ 1041
+ BACKUP
+ Copia de Seguridad
+ backup/backup
+
+
+ 1050
+ IMPORT_CONFIG
+ Configuración Importación
+ import/config
+
+
+ 1051
+ IMPORT_CSV
+ Importar CSV
+ import/csv
+
+
+ 1052
+ IMPORT_XML
+ Importar XML
+ import/xml
+
+
+ 1060
+ EXPORT_CONFIG
+ Configuración Exportación
+ export/config
+
+
+ 1061
+ EXPORT
+ Exportación
+ export/export
+
+
+ 1070
+ MAIL_CONFIG
+ Configuración Email
+ mail/config
+
+
+ 1080
+ LDAP_CONFIG
+ Configuración LDAP
+ ldap/config
+
+
+ 1081
+ LDAP_SYNC
+ Sincronización LDAP
+ ldap/sync
+
+
+ 6701
+ ACCOUNTMGR_HISTORY
+ Gestión de Cuenta (H)
+ accountHistoryManager/index
+
+
+ 6731
+ ACCOUNTMGR_DELETE_HISTORY
+ Eliminar Cuenta
+ accountHistoryManager/delete
+
+
+ 6751
+ ACCOUNTMGR_SEARCH_HISTORY
+ Buscar Cuenta
+ accountHistoryManager/search
+
+
+ 6771
+ ACCOUNTMGR_RESTORE
+ Restaurar Cuenta
+ accountManager/restore
+
+
+ 760
+ NOTIFICATION_VIEW
+ Ver Notificación
+ notification/view
+
+
+ 761
+ NOTIFICATION_CREATE
+ Crear Notificación
+ notification/create
+
+
+ 762
+ NOTIFICATION_EDIT
+ Editar Notificación
+ notification/edit
+
+
+ 763
+ NOTIFICATION_DELETE
+ Eliminar Notificación
+ notification/delete
+
+
+ 764
+ NOTIFICATION_CHECK
+ Marcar Notificación
+ notification/check
+
+
+ 765
+ NOTIFICATION_SEARCH
+ Buscar Notificación
+ notification/search
+
+
\ No newline at end of file