From 096076053277bb924a41cbc3ad9df8e4746176e5 Mon Sep 17 00:00:00 2001 From: nuxsmin Date: Mon, 23 Jul 2018 21:52:50 +0200 Subject: [PATCH] * [ADD] Updated database structure * [MOD] Unit testing. Work in progress --- .../CustomField/CustomFieldDefRepository.php | 3 +-- lib/SP/Storage/Database/Database.php | 4 ++-- schemas/30018072302.sql | 6 +++++- schemas/dbstructure.sql | 8 +++++--- test/SP/Config/ConfigTest.php | 2 -- test/SP/Core/Crypt/CryptTest.php | 5 ----- test/SP/Core/Crypt/VaultTest.php | 4 ---- .../SP/Repositories/AccountRepositoryTest.php | 5 ----- .../AccountToTagRepositoryTest.php | 2 -- .../AccountToUserGroupRepositoryTest.php | 6 ------ .../AccountToUserRepositoryTest.php | 6 ------ .../Repositories/AuthTokenRepositoryTest.php | 6 ------ .../Repositories/CategoryRepositoryTest.php | 4 ---- test/SP/Repositories/ClientRepositoryTest.php | 4 ---- .../CustomFieldDefRepositoryTest.php | 1 - .../CustomFieldTypeRepositoryTest.php | 2 -- .../NotificationRepositoryTest.php | 4 ---- test/SP/Repositories/PluginRepositoryTest.php | 4 ---- .../Repositories/PublicLinkRepositoryTest.php | 20 +++++++++++++++---- test/SP/Repositories/TagRepositoryTest.php | 4 ---- test/SP/Repositories/TrackRepositoryTest.php | 1 - .../Repositories/UserGroupRepositoryTest.php | 2 -- .../UserProfileRepositoryTest.php | 1 - test/SP/Repositories/UserRepositoryTest.php | 3 --- .../Services/Account/AccountServiceTest.php | 7 +------ test/SP/Services/Install/MySQLTest.php | 2 ++ test/SP/Storage/FileHandlerTest.php | 9 --------- test/SP/Storage/XmlHandlerTest.php | 2 -- test/res/config/config.xml | 8 ++++---- test/res/datasets/syspass_accountFile.xml | 20 +++++++++++++++++++ test/res/datasets/syspass_accountHistory.xml | 17 ++++++++++++++++ 31 files changed, 73 insertions(+), 99 deletions(-) diff --git a/lib/SP/Repositories/CustomField/CustomFieldDefRepository.php b/lib/SP/Repositories/CustomField/CustomFieldDefRepository.php index c818de38..81ab2309 100644 --- a/lib/SP/Repositories/CustomField/CustomFieldDefRepository.php +++ b/lib/SP/Repositories/CustomField/CustomFieldDefRepository.php @@ -100,8 +100,7 @@ class CustomFieldDefRepository extends Repository implements RepositoryItemInter `help` = ?, showInList = ?, typeId = ?, - isEncrypted = ?, - field = NULL + isEncrypted = ? WHERE id = ? LIMIT 1'; $queryData = new QueryData(); diff --git a/lib/SP/Storage/Database/Database.php b/lib/SP/Storage/Database/Database.php index cf22882e..a2b004ea 100644 --- a/lib/SP/Storage/Database/Database.php +++ b/lib/SP/Storage/Database/Database.php @@ -267,8 +267,8 @@ class Database implements DatabaseInterface } catch (\Exception $e) { processException($e); - switch ($e->getCode()) { - case '23000': + switch ((int)$e->getCode()) { + case 23000: throw new ConstraintException( __u('Restricción de integridad'), ConstraintException::ERROR, diff --git a/schemas/30018072302.sql b/schemas/30018072302.sql index 2457c57f..1d3a4db7 100644 --- a/schemas/30018072302.sql +++ b/schemas/30018072302.sql @@ -31,4 +31,8 @@ ALTER TABLE User MODIFY hashSalt varbinary(255) NOT NULL; ALTER TABLE UserPassRecover - MODIFY hash varbinary(255) NOT NULL; \ No newline at end of file + MODIFY hash varbinary(255) NOT NULL; + +ALTER TABLE Notification + ADD CONSTRAINT fk_Notificationt_userId +FOREIGN KEY (userId) REFERENCES User (id) ON DELETE CASCADE ON UPDATE CASCADE; \ No newline at end of file diff --git a/schemas/dbstructure.sql b/schemas/dbstructure.sql index a2a37b81..718ec1a6 100644 --- a/schemas/dbstructure.sql +++ b/schemas/dbstructure.sql @@ -350,9 +350,11 @@ CREATE TABLE `Notification` ( `onlyAdmin` tinyint(1) DEFAULT 0, PRIMARY KEY (`id`), KEY `idx_Notification_01` (`userId`, `checked`, `date`), - KEY `idx_Notification_02` (`component`, `date`, `checked`, `userId`) + KEY `idx_Notification_02` (`component`, `date`, `checked`, `userId`), + KEY `fk_Notification_userId` (`userId`), + CONSTRAINT `fk_Notification_userId` FOREIGN KEY (`userId`) REFERENCES `User` (`id`) ) - ENGINE = MyISAM + ENGINE = InnoDB DEFAULT CHARSET = utf8; /*!40101 SET character_set_client = @saved_cs_client */; DROP TABLE IF EXISTS `Plugin`; @@ -367,7 +369,7 @@ CREATE TABLE `Plugin` ( PRIMARY KEY (`id`), UNIQUE KEY `uk_Plugin_01` (`name`) ) - ENGINE = MyISAM + ENGINE = InnoDB DEFAULT CHARSET = utf8; /*!40101 SET character_set_client = @saved_cs_client */; DROP TABLE IF EXISTS `PublicLink`; diff --git a/test/SP/Config/ConfigTest.php b/test/SP/Config/ConfigTest.php index a7655d54..3bc54ce7 100644 --- a/test/SP/Config/ConfigTest.php +++ b/test/SP/Config/ConfigTest.php @@ -76,8 +76,6 @@ class ConfigTest extends TestCase /** * Comprobar la carga de la configuración * - * @covers \SP\Config\ConfigUtil::checkConfigDir() - * @covers \SP\Config\Config::loadConfigFromFile() * @throws DependencyException * @throws NotFoundException */ diff --git a/test/SP/Core/Crypt/CryptTest.php b/test/SP/Core/Crypt/CryptTest.php index a7a859e8..4d48d57a 100644 --- a/test/SP/Core/Crypt/CryptTest.php +++ b/test/SP/Core/Crypt/CryptTest.php @@ -71,7 +71,6 @@ class CryptTest extends TestCase * Comprobar el desbloqueo de una llave de cifrado * * @depends testMakeSecuredKey - * @covers \SP\Core\Crypt\Crypt::unlockSecuredKey * * @param string $key LLave de cifrado * @@ -88,8 +87,6 @@ class CryptTest extends TestCase * Comprobar la encriptación y desencriptado de datos * * @depends testMakeSecuredKey - * @covers \SP\Core\Crypt\Crypt::encrypt - * @covers \SP\Core\Crypt\Crypt::decrypt * * @param string $key LLave de cifrado * @@ -106,8 +103,6 @@ class CryptTest extends TestCase * Comprobar la encriptación y desencriptado de datos * * @depends testMakeSecuredKey - * @covers \SP\Core\Crypt\Crypt::encrypt - * @covers \SP\Core\Crypt\Crypt::decrypt * * @param string $key LLave de cifrado * diff --git a/test/SP/Core/Crypt/VaultTest.php b/test/SP/Core/Crypt/VaultTest.php index 73a677de..810ad119 100644 --- a/test/SP/Core/Crypt/VaultTest.php +++ b/test/SP/Core/Crypt/VaultTest.php @@ -52,7 +52,6 @@ class VaultTest extends TestCase } /** - * @covers \SP\Core\Crypt\Vault::saveData() * @throws \Defuse\Crypto\Exception\CryptoException */ public function testGetData() @@ -70,7 +69,6 @@ class VaultTest extends TestCase /** - * @covers \SP\Core\Crypt\Vault::saveData() * @throws \Defuse\Crypto\Exception\CryptoException */ public function testGetTimeSet() @@ -81,7 +79,6 @@ class VaultTest extends TestCase } /** - * @covers \SP\Core\Crypt\Vault::saveData() * @throws \Defuse\Crypto\Exception\CryptoException */ public function testReKey() @@ -97,7 +94,6 @@ class VaultTest extends TestCase } /** - * @covers \SP\Core\Crypt\Vault::saveData() * @throws \Defuse\Crypto\Exception\CryptoException */ public function testGetTimeUpdated() diff --git a/test/SP/Repositories/AccountRepositoryTest.php b/test/SP/Repositories/AccountRepositoryTest.php index 2c45cc4f..89a52750 100644 --- a/test/SP/Repositories/AccountRepositoryTest.php +++ b/test/SP/Repositories/AccountRepositoryTest.php @@ -106,7 +106,6 @@ class AccountRepositoryTest extends DatabaseTestCase /** * Comprobar la modificación de una clave de cuenta * - * @covers \SP\Repositories\Account\AccountRepository::getPasswordForId() * @throws SPException * @throws \Defuse\Crypto\Exception\CryptoException * @throws \SP\Core\Exceptions\ConstraintException @@ -154,7 +153,6 @@ class AccountRepositoryTest extends DatabaseTestCase } /** - * @depends testGetById * @throws SPException */ public function testUpdate() @@ -280,7 +278,6 @@ class AccountRepositoryTest extends DatabaseTestCase /** * Comprobar en incremento del contador de vistas * - * @depends testGetById * @throws \SP\Core\Exceptions\ConstraintException * @throws \SP\Core\Exceptions\QueryException * @throws SPException @@ -321,7 +318,6 @@ class AccountRepositoryTest extends DatabaseTestCase } /** - * @covers \SP\Repositories\Account\AccountRepository::getPasswordForId() * @throws SPException * @throws \Defuse\Crypto\Exception\CryptoException * @throws \SP\Core\Exceptions\ConstraintException @@ -346,7 +342,6 @@ class AccountRepositoryTest extends DatabaseTestCase /** * Comprobar en incremento del contador de desencriptado * - * @depends testGetById * @throws SPException * @throws \SP\Core\Exceptions\ConstraintException * @throws \SP\Core\Exceptions\QueryException diff --git a/test/SP/Repositories/AccountToTagRepositoryTest.php b/test/SP/Repositories/AccountToTagRepositoryTest.php index 43d6c72b..46b38ece 100644 --- a/test/SP/Repositories/AccountToTagRepositoryTest.php +++ b/test/SP/Repositories/AccountToTagRepositoryTest.php @@ -80,7 +80,6 @@ class AccountToTagRepositoryTest extends DatabaseTestCase /** * Comprobar la creación de etiquetas asociadas a las cuentas * - * @depends testGetTagsByAccountId * @throws \SP\Core\Exceptions\ConstraintException * @throws \SP\Core\Exceptions\QueryException */ @@ -130,7 +129,6 @@ class AccountToTagRepositoryTest extends DatabaseTestCase /** * Comprobar la actualización de etiquetas por Id de cuenta * - * @depends testGetTagsByAccountId * @throws \SP\Core\Exceptions\ConstraintException * @throws \SP\Core\Exceptions\QueryException */ diff --git a/test/SP/Repositories/AccountToUserGroupRepositoryTest.php b/test/SP/Repositories/AccountToUserGroupRepositoryTest.php index 57bea8fe..1a5490ef 100644 --- a/test/SP/Repositories/AccountToUserGroupRepositoryTest.php +++ b/test/SP/Repositories/AccountToUserGroupRepositoryTest.php @@ -115,7 +115,6 @@ class AccountToUserGroupRepositoryTest extends DatabaseTestCase /** * Comprobar la actualización de grupos de usuarios por Id de cuenta * - * @depends testGetUserGroupsByAccountId * @throws \SP\Core\Exceptions\ConstraintException * @throws \SP\Core\Exceptions\QueryException */ @@ -153,7 +152,6 @@ class AccountToUserGroupRepositoryTest extends DatabaseTestCase /** * Comprobar la actualización de grupos de usuarios con permisos de modificación por Id de cuenta * - * @depends testGetUserGroupsByAccountId * @throws \SP\Core\Exceptions\ConstraintException * @throws \SP\Core\Exceptions\QueryException */ @@ -191,7 +189,6 @@ class AccountToUserGroupRepositoryTest extends DatabaseTestCase /** * Comprobar la eliminación de grupos de usuarios por Id de cuenta * - * @depends testGetUserGroupsByAccountId * @throws \SP\Core\Exceptions\ConstraintException * @throws \SP\Core\Exceptions\QueryException */ @@ -208,7 +205,6 @@ class AccountToUserGroupRepositoryTest extends DatabaseTestCase /** * Comprobar la insercción de grupos de usuarios con permisos de modificación por Id de cuenta * - * @depends testGetUserGroupsByAccountId * @throws \SP\Core\Exceptions\ConstraintException * @throws \SP\Core\Exceptions\QueryException */ @@ -245,7 +241,6 @@ class AccountToUserGroupRepositoryTest extends DatabaseTestCase /** * Comprobar la insercción de grupos de usuarios por Id de cuenta * - * @depends testGetUserGroupsByAccountId * @throws \SP\Core\Exceptions\ConstraintException * @throws \SP\Core\Exceptions\QueryException */ @@ -285,7 +280,6 @@ class AccountToUserGroupRepositoryTest extends DatabaseTestCase /** * Comprobar la eliminación de grupos de usuarios con permisos de modificación por Id de cuenta * - * @depends testGetUserGroupsByAccountId * @throws \SP\Core\Exceptions\ConstraintException * @throws \SP\Core\Exceptions\QueryException */ diff --git a/test/SP/Repositories/AccountToUserRepositoryTest.php b/test/SP/Repositories/AccountToUserRepositoryTest.php index ebe5e993..e0f37c9f 100644 --- a/test/SP/Repositories/AccountToUserRepositoryTest.php +++ b/test/SP/Repositories/AccountToUserRepositoryTest.php @@ -115,7 +115,6 @@ class AccountToUserRepositoryTest extends DatabaseTestCase /** * Comprobar la actualización de usuarios por Id de cuenta * - * @depends testGetUsersByAccountId * @throws \SP\Core\Exceptions\ConstraintException * @throws \SP\Core\Exceptions\QueryException */ @@ -152,7 +151,6 @@ class AccountToUserRepositoryTest extends DatabaseTestCase /** * Comprobar la actualización de usuarios con permisos de modificación por Id de cuenta * - * @depends testGetUsersByAccountId * @throws \SP\Core\Exceptions\ConstraintException * @throws \SP\Core\Exceptions\QueryException */ @@ -189,7 +187,6 @@ class AccountToUserRepositoryTest extends DatabaseTestCase /** * Comprobar la eliminación de usuarios por Id de cuenta * - * @depends testGetUsersByAccountId * @throws \SP\Core\Exceptions\ConstraintException * @throws \SP\Core\Exceptions\QueryException */ @@ -206,7 +203,6 @@ class AccountToUserRepositoryTest extends DatabaseTestCase /** * Comprobar la insercción de usuarios con permisos de modificación por Id de cuenta * - * @depends testGetUsersByAccountId * @throws \SP\Core\Exceptions\ConstraintException * @throws \SP\Core\Exceptions\QueryException */ @@ -242,7 +238,6 @@ class AccountToUserRepositoryTest extends DatabaseTestCase /** * Comprobar la insercción de usuarios por Id de cuenta * - * @depends testGetUsersByAccountId * @throws \SP\Core\Exceptions\ConstraintException * @throws \SP\Core\Exceptions\QueryException */ @@ -278,7 +273,6 @@ class AccountToUserRepositoryTest extends DatabaseTestCase /** * Comprobar la eliminación de usuarios con permisos de modificación por Id de cuenta * - * @depends testGetUsersByAccountId * @throws \SP\Core\Exceptions\ConstraintException * @throws \SP\Core\Exceptions\QueryException */ diff --git a/test/SP/Repositories/AuthTokenRepositoryTest.php b/test/SP/Repositories/AuthTokenRepositoryTest.php index 07e3be8f..7baacebc 100644 --- a/test/SP/Repositories/AuthTokenRepositoryTest.php +++ b/test/SP/Repositories/AuthTokenRepositoryTest.php @@ -138,7 +138,6 @@ class AuthTokenRepositoryTest extends DatabaseTestCase } /** - * @depends testGetTokenByToken * @throws CryptoException * @throws \SP\Core\Exceptions\ConstraintException * @throws \SP\Core\Exceptions\QueryException @@ -168,7 +167,6 @@ class AuthTokenRepositoryTest extends DatabaseTestCase } /** - * @depends testGetTokenByUserId * @throws \Defuse\Crypto\Exception\EnvironmentIsBrokenException * @throws \SP\Core\Exceptions\ConstraintException * @throws \SP\Core\Exceptions\QueryException @@ -187,8 +185,6 @@ class AuthTokenRepositoryTest extends DatabaseTestCase } /** - * @covers \SP\Repositories\AuthToken\AuthTokenRepository::checkDuplicatedOnUpdate() - * @depends testGetTokenByToken * @throws \Defuse\Crypto\Exception\EnvironmentIsBrokenException * @throws \SP\Core\Exceptions\ConstraintException * @throws \SP\Core\Exceptions\QueryException @@ -300,8 +296,6 @@ class AuthTokenRepositoryTest extends DatabaseTestCase } /** - * @covers \SP\Repositories\AuthToken\AuthTokenRepository::checkDuplicatedOnAdd() - * * @throws CryptoException * @throws \Defuse\Crypto\Exception\EnvironmentIsBrokenException * @throws \SP\Core\Exceptions\ConstraintException diff --git a/test/SP/Repositories/CategoryRepositoryTest.php b/test/SP/Repositories/CategoryRepositoryTest.php index 0e387d43..68e924b7 100644 --- a/test/SP/Repositories/CategoryRepositoryTest.php +++ b/test/SP/Repositories/CategoryRepositoryTest.php @@ -181,8 +181,6 @@ class CategoryRepositoryTest extends DatabaseTestCase /** * Comprobar la actualización de categorías * - * @depends testGetById - * @covers \SP\Repositories\Category\CategoryRepository::checkDuplicatedOnUpdate() * @throws \SP\Core\Exceptions\ConstraintException * @throws \SP\Core\Exceptions\QueryException * @throws \SP\Core\Exceptions\SPException @@ -238,8 +236,6 @@ class CategoryRepositoryTest extends DatabaseTestCase /** * Comprobar la creación de categorías * - * @depends testGetById - * @covers \SP\Repositories\Category\CategoryRepository::checkDuplicatedOnAdd() * @throws DuplicatedItemException * @throws \SP\Core\Exceptions\SPException */ diff --git a/test/SP/Repositories/ClientRepositoryTest.php b/test/SP/Repositories/ClientRepositoryTest.php index ddbb72c7..bbcd55e7 100644 --- a/test/SP/Repositories/ClientRepositoryTest.php +++ b/test/SP/Repositories/ClientRepositoryTest.php @@ -175,8 +175,6 @@ class ClientRepositoryTest extends DatabaseTestCase /** * Comprobar la actualización de clientes * - * @depends testGetById - * @covers \SP\Repositories\Client\ClientRepository::checkDuplicatedOnUpdate() * @throws \SP\Core\Exceptions\ConstraintException * @throws \SP\Core\Exceptions\QueryException * @throws \SP\Core\Exceptions\SPException @@ -231,8 +229,6 @@ class ClientRepositoryTest extends DatabaseTestCase /** * Comprobar la creación de clientes * - * @depends testGetById - * @covers \SP\Repositories\Client\ClientRepository::checkDuplicatedOnAdd() * @throws DuplicatedItemException * @throws \SP\Core\Exceptions\SPException */ diff --git a/test/SP/Repositories/CustomFieldDefRepositoryTest.php b/test/SP/Repositories/CustomFieldDefRepositoryTest.php index 817b0b1d..8bb7d7dc 100644 --- a/test/SP/Repositories/CustomFieldDefRepositoryTest.php +++ b/test/SP/Repositories/CustomFieldDefRepositoryTest.php @@ -89,7 +89,6 @@ class CustomFieldDefRepositoryTest extends DatabaseTestCase } /** - * @depends testGetById * @throws \SP\Core\Exceptions\ConstraintException * @throws \SP\Core\Exceptions\QueryException * @throws NoSuchItemException diff --git a/test/SP/Repositories/CustomFieldTypeRepositoryTest.php b/test/SP/Repositories/CustomFieldTypeRepositoryTest.php index 7e478832..769695d5 100644 --- a/test/SP/Repositories/CustomFieldTypeRepositoryTest.php +++ b/test/SP/Repositories/CustomFieldTypeRepositoryTest.php @@ -132,7 +132,6 @@ class CustomFieldTypeRepositoryTest extends DatabaseTestCase } /** - * @depends testGetById * @throws ConstraintException * @throws \SP\Core\Exceptions\QueryException * @throws \SP\Core\Exceptions\SPException @@ -149,7 +148,6 @@ class CustomFieldTypeRepositoryTest extends DatabaseTestCase } /** - * @depends testGetById * @throws ConstraintException * @throws \SP\Core\Exceptions\QueryException * @throws \SP\Core\Exceptions\SPException diff --git a/test/SP/Repositories/NotificationRepositoryTest.php b/test/SP/Repositories/NotificationRepositoryTest.php index 2cf14536..cd5048f4 100644 --- a/test/SP/Repositories/NotificationRepositoryTest.php +++ b/test/SP/Repositories/NotificationRepositoryTest.php @@ -134,7 +134,6 @@ class NotificationRepositoryTest extends DatabaseTestCase } /** - * @depends testGetById * @throws \SP\Core\Exceptions\ConstraintException * @throws \SP\Core\Exceptions\QueryException */ @@ -217,7 +216,6 @@ class NotificationRepositoryTest extends DatabaseTestCase } /** - * @depends testGetById * @throws \SP\Core\Exceptions\ConstraintException * @throws \SP\Core\Exceptions\QueryException */ @@ -387,8 +385,6 @@ class NotificationRepositoryTest extends DatabaseTestCase } /** - * @depends testSetCheckedById - * * @throws ConstraintException * @throws QueryException */ diff --git a/test/SP/Repositories/PluginRepositoryTest.php b/test/SP/Repositories/PluginRepositoryTest.php index e0e7741b..873ce1c1 100644 --- a/test/SP/Repositories/PluginRepositoryTest.php +++ b/test/SP/Repositories/PluginRepositoryTest.php @@ -141,7 +141,6 @@ class PluginRepositoryTest extends DatabaseTestCase } /** - * @depends testGetByName * @throws ConstraintException * @throws \SP\Core\Exceptions\QueryException */ @@ -234,7 +233,6 @@ class PluginRepositoryTest extends DatabaseTestCase } /** - * @depends testGetById * @throws ConstraintException * @throws \SP\Core\Exceptions\QueryException */ @@ -261,7 +259,6 @@ class PluginRepositoryTest extends DatabaseTestCase } /** - * @depends testGetById * @throws ConstraintException * @throws \SP\Core\Exceptions\QueryException */ @@ -273,7 +270,6 @@ class PluginRepositoryTest extends DatabaseTestCase } /** - * @depends testGetById * @throws ConstraintException * @throws \SP\Core\Exceptions\QueryException */ diff --git a/test/SP/Repositories/PublicLinkRepositoryTest.php b/test/SP/Repositories/PublicLinkRepositoryTest.php index fc8196e0..5da3c292 100644 --- a/test/SP/Repositories/PublicLinkRepositoryTest.php +++ b/test/SP/Repositories/PublicLinkRepositoryTest.php @@ -150,7 +150,6 @@ class PublicLinkRepositoryTest extends DatabaseTestCase } /** - * @covers \SP\Repositories\PublicLink\PublicLinkRepository::checkDuplicatedOnAdd() * @throws \Defuse\Crypto\Exception\EnvironmentIsBrokenException * @throws \SP\Core\Exceptions\ConstraintException * @throws \SP\Core\Exceptions\QueryException @@ -307,7 +306,6 @@ class PublicLinkRepositoryTest extends DatabaseTestCase } /** - * @depends testGetById * @throws ConstraintException * @throws \SP\Core\Exceptions\QueryException * @throws \SP\Core\Exceptions\SPException @@ -334,12 +332,26 @@ class PublicLinkRepositoryTest extends DatabaseTestCase $this->expectException(ConstraintException::class); - $data->setId(3); + $data->setId(2); self::$repository->refresh($data); + } - $data->setId(1); + /** + * @throws ConstraintException + * @throws \SP\Core\Exceptions\QueryException + * @throws \SP\Core\Exceptions\SPException + */ + public function testRefreshNullHash() + { + $data = new PublicLinkData(); $data->setHash(null); + $data->setDateExpire(time() + 3600); + $data->setMaxCountViews(6); + $data->setData('data_new'); + $data->setId(1); + + $this->expectException(ConstraintException::class); self::$repository->refresh($data); } diff --git a/test/SP/Repositories/TagRepositoryTest.php b/test/SP/Repositories/TagRepositoryTest.php index b913db97..549509c1 100644 --- a/test/SP/Repositories/TagRepositoryTest.php +++ b/test/SP/Repositories/TagRepositoryTest.php @@ -144,8 +144,6 @@ class TagRepositoryTest extends DatabaseTestCase /** * Comprobar la actualización de etiquetas * - * @depends testGetById - * @covers \SP\Repositories\Category\CategoryRepository::checkDuplicatedOnUpdate() * @throws \SP\Core\Exceptions\ConstraintException * @throws \SP\Core\Exceptions\QueryException * @throws \SP\Core\Exceptions\SPException @@ -189,8 +187,6 @@ class TagRepositoryTest extends DatabaseTestCase /** * Comprobar la creación de etiquetas * - * @depends testGetById - * @covers \SP\Repositories\Category\CategoryRepository::checkDuplicatedOnAdd() * @throws DuplicatedItemException * @throws \SP\Core\Exceptions\SPException */ diff --git a/test/SP/Repositories/TrackRepositoryTest.php b/test/SP/Repositories/TrackRepositoryTest.php index bf39f838..cc9e7728 100644 --- a/test/SP/Repositories/TrackRepositoryTest.php +++ b/test/SP/Repositories/TrackRepositoryTest.php @@ -97,7 +97,6 @@ class TrackRepositoryTest extends DatabaseTestCase } /** - * @depends testGetById * @throws \SP\Core\Exceptions\ConstraintException * @throws \SP\Core\Exceptions\QueryException * @throws \SP\Core\Exceptions\InvalidArgumentException diff --git a/test/SP/Repositories/UserGroupRepositoryTest.php b/test/SP/Repositories/UserGroupRepositoryTest.php index 4285bb01..354b89c4 100644 --- a/test/SP/Repositories/UserGroupRepositoryTest.php +++ b/test/SP/Repositories/UserGroupRepositoryTest.php @@ -129,7 +129,6 @@ class UserGroupRepositoryTestCase extends DatabaseTestCase /** * Comprobar la actualización de grupos * - * @covers \SP\Repositories\UserGroup\UserGroupRepository::checkDuplicatedOnUpdate() * @throws ConstraintException * @throws DuplicatedItemException * @throws QueryException @@ -171,7 +170,6 @@ class UserGroupRepositoryTestCase extends DatabaseTestCase /** * Comprobar la creación de grupos * - * @covers \SP\Repositories\UserGroup\UserGroupRepository::checkDuplicatedOnAdd() * @throws ConstraintException * @throws QueryException * @throws \SP\Core\Exceptions\SPException diff --git a/test/SP/Repositories/UserProfileRepositoryTest.php b/test/SP/Repositories/UserProfileRepositoryTest.php index b77c297a..fb632053 100644 --- a/test/SP/Repositories/UserProfileRepositoryTest.php +++ b/test/SP/Repositories/UserProfileRepositoryTest.php @@ -118,7 +118,6 @@ class UserProfileRepositoryTest extends DatabaseTestCase /** * Comprobar la actualización de perfiles * - * @covers \SP\Repositories\UserGroup\UserGroupRepository::checkDuplicatedOnUpdate() * @throws ConstraintException * @throws DuplicatedItemException * @throws QueryException diff --git a/test/SP/Repositories/UserRepositoryTest.php b/test/SP/Repositories/UserRepositoryTest.php index 0bcae010..3976819d 100644 --- a/test/SP/Repositories/UserRepositoryTest.php +++ b/test/SP/Repositories/UserRepositoryTest.php @@ -76,7 +76,6 @@ class UserRepositoryTest extends DatabaseTestCase /** * Comprobar la actualización de usuarios * - * @covers \SP\Repositories\User\UserRepository::checkDuplicatedOnUpdate() * @throws \SP\Core\Exceptions\ConstraintException * @throws \SP\Core\Exceptions\QueryException * @throws \SP\Core\Exceptions\SPException @@ -352,7 +351,6 @@ class UserRepositoryTest extends DatabaseTestCase } /** - * @depends testGetById * @throws ConstraintException * @throws QueryException * @throws \Defuse\Crypto\Exception\CryptoException @@ -374,7 +372,6 @@ class UserRepositoryTest extends DatabaseTestCase /** * Comprobar la creación de usuarios * - * @covers \SP\Repositories\User\UserRepository::checkDuplicatedOnAdd() * @throws \SP\Core\Exceptions\SPException */ public function testCreate() diff --git a/test/SP/Services/Account/AccountServiceTest.php b/test/SP/Services/Account/AccountServiceTest.php index fe2b3945..b4550e62 100644 --- a/test/SP/Services/Account/AccountServiceTest.php +++ b/test/SP/Services/Account/AccountServiceTest.php @@ -73,9 +73,6 @@ class AccountServiceTest extends DatabaseTestCase } /** - * @covers \SP\Services\Account\AccountService::withTagsById() - * @covers \SP\Services\Account\AccountService::withUsersById() - * @covers \SP\Services\Account\AccountService::withUserGroupsById() * @throws \SP\Core\Exceptions\ConstraintException * @throws \SP\Core\Exceptions\QueryException * @throws \SP\Core\Exceptions\SPException @@ -290,12 +287,11 @@ class AccountServiceTest extends DatabaseTestCase } /** - * @covers \SP\Services\Account\AccountService::getPasswordForId() * @throws NoSuchItemException - * @throws ServiceException * @throws \Defuse\Crypto\Exception\CryptoException * @throws \SP\Core\Exceptions\ConstraintException * @throws \SP\Core\Exceptions\QueryException + * @throws \Exception */ public function testEditPassword() { @@ -322,7 +318,6 @@ class AccountServiceTest extends DatabaseTestCase } /** - * @covers \SP\Services\Account\AccountService::getById() * @throws NoSuchItemException * @throws \SP\Core\Exceptions\ConstraintException * @throws \SP\Core\Exceptions\QueryException diff --git a/test/SP/Services/Install/MySQLTest.php b/test/SP/Services/Install/MySQLTest.php index f1c6e65f..9a0f88a0 100644 --- a/test/SP/Services/Install/MySQLTest.php +++ b/test/SP/Services/Install/MySQLTest.php @@ -49,6 +49,8 @@ class MySQLTest extends TestCase */ public function testCheckDatabaseNotExist() { + $this->dropDatabase(self::DB_NAME); + $mysql = new MySQL($this->getParams(), new ConfigData()); $this->assertFalse($mysql->checkDatabaseExist()); diff --git a/test/SP/Storage/FileHandlerTest.php b/test/SP/Storage/FileHandlerTest.php index da7c557e..53ccd117 100644 --- a/test/SP/Storage/FileHandlerTest.php +++ b/test/SP/Storage/FileHandlerTest.php @@ -70,8 +70,6 @@ class FileHandlerTest extends TestCase /** * Comprobar si es posible escribir en el archivo * - * @depends testWrite - * @doesNotPerformAssertions * @throws FileException */ public function testCheckIsWritable() @@ -86,7 +84,6 @@ class FileHandlerTest extends TestCase /** * Comprobar el tamaño del archivo * - * @depends testWrite * @throws FileException */ public function testGetFileSize() @@ -99,7 +96,6 @@ class FileHandlerTest extends TestCase /** * Comprobar un archivo válido * - * @depends testWrite * @doesNotPerformAssertions * @throws FileException */ @@ -119,7 +115,6 @@ class FileHandlerTest extends TestCase /** * Abrir un archivo * - * @depends testWrite * @throws FileException */ public function testOpenAndRead() @@ -133,7 +128,6 @@ class FileHandlerTest extends TestCase /** * Comprobar a cerrar un archivo * - * @depends testWrite * @throws FileException */ public function testClose() @@ -149,7 +143,6 @@ class FileHandlerTest extends TestCase /** * Comprobar si es posible leer el archivo * - * @depends testWrite * @doesNotPerformAssertions * @throws FileException */ @@ -167,8 +160,6 @@ class FileHandlerTest extends TestCase /** * Comprobar la eliminación de un archivo * - * @depends testWrite - * @doesNotPerformAssertions * @throws FileException */ public function testDelete() diff --git a/test/SP/Storage/XmlHandlerTest.php b/test/SP/Storage/XmlHandlerTest.php index c0422623..38b02ca5 100644 --- a/test/SP/Storage/XmlHandlerTest.php +++ b/test/SP/Storage/XmlHandlerTest.php @@ -88,7 +88,6 @@ class XmlHandlerTest extends TestCase /** * Test para comprobar la carga de un archivo XML * - * @depends testSave * @throws FileException */ public function testLoad() @@ -108,7 +107,6 @@ class XmlHandlerTest extends TestCase /** * Test para comprobar el guardado de un archivo XML * - * @depends testLoad * @throws FileException */ public function testSaveNoItems() diff --git a/test/res/config/config.xml b/test/res/config/config.xml index ff1eae35..0debbb4c 100644 --- a/test/res/config/config.xml +++ b/test/res/config/config.xml @@ -9,11 +9,11 @@ 1 1 - c79d69a2c0092ccc288fd5b3d56a434e2f0e4f75 + 7073a41c8032d93be23cda9eea07f9c3527f54da 0 0 - 1532369257 - 92e386c54329fda42f58da43ed2f587ea0cb1cb9 + 1532375214 + a4658216020fa81739ab6f100a0d96170a0e5f90 @@ -32,7 +32,7 @@ 0 - ff02ccd71fc8d53ff49d25069933be16be661ba0 + 7768216134c3c60d24989d670ed6e26d3006347a PDF JPG diff --git a/test/res/datasets/syspass_accountFile.xml b/test/res/datasets/syspass_accountFile.xml index 6ce75401..6aafee5a 100644 --- a/test/res/datasets/syspass_accountFile.xml +++ b/test/res/datasets/syspass_accountFile.xml @@ -24,6 +24,26 @@ 1 + + + 1 + Web + Web sites + 3235363761356563393730356562376163326339383430333365303631383964 + + + 2 + Linux + Linux server + 6532303661353465393736393063636535306363383732646437306565383936 + + + 3 + SSH + SSH access + 3137383764373634363330346335643938376366346536346133393733646337 + + 1 diff --git a/test/res/datasets/syspass_accountHistory.xml b/test/res/datasets/syspass_accountHistory.xml index fdd5b282..aa59705f 100644 --- a/test/res/datasets/syspass_accountHistory.xml +++ b/test/res/datasets/syspass_accountHistory.xml @@ -21,6 +21,23 @@ 3137383764373634363330346335643938376366346536346133393733646337 + + + 1 + Admins + sysPass Admins + + + 2 + Demo + + + + 3 + Usuarios + Grupo Usuarios + + 1