mirror of
https://github.com/nuxsmin/sysPass.git
synced 2026-03-24 09:07:18 +01:00
chore(tests): UT for Database service
Signed-off-by: Rubén D <nuxsmin@syspass.org>
This commit is contained in:
@@ -81,7 +81,7 @@ use SP\Http\Request;
|
||||
use SP\Infrastructure\Database\Database;
|
||||
use SP\Infrastructure\Database\DatabaseConnectionData;
|
||||
use SP\Infrastructure\Database\DatabaseInterface;
|
||||
use SP\Infrastructure\Database\DbStorageInterface;
|
||||
use SP\Infrastructure\Database\DbStorageHandler;
|
||||
use SP\Infrastructure\Database\MysqlHandler;
|
||||
use SP\Infrastructure\File\DirectoryHandler;
|
||||
use SP\Infrastructure\File\FileCache;
|
||||
@@ -141,7 +141,7 @@ final class CoreDefinitions
|
||||
),
|
||||
ConfigDataInterface::class => factory([ConfigFileService::class, 'getConfigData']),
|
||||
DatabaseConnectionData::class => factory([DatabaseConnectionData::class, 'getFromConfig']),
|
||||
DbStorageInterface::class => autowire(MysqlHandler::class),
|
||||
DbStorageHandler::class => autowire(MysqlHandler::class),
|
||||
ActionsInterface::class =>
|
||||
static fn() => new Actions(
|
||||
new FileCache(Actions::ACTIONS_CACHE_FILE),
|
||||
|
||||
@@ -153,7 +153,7 @@ final class BackupFile implements BackupFileService
|
||||
|
||||
$fileHandler->open('w');
|
||||
|
||||
$dbname = $this->database->getDbHandler()->getDatabaseName();
|
||||
$dbname = $this->configData->getDbName();
|
||||
|
||||
$sqlOut = [
|
||||
'-- ',
|
||||
@@ -179,7 +179,7 @@ final class BackupFile implements BackupFileService
|
||||
foreach ($tables as $table) {
|
||||
$query = Query::buildForMySQL(sprintf('SHOW CREATE TABLE %s', $table), []);
|
||||
|
||||
$data = $this->database->doQuery(QueryData::build($query))->getData();
|
||||
$data = $this->database->runQuery(QueryData::build($query))->getData();
|
||||
|
||||
$sqlOut = [
|
||||
'-- ',
|
||||
@@ -196,7 +196,7 @@ final class BackupFile implements BackupFileService
|
||||
foreach ($views as $view) {
|
||||
$query = Query::buildForMySQL(sprintf('SHOW CREATE TABLE %s', $view), []);
|
||||
|
||||
$data = $this->database->doQuery(QueryData::build($query))->getData();
|
||||
$data = $this->database->runQuery(QueryData::build($query))->getData();
|
||||
|
||||
$sqlOut = [
|
||||
'-- ',
|
||||
@@ -215,13 +215,14 @@ final class BackupFile implements BackupFileService
|
||||
$query = Query::buildForMySQL(sprintf('SELECT * FROM `%s`', $table), []);
|
||||
|
||||
// Get table records
|
||||
$statement = $this->database->doQueryRaw(
|
||||
$rows = $this->database->doFetchWithOptions(
|
||||
QueryData::build($query),
|
||||
[PDO::ATTR_CURSOR => PDO::CURSOR_SCROLL],
|
||||
PDO::FETCH_NUM,
|
||||
false
|
||||
);
|
||||
|
||||
while ($row = $statement->fetch(PDO::FETCH_NUM)) {
|
||||
foreach ($rows as $row) {
|
||||
$values = array_map(
|
||||
function (mixed $value) {
|
||||
if (is_numeric($value)) {
|
||||
|
||||
@@ -30,7 +30,7 @@ use SP\Domain\Core\Exceptions\SPException;
|
||||
use SP\Domain\Install\Adapters\InstallData;
|
||||
use SP\Infrastructure\Database\DatabaseFileInterface;
|
||||
use SP\Infrastructure\Database\DatabaseUtil;
|
||||
use SP\Infrastructure\Database\DbStorageInterface;
|
||||
use SP\Infrastructure\Database\DbStorageHandler;
|
||||
use SP\Infrastructure\File\FileException;
|
||||
use SP\Util\PasswordUtil;
|
||||
|
||||
@@ -52,7 +52,7 @@ final class MysqlService implements DatabaseSetupInterface
|
||||
*
|
||||
*/
|
||||
public function __construct(
|
||||
private readonly DbStorageInterface $dbStorage,
|
||||
private readonly DbStorageHandler $dbStorage,
|
||||
private readonly InstallData $installData,
|
||||
private readonly DatabaseFileInterface $databaseFile,
|
||||
private readonly DatabaseUtil $databaseUtil
|
||||
|
||||
@@ -159,7 +159,7 @@ final class UpgradeDatabase extends Service implements UpgradeDatabaseService
|
||||
);
|
||||
|
||||
// Direct PDO handling
|
||||
$this->database->getDbHandler()->getConnection()->exec($query);
|
||||
$this->database->runQueryRaw($query);
|
||||
} catch (Exception $e) {
|
||||
processException($e);
|
||||
|
||||
|
||||
@@ -73,7 +73,7 @@ final class Account extends BaseRepository implements AccountRepository
|
||||
->cols(['SUM(n) AS num'])
|
||||
->fromSubSelect('SELECT COUNT(*) AS n FROM Account UNION SELECT COUNT(*) AS n FROM AccountHistory', 'a');
|
||||
|
||||
return $this->db->doSelect(QueryData::build($query));
|
||||
return $this->db->runQuery(QueryData::build($query));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -97,7 +97,7 @@ final class Account extends BaseRepository implements AccountRepository
|
||||
->bindValues(['id' => $accountId])
|
||||
->limit(1);
|
||||
|
||||
return $this->db->doSelect(QueryData::build($query)->setMapClassName(AccountModel::class));
|
||||
return $this->db->runQuery(QueryData::build($query)->setMapClassName(AccountModel::class));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -121,7 +121,7 @@ final class Account extends BaseRepository implements AccountRepository
|
||||
->where('AccountHistory.accountId = :accountId')
|
||||
->bindValues(['accountId' => $accountId]);
|
||||
|
||||
return $this->db->doSelect(QueryData::build($query));
|
||||
return $this->db->runQuery(QueryData::build($query));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -142,7 +142,7 @@ final class Account extends BaseRepository implements AccountRepository
|
||||
->where('id = :id')
|
||||
->bindValues(['id' => $accountId]);
|
||||
|
||||
return $this->db->doQuery(QueryData::build($query));
|
||||
return $this->db->runQuery(QueryData::build($query));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -165,7 +165,7 @@ final class Account extends BaseRepository implements AccountRepository
|
||||
|
||||
$queryData = QueryData::build($query)->setOnErrorMessage(__u('Error while creating the account'));
|
||||
|
||||
return $this->db->doQuery($queryData);
|
||||
return $this->db->runQuery($queryData);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -186,7 +186,7 @@ final class Account extends BaseRepository implements AccountRepository
|
||||
|
||||
$queryData = QueryData::build($query)->setOnErrorMessage(__u('Error while creating the account'));
|
||||
|
||||
return $this->db->doQuery($queryData);
|
||||
return $this->db->runQuery($queryData);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -212,7 +212,7 @@ final class Account extends BaseRepository implements AccountRepository
|
||||
|
||||
$queryData = QueryData::build($query)->setOnErrorMessage(__u('Error while updating the password'));
|
||||
|
||||
return $this->db->doQuery($queryData);
|
||||
return $this->db->runQuery($queryData);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -236,7 +236,7 @@ final class Account extends BaseRepository implements AccountRepository
|
||||
|
||||
$queryData = QueryData::build($query)->setOnErrorMessage(__u('Error while updating the password'));
|
||||
|
||||
return $this->db->doQuery($queryData);
|
||||
return $this->db->runQuery($queryData);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -273,7 +273,7 @@ final class Account extends BaseRepository implements AccountRepository
|
||||
|
||||
$queryData = QueryData::build($query)->setOnErrorMessage(__u('Error on restoring the account'));
|
||||
|
||||
return $this->db->doQuery($queryData);
|
||||
return $this->db->runQuery($queryData);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -295,7 +295,7 @@ final class Account extends BaseRepository implements AccountRepository
|
||||
|
||||
$queryData = QueryData::build($query)->setOnErrorMessage(__u('Error while deleting the account'));
|
||||
|
||||
return $this->db->doQuery($queryData);
|
||||
return $this->db->runQuery($queryData);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -346,7 +346,7 @@ final class Account extends BaseRepository implements AccountRepository
|
||||
|
||||
$queryData = QueryData::build($query)->setOnErrorMessage(__u('Error while updating the account'));
|
||||
|
||||
return $this->db->doQuery($queryData);
|
||||
return $this->db->runQuery($queryData);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -398,7 +398,7 @@ final class Account extends BaseRepository implements AccountRepository
|
||||
|
||||
$queryData = QueryData::build($query)->setOnErrorMessage(__u('Error while updating the account'));
|
||||
|
||||
return $this->db->doQuery($queryData);
|
||||
return $this->db->runQuery($queryData);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -421,7 +421,7 @@ final class Account extends BaseRepository implements AccountRepository
|
||||
$queryData = QueryData::buildWithMapper($query, AccountViewModel::class)
|
||||
->setOnErrorMessage(__u('Error while retrieving account\'s data'));
|
||||
|
||||
return $this->db->doSelect($queryData);
|
||||
return $this->db->runQuery($queryData);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -444,7 +444,7 @@ final class Account extends BaseRepository implements AccountRepository
|
||||
$queryData = QueryData::buildWithMapper($query, AccountModel::class)
|
||||
->setOnErrorMessage(__u('Error while retrieving account\'s data'));
|
||||
|
||||
return $this->db->doSelect($queryData);
|
||||
return $this->db->runQuery($queryData);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -459,7 +459,7 @@ final class Account extends BaseRepository implements AccountRepository
|
||||
->from('Account')
|
||||
->cols(AccountModel::getCols(['pass', 'key']));
|
||||
|
||||
return $this->db->doSelect(QueryData::buildWithMapper($query, AccountModel::class));
|
||||
return $this->db->runQuery(QueryData::buildWithMapper($query, AccountModel::class));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -484,7 +484,7 @@ final class Account extends BaseRepository implements AccountRepository
|
||||
|
||||
$queryData = QueryData::build($query)->setOnErrorMessage(__u('Error while deleting the accounts'));
|
||||
|
||||
return $this->db->doQuery($queryData);
|
||||
return $this->db->runQuery($queryData);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -522,7 +522,7 @@ final class Account extends BaseRepository implements AccountRepository
|
||||
]);
|
||||
}
|
||||
|
||||
return $this->db->doSelect(QueryData::buildWithMapper($query, AccountSearchViewModel::class), true);
|
||||
return $this->db->runQuery(QueryData::buildWithMapper($query, AccountSearchViewModel::class), true);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -543,7 +543,7 @@ final class Account extends BaseRepository implements AccountRepository
|
||||
->where('id = :id')
|
||||
->bindValues(['id' => $accountId]);
|
||||
|
||||
return $this->db->doQuery(QueryData::build($query));
|
||||
return $this->db->runQuery(QueryData::build($query));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -575,7 +575,7 @@ final class Account extends BaseRepository implements AccountRepository
|
||||
|
||||
$queryData = QueryData::build($query)->setOnErrorMessage(__u('Error while retrieving account\'s data'));
|
||||
|
||||
return $this->db->doSelect($queryData);
|
||||
return $this->db->runQuery($queryData);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -602,7 +602,7 @@ final class Account extends BaseRepository implements AccountRepository
|
||||
->bindValues(['id' => $accountId]);
|
||||
}
|
||||
|
||||
return $this->db->doSelect(QueryData::build($query));
|
||||
return $this->db->runQuery(QueryData::build($query));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -624,7 +624,7 @@ final class Account extends BaseRepository implements AccountRepository
|
||||
->bindValues(['parentId' => $accountId])
|
||||
->orderBy(['Account.name ASC']);
|
||||
|
||||
return $this->db->doSelect(QueryData::build($query));
|
||||
return $this->db->runQuery(QueryData::build($query));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -645,6 +645,6 @@ final class Account extends BaseRepository implements AccountRepository
|
||||
])
|
||||
->where('BIT_LENGTH(pass) > 0');
|
||||
|
||||
return $this->db->doSelect(QueryData::buildWithMapper($query, AccountModel::class));
|
||||
return $this->db->runQuery(QueryData::buildWithMapper($query, AccountModel::class));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -70,7 +70,7 @@ final class AccountFile extends BaseRepository implements AccountFileRepository
|
||||
]);
|
||||
$queryData = QueryData::build($query)->setOnErrorMessage(__u('Error while saving file'));
|
||||
|
||||
return $this->db->doQuery($queryData)->getLastId();
|
||||
return $this->db->runQuery($queryData)->getLastId();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -103,7 +103,7 @@ final class AccountFile extends BaseRepository implements AccountFileRepository
|
||||
->bindValues(['id' => $id])
|
||||
->limit(1);
|
||||
|
||||
return $this->db->doSelect(QueryData::build($query));
|
||||
return $this->db->runQuery(QueryData::build($query));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -133,7 +133,7 @@ final class AccountFile extends BaseRepository implements AccountFileRepository
|
||||
->orderBy(['name ASC'])
|
||||
->limit(1);
|
||||
|
||||
return $this->db->doSelect(QueryData::build($query));
|
||||
return $this->db->runQuery(QueryData::build($query));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -155,7 +155,7 @@ final class AccountFile extends BaseRepository implements AccountFileRepository
|
||||
|
||||
$queryData = QueryData::build($query)->setOnErrorMessage(__u('Error while deleting the file'));
|
||||
|
||||
return $this->db->doQuery($queryData)->getAffectedNumRows() === 1;
|
||||
return $this->db->runQuery($queryData)->getAffectedNumRows() === 1;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -180,7 +180,7 @@ final class AccountFile extends BaseRepository implements AccountFileRepository
|
||||
|
||||
$queryData = QueryData::build($query)->setOnErrorMessage(__u('Error while deleting the files'));
|
||||
|
||||
return $this->db->doQuery($queryData)->getAffectedNumRows();
|
||||
return $this->db->runQuery($queryData)->getAffectedNumRows();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -228,6 +228,6 @@ final class AccountFile extends BaseRepository implements AccountFileRepository
|
||||
]);
|
||||
}
|
||||
|
||||
return $this->db->doSelect(QueryData::build($query), true);
|
||||
return $this->db->runQuery(QueryData::build($query), true);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -71,7 +71,7 @@ final class AccountHistory extends BaseRepository implements AccountHistoryRepos
|
||||
->bindValues(['id' => $id])
|
||||
->orderBy(['Account.id DESC']);
|
||||
|
||||
return $this->db->doSelect(QueryData::build($query));
|
||||
return $this->db->runQuery(QueryData::build($query));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -121,7 +121,7 @@ final class AccountHistory extends BaseRepository implements AccountHistoryRepos
|
||||
|
||||
$queryData = QueryData::build($query)->setOnErrorMessage(__u('Error while updating history'));
|
||||
|
||||
return $this->db->doQuery($queryData)->getLastId();
|
||||
return $this->db->runQuery($queryData)->getLastId();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -143,7 +143,7 @@ final class AccountHistory extends BaseRepository implements AccountHistoryRepos
|
||||
|
||||
$queryData = QueryData::build($query)->setOnErrorMessage(__u('Error while deleting the account'));
|
||||
|
||||
return $this->db->doQuery($queryData)->getAffectedNumRows() === 1;
|
||||
return $this->db->runQuery($queryData)->getAffectedNumRows() === 1;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -204,7 +204,7 @@ final class AccountHistory extends BaseRepository implements AccountHistoryRepos
|
||||
|
||||
$queryData = QueryData::build($query)->setOnErrorMessage(__u('Error while retrieving account\'s data'));
|
||||
|
||||
return $this->db->doSelect($queryData);
|
||||
return $this->db->runQuery($queryData);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -259,7 +259,7 @@ final class AccountHistory extends BaseRepository implements AccountHistoryRepos
|
||||
->join('LEFT', 'User AS UserEdit', 'Account.userEditId = UserEdit.id')
|
||||
->orderBy(['Account.id DESC']);
|
||||
|
||||
return $this->db->doSelect(QueryData::build($query));
|
||||
return $this->db->runQuery(QueryData::build($query));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -284,7 +284,7 @@ final class AccountHistory extends BaseRepository implements AccountHistoryRepos
|
||||
|
||||
$queryData = QueryData::build($query)->setOnErrorMessage(__u('Error while deleting the accounts'));
|
||||
|
||||
return $this->db->doQuery($queryData)->getAffectedNumRows();
|
||||
return $this->db->runQuery($queryData)->getAffectedNumRows();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -309,7 +309,7 @@ final class AccountHistory extends BaseRepository implements AccountHistoryRepos
|
||||
|
||||
$queryData = QueryData::build($query)->setOnErrorMessage(__u('Error while deleting the accounts'));
|
||||
|
||||
return $this->db->doQuery($queryData)->getAffectedNumRows();
|
||||
return $this->db->runQuery($queryData)->getAffectedNumRows();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -352,7 +352,7 @@ final class AccountHistory extends BaseRepository implements AccountHistoryRepos
|
||||
]);
|
||||
}
|
||||
|
||||
return $this->db->doSelect(QueryData::build($query), true);
|
||||
return $this->db->runQuery(QueryData::build($query), true);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -377,7 +377,7 @@ final class AccountHistory extends BaseRepository implements AccountHistoryRepos
|
||||
->where('BIT_LENGTH(pass) > 0')
|
||||
->orderBy(['id ASC']);
|
||||
|
||||
return $this->db->doSelect(QueryData::build($query));
|
||||
return $this->db->runQuery(QueryData::build($query));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -405,6 +405,6 @@ final class AccountHistory extends BaseRepository implements AccountHistoryRepos
|
||||
|
||||
$queryData = QueryData::build($query)->setOnErrorMessage(__u('Error while updating the password'));
|
||||
|
||||
return $this->db->doQuery($queryData)->getAffectedNumRows() === 1;
|
||||
return $this->db->runQuery($queryData)->getAffectedNumRows() === 1;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -117,7 +117,7 @@ final class AccountSearch extends BaseRepository implements AccountSearchReposit
|
||||
$this->query->offset($accountSearchFilter->getLimitStart());
|
||||
}
|
||||
|
||||
return $this->db->doSelect(
|
||||
return $this->db->runQuery(
|
||||
QueryData::build($this->query)->setMapClassName(AccountSearchView::class),
|
||||
true
|
||||
);
|
||||
|
||||
@@ -59,7 +59,7 @@ final class AccountToFavorite extends BaseRepository implements AccountToFavorit
|
||||
->where('userId = :userId')
|
||||
->bindValues(['userId' => $id]);
|
||||
|
||||
return $this->db->doSelect(QueryData::build($query));
|
||||
return $this->db->runQuery(QueryData::build($query));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -84,7 +84,7 @@ final class AccountToFavorite extends BaseRepository implements AccountToFavorit
|
||||
|
||||
$queryData = QueryData::build($query)->setOnErrorMessage(__u('Error while adding favorite'));
|
||||
|
||||
return $this->db->doQuery($queryData)->getLastId();
|
||||
return $this->db->runQuery($queryData)->getLastId();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -111,6 +111,6 @@ final class AccountToFavorite extends BaseRepository implements AccountToFavorit
|
||||
|
||||
$queryData = QueryData::build($query)->setOnErrorMessage(__u('Error while deleting favorite'));
|
||||
|
||||
return $this->db->doQuery($queryData)->getAffectedNumRows() === 1;
|
||||
return $this->db->runQuery($queryData)->getAffectedNumRows() === 1;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -64,7 +64,7 @@ final class AccountToTag extends BaseRepository implements AccountToTagRepositor
|
||||
->bindValues(['accountId' => $id])
|
||||
->orderBy(['Tag.name ASC']);
|
||||
|
||||
return $this->db->doSelect(QueryData::build($query));
|
||||
return $this->db->runQuery(QueryData::build($query));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -88,7 +88,7 @@ final class AccountToTag extends BaseRepository implements AccountToTagRepositor
|
||||
|
||||
$queryData = QueryData::build($query)->setOnErrorMessage(__u('Error while removing the account\'s tags'));
|
||||
|
||||
return $this->db->doQuery($queryData)->getAffectedNumRows() === 1;
|
||||
return $this->db->runQuery($queryData)->getAffectedNumRows() === 1;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -114,7 +114,7 @@ final class AccountToTag extends BaseRepository implements AccountToTagRepositor
|
||||
|
||||
$queryData = QueryData::build($query)->setOnErrorMessage(__u('Error while adding the account\'s tags'));
|
||||
|
||||
$this->db->doQuery($queryData);
|
||||
$this->db->runQuery($queryData);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -69,7 +69,7 @@ final class AccountToUser extends BaseRepository implements AccountToUserReposit
|
||||
|
||||
$queryData = QueryData::build($query)->setOnErrorMessage(__u('Error while deleting the account\'s groups'));
|
||||
|
||||
$this->db->doQuery($queryData);
|
||||
$this->db->runQuery($queryData);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -100,7 +100,7 @@ final class AccountToUser extends BaseRepository implements AccountToUserReposit
|
||||
Query::buildForMySQL($query, array_merge_recursive($values))
|
||||
)->setOnErrorMessage(__u('Error while updating the account users'));
|
||||
|
||||
$this->db->doQuery($queryData);
|
||||
$this->db->runQuery($queryData);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -124,7 +124,7 @@ final class AccountToUser extends BaseRepository implements AccountToUserReposit
|
||||
|
||||
$queryData = QueryData::build($query)->setOnErrorMessage(__u('Error while deleting the account users'));
|
||||
|
||||
return $this->db->doQuery($queryData)->getAffectedNumRows() === 1;
|
||||
return $this->db->runQuery($queryData)->getAffectedNumRows() === 1;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -150,6 +150,6 @@ final class AccountToUser extends BaseRepository implements AccountToUserReposit
|
||||
->bindValues(['accountId' => $id])
|
||||
->orderBy(['User.name ASC']);
|
||||
|
||||
return $this->db->doSelect(QueryData::build($query)->setMapClassName(Item::class));
|
||||
return $this->db->runQuery(QueryData::build($query)->setMapClassName(Item::class));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -67,7 +67,7 @@ final class AccountToUserGroup extends BaseRepository implements AccountToUserGr
|
||||
->bindValues(['accountId' => $id])
|
||||
->orderBy(['UserGroup.name ASC']);
|
||||
|
||||
return $this->db->doSelect(QueryData::build($query)->setMapClassName(Item::class));
|
||||
return $this->db->runQuery(QueryData::build($query)->setMapClassName(Item::class));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -92,7 +92,7 @@ final class AccountToUserGroup extends BaseRepository implements AccountToUserGr
|
||||
->bindValues(['userGroupId' => $id])
|
||||
->orderBy(['UserGroup.name ASC']);
|
||||
|
||||
return $this->db->doSelect(QueryData::build($query)->setMapClassName(Item::class));
|
||||
return $this->db->runQuery(QueryData::build($query)->setMapClassName(Item::class));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -112,7 +112,7 @@ final class AccountToUserGroup extends BaseRepository implements AccountToUserGr
|
||||
|
||||
$queryData = QueryData::build($query)->setOnErrorMessage(__u('Error while deleting the account\'s groups'));
|
||||
|
||||
return $this->db->doQuery($queryData)->getAffectedNumRows() === 1;
|
||||
return $this->db->runQuery($queryData)->getAffectedNumRows() === 1;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -137,7 +137,7 @@ final class AccountToUserGroup extends BaseRepository implements AccountToUserGr
|
||||
|
||||
$queryData = QueryData::build($query)->setOnErrorMessage(__u('Error while deleting the account\'s groups'));
|
||||
|
||||
$this->db->doQuery($queryData);
|
||||
$this->db->runQuery($queryData);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -166,7 +166,7 @@ final class AccountToUserGroup extends BaseRepository implements AccountToUserGr
|
||||
Query::buildForMySQL($query, array_merge_recursive($values))
|
||||
)->setOnErrorMessage(__u('Error while updating the secondary groups'));
|
||||
|
||||
$this->db->doQuery($queryData);
|
||||
$this->db->runQuery($queryData);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -186,6 +186,6 @@ final class AccountToUserGroup extends BaseRepository implements AccountToUserGr
|
||||
|
||||
$queryData = QueryData::build($query)->setOnErrorMessage(__u('Error while deleting the account\'s groups'));
|
||||
|
||||
return $this->db->doQuery($queryData)->getAffectedNumRows() === 1;
|
||||
return $this->db->runQuery($queryData)->getAffectedNumRows() === 1;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -64,7 +64,7 @@ final class PublicLink extends BaseRepository implements PublicLinkRepository
|
||||
->where('id = :id')
|
||||
->bindValue('id', $id);
|
||||
|
||||
$this->db->doQuery(QueryData::build($query)->setOnErrorMessage(__u('Error while removing the link')));
|
||||
$this->db->runQuery(QueryData::build($query)->setOnErrorMessage(__u('Error while removing the link')));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -100,7 +100,7 @@ final class PublicLink extends BaseRepository implements PublicLinkRepository
|
||||
->join('INNER', 'Account', 'Account.id = PublicLink.itemId')
|
||||
->orderBy(['PublicLink.id']);
|
||||
|
||||
return $this->db->doSelect(QueryData::build($query));
|
||||
return $this->db->runQuery(QueryData::build($query));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -123,7 +123,7 @@ final class PublicLink extends BaseRepository implements PublicLinkRepository
|
||||
->from('PublicLink')
|
||||
->where('id IN (:ids)', ['ids' => $ids]);
|
||||
|
||||
return $this->db->doQuery(QueryData::build($query))->getAffectedNumRows();
|
||||
return $this->db->runQuery(QueryData::build($query))->getAffectedNumRows();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -179,7 +179,7 @@ final class PublicLink extends BaseRepository implements PublicLinkRepository
|
||||
]);
|
||||
}
|
||||
|
||||
return $this->db->doSelect(QueryData::build($query), true);
|
||||
return $this->db->runQuery(QueryData::build($query), true);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -215,7 +215,7 @@ final class PublicLink extends BaseRepository implements PublicLinkRepository
|
||||
|
||||
$queryData = QueryData::build($query)->setOnErrorMessage(__u('Error while creating the link'));
|
||||
|
||||
return $this->db->doQuery($queryData);
|
||||
return $this->db->runQuery($queryData);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -236,7 +236,7 @@ final class PublicLink extends BaseRepository implements PublicLinkRepository
|
||||
->where('itemId = :itemId')
|
||||
->bindValue('itemId', $id);
|
||||
|
||||
return $this->db->doQuery(QueryData::build($query))->getNumRows() === 1;
|
||||
return $this->db->runQuery(QueryData::build($query))->getNumRows() === 1;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -261,7 +261,7 @@ final class PublicLink extends BaseRepository implements PublicLinkRepository
|
||||
|
||||
$queryData = QueryData::build($query)->setOnErrorMessage(__u('Error while updating the link'));
|
||||
|
||||
return $this->db->doQuery($queryData)->getAffectedNumRows() === 1;
|
||||
return $this->db->runQuery($queryData)->getAffectedNumRows() === 1;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -294,7 +294,7 @@ final class PublicLink extends BaseRepository implements PublicLinkRepository
|
||||
|
||||
$queryData = QueryData::build($query)->setOnErrorMessage(__u('Error while updating the link'));
|
||||
|
||||
return $this->db->doQuery($queryData)->getAffectedNumRows() === 1;
|
||||
return $this->db->runQuery($queryData)->getAffectedNumRows() === 1;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -324,7 +324,7 @@ final class PublicLink extends BaseRepository implements PublicLinkRepository
|
||||
|
||||
$queryData = QueryData::build($query)->setOnErrorMessage(__u('Error while renewing the link'));
|
||||
|
||||
return $this->db->doQuery($queryData)->getAffectedNumRows() === 1;
|
||||
return $this->db->runQuery($queryData)->getAffectedNumRows() === 1;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -363,7 +363,7 @@ final class PublicLink extends BaseRepository implements PublicLinkRepository
|
||||
->where('PublicLink.id = :id')
|
||||
->bindValue('id', $id);
|
||||
|
||||
return $this->db->doSelect(QueryData::build($query)->setOnErrorMessage(__u('Error while retrieving the link')));
|
||||
return $this->db->runQuery(QueryData::build($query)->setOnErrorMessage(__u('Error while retrieving the link')));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -400,7 +400,7 @@ final class PublicLink extends BaseRepository implements PublicLinkRepository
|
||||
->where('PublicLink.hash = :hash')
|
||||
->bindValue('hash', $hash);
|
||||
|
||||
return $this->db->doSelect(QueryData::build($query)->setOnErrorMessage(__u('Error while retrieving the link')));
|
||||
return $this->db->runQuery(QueryData::build($query)->setOnErrorMessage(__u('Error while retrieving the link')));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -423,6 +423,6 @@ final class PublicLink extends BaseRepository implements PublicLinkRepository
|
||||
->where('itemId = :itemId')
|
||||
->bindValue('itemId', $itemId);
|
||||
|
||||
return $this->db->doSelect(QueryData::build($query)->setOnErrorMessage(__u('Error while retrieving the link')));
|
||||
return $this->db->runQuery(QueryData::build($query)->setOnErrorMessage(__u('Error while retrieving the link')));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -65,7 +65,7 @@ final class AuthToken extends BaseRepository implements AuthTokenRepository
|
||||
|
||||
$queryData = QueryData::build($query)->setOnErrorMessage(__u('Internal error'));
|
||||
|
||||
return $this->db->doQuery($queryData);
|
||||
return $this->db->runQuery($queryData);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -87,7 +87,7 @@ final class AuthToken extends BaseRepository implements AuthTokenRepository
|
||||
|
||||
$queryData = QueryData::buildWithMapper($query, AuthTokenModel::class);
|
||||
|
||||
return $this->db->doSelect($queryData);
|
||||
return $this->db->runQuery($queryData);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -102,7 +102,7 @@ final class AuthToken extends BaseRepository implements AuthTokenRepository
|
||||
->from(self::TABLE)
|
||||
->cols(AuthTokenModel::getCols());
|
||||
|
||||
return $this->db->doSelect(QueryData::buildWithMapper($query, AuthTokenModel::class));
|
||||
return $this->db->runQuery(QueryData::buildWithMapper($query, AuthTokenModel::class));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -127,7 +127,7 @@ final class AuthToken extends BaseRepository implements AuthTokenRepository
|
||||
|
||||
$queryData = QueryData::build($query)->setOnErrorMessage(__u('Internal error'));
|
||||
|
||||
return $this->db->doQuery($queryData);
|
||||
return $this->db->runQuery($queryData);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -166,7 +166,7 @@ final class AuthToken extends BaseRepository implements AuthTokenRepository
|
||||
$query->bindValues(['userLogin' => $search, 'userName' => $search]);
|
||||
}
|
||||
|
||||
return $this->db->doSelect(QueryData::build($query), true);
|
||||
return $this->db->runQuery(QueryData::build($query), true);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -193,7 +193,7 @@ final class AuthToken extends BaseRepository implements AuthTokenRepository
|
||||
|
||||
$queryData = QueryData::build($query)->setOnErrorMessage(__u('Internal error'));
|
||||
|
||||
return $this->db->doQuery($queryData);
|
||||
return $this->db->runQuery($queryData);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -221,7 +221,7 @@ final class AuthToken extends BaseRepository implements AuthTokenRepository
|
||||
]
|
||||
);
|
||||
|
||||
return $this->db->doQuery(QueryData::build($query))->getNumRows() > 0;
|
||||
return $this->db->runQuery(QueryData::build($query))->getNumRows() > 0;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -243,7 +243,7 @@ final class AuthToken extends BaseRepository implements AuthTokenRepository
|
||||
|
||||
$queryData = QueryData::buildWithMapper($query, AuthTokenModel::class);
|
||||
|
||||
return $this->db->doSelect($queryData);
|
||||
return $this->db->runQuery($queryData);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -272,7 +272,7 @@ final class AuthToken extends BaseRepository implements AuthTokenRepository
|
||||
|
||||
$queryData = QueryData::build($query)->setOnErrorMessage(__u('Internal error'));
|
||||
|
||||
return $this->db->doQuery($queryData)->getAffectedNumRows() === 1;
|
||||
return $this->db->runQuery($queryData)->getAffectedNumRows() === 1;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -301,7 +301,7 @@ final class AuthToken extends BaseRepository implements AuthTokenRepository
|
||||
]
|
||||
);
|
||||
|
||||
return $this->db->doQuery(QueryData::build($query))->getNumRows() > 0;
|
||||
return $this->db->runQuery(QueryData::build($query))->getNumRows() > 0;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -325,7 +325,7 @@ final class AuthToken extends BaseRepository implements AuthTokenRepository
|
||||
|
||||
$queryData = QueryData::build($query)->setOnErrorMessage(__u('Internal error'));
|
||||
|
||||
return $this->db->doQuery($queryData)->getAffectedNumRows();
|
||||
return $this->db->runQuery($queryData)->getAffectedNumRows();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -354,7 +354,7 @@ final class AuthToken extends BaseRepository implements AuthTokenRepository
|
||||
|
||||
$queryData = QueryData::build($query)->setOnErrorMessage(__u('Internal error'));
|
||||
|
||||
return $this->db->doQuery($queryData)->getAffectedNumRows();
|
||||
return $this->db->runQuery($queryData)->getAffectedNumRows();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -376,6 +376,6 @@ final class AuthToken extends BaseRepository implements AuthTokenRepository
|
||||
->bindValues(['actionId' => $actionId, 'token' => $token])
|
||||
->limit(1);
|
||||
|
||||
return $this->db->doSelect(QueryData::buildWithMapper($query, AuthTokenModel::class));
|
||||
return $this->db->runQuery(QueryData::buildWithMapper($query, AuthTokenModel::class));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -73,7 +73,7 @@ final class Category extends BaseRepository implements CategoryRepository
|
||||
|
||||
$queryData = QueryData::build($query)->setOnErrorMessage(__u('Error while creating the category'));
|
||||
|
||||
return $this->db->doQuery($queryData);
|
||||
return $this->db->runQuery($queryData);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -100,7 +100,7 @@ final class Category extends BaseRepository implements CategoryRepository
|
||||
]
|
||||
);
|
||||
|
||||
return $this->db->doQuery(QueryData::build($query))->getNumRows() > 0;
|
||||
return $this->db->runQuery(QueryData::build($query))->getNumRows() > 0;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -134,7 +134,7 @@ final class Category extends BaseRepository implements CategoryRepository
|
||||
|
||||
$queryData = QueryData::build($query)->setOnErrorMessage(__u('Error while updating the category'));
|
||||
|
||||
return $this->db->doQuery($queryData)->getAffectedNumRows();
|
||||
return $this->db->runQuery($queryData)->getAffectedNumRows();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -162,7 +162,7 @@ final class Category extends BaseRepository implements CategoryRepository
|
||||
]
|
||||
);
|
||||
|
||||
return $this->db->doQuery(QueryData::build($query))->getNumRows() > 0;
|
||||
return $this->db->runQuery(QueryData::build($query))->getNumRows() > 0;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -184,7 +184,7 @@ final class Category extends BaseRepository implements CategoryRepository
|
||||
|
||||
$queryData = QueryData::buildWithMapper($query, CategoryModel::class);
|
||||
|
||||
return $this->db->doSelect($queryData);
|
||||
return $this->db->runQuery($queryData);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -206,7 +206,7 @@ final class Category extends BaseRepository implements CategoryRepository
|
||||
|
||||
$queryData = QueryData::buildWithMapper($query, CategoryModel::class);
|
||||
|
||||
return $this->db->doSelect($queryData);
|
||||
return $this->db->runQuery($queryData);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -221,7 +221,7 @@ final class Category extends BaseRepository implements CategoryRepository
|
||||
->from(self::TABLE)
|
||||
->cols(CategoryModel::getCols());
|
||||
|
||||
return $this->db->doSelect(QueryData::buildWithMapper($query, CategoryModel::class));
|
||||
return $this->db->runQuery(QueryData::buildWithMapper($query, CategoryModel::class));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -246,7 +246,7 @@ final class Category extends BaseRepository implements CategoryRepository
|
||||
|
||||
$queryData = QueryData::build($query)->setOnErrorMessage(__u('Error while deleting the categories'));
|
||||
|
||||
return $this->db->doQuery($queryData);
|
||||
return $this->db->runQuery($queryData);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -268,7 +268,7 @@ final class Category extends BaseRepository implements CategoryRepository
|
||||
|
||||
$queryData = QueryData::build($query)->setOnErrorMessage(__u('Error while deleting the category'));
|
||||
|
||||
return $this->db->doQuery($queryData);
|
||||
return $this->db->runQuery($queryData);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -299,6 +299,6 @@ final class Category extends BaseRepository implements CategoryRepository
|
||||
|
||||
$queryData = QueryData::build($query)->setMapClassName(CategoryModel::class);
|
||||
|
||||
return $this->db->doSelect($queryData, true);
|
||||
return $this->db->runQuery($queryData, true);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -71,7 +71,7 @@ final class Client extends BaseRepository implements ClientRepository
|
||||
|
||||
$queryData = QueryData::build($query)->setOnErrorMessage(__u('Error while creating the client'));
|
||||
|
||||
return $this->db->doQuery($queryData);
|
||||
return $this->db->runQuery($queryData);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -97,7 +97,7 @@ final class Client extends BaseRepository implements ClientRepository
|
||||
]
|
||||
);
|
||||
|
||||
return $this->db->doQuery(QueryData::build($query))->getNumRows() > 0;
|
||||
return $this->db->runQuery(QueryData::build($query))->getNumRows() > 0;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -131,7 +131,7 @@ final class Client extends BaseRepository implements ClientRepository
|
||||
|
||||
$queryData = QueryData::build($query)->setOnErrorMessage(__u('Error while updating the client'));
|
||||
|
||||
return $this->db->doQuery($queryData)->getAffectedNumRows();
|
||||
return $this->db->runQuery($queryData)->getAffectedNumRows();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -159,7 +159,7 @@ final class Client extends BaseRepository implements ClientRepository
|
||||
]
|
||||
);
|
||||
|
||||
return $this->db->doQuery(QueryData::build($query))->getNumRows() > 0;
|
||||
return $this->db->runQuery(QueryData::build($query))->getNumRows() > 0;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -181,7 +181,7 @@ final class Client extends BaseRepository implements ClientRepository
|
||||
|
||||
$queryData = QueryData::buildWithMapper($query, ClientModel::class);
|
||||
|
||||
return $this->db->doSelect($queryData);
|
||||
return $this->db->runQuery($queryData);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -203,7 +203,7 @@ final class Client extends BaseRepository implements ClientRepository
|
||||
|
||||
$queryData = QueryData::buildWithMapper($query, ClientModel::class);
|
||||
|
||||
return $this->db->doSelect($queryData);
|
||||
return $this->db->runQuery($queryData);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -218,7 +218,7 @@ final class Client extends BaseRepository implements ClientRepository
|
||||
->from(ClientModel::TABLE)
|
||||
->cols(ClientModel::getCols());
|
||||
|
||||
return $this->db->doSelect(QueryData::buildWithMapper($query, ClientModel::class));
|
||||
return $this->db->runQuery(QueryData::buildWithMapper($query, ClientModel::class));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -243,7 +243,7 @@ final class Client extends BaseRepository implements ClientRepository
|
||||
|
||||
$queryData = QueryData::build($query)->setOnErrorMessage(__u('Error while deleting the clients'));
|
||||
|
||||
return $this->db->doQuery($queryData);
|
||||
return $this->db->runQuery($queryData);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -265,7 +265,7 @@ final class Client extends BaseRepository implements ClientRepository
|
||||
|
||||
$queryData = QueryData::build($query)->setOnErrorMessage(__u('Error while deleting the client'));
|
||||
|
||||
return $this->db->doQuery($queryData);
|
||||
return $this->db->runQuery($queryData);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -295,7 +295,7 @@ final class Client extends BaseRepository implements ClientRepository
|
||||
|
||||
$queryData = QueryData::build($query)->setMapClassName(ClientModel::class);
|
||||
|
||||
return $this->db->doSelect($queryData, true);
|
||||
return $this->db->runQuery($queryData, true);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -316,6 +316,6 @@ final class Client extends BaseRepository implements ClientRepository
|
||||
->groupBy(['id'])
|
||||
->orderBy(['Client.name']);
|
||||
|
||||
return $this->db->doSelect(QueryData::build($query));
|
||||
return $this->db->runQuery(QueryData::build($query));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -118,6 +118,6 @@ abstract class BaseRepository implements Repository
|
||||
->bindValues($bindValues ?? []);
|
||||
}
|
||||
|
||||
return $this->db->doSelect(QueryData::build($query));
|
||||
return $this->db->runQuery(QueryData::build($query));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
*
|
||||
* @author nuxsmin
|
||||
* @link https://syspass.org
|
||||
* @copyright 2012-2022, Rubén Domínguez nuxsmin@$syspass.org
|
||||
* @copyright 2012-2024, Rubén Domínguez nuxsmin@$syspass.org
|
||||
*
|
||||
* This file is part of sysPass.
|
||||
*
|
||||
@@ -24,7 +24,6 @@
|
||||
|
||||
namespace SP\Infrastructure\Common\Repositories;
|
||||
|
||||
|
||||
use SP\Domain\Core\Exceptions\SPException;
|
||||
|
||||
/**
|
||||
|
||||
@@ -65,7 +65,7 @@ final class Config extends BaseRepository implements ConfigRepository
|
||||
|
||||
$queryData = QueryData::build($query);
|
||||
|
||||
return $this->db->doQuery($queryData);
|
||||
return $this->db->runQuery($queryData);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -84,7 +84,7 @@ final class Config extends BaseRepository implements ConfigRepository
|
||||
|
||||
$queryData = QueryData::build($query);
|
||||
|
||||
return $this->db->doQuery($queryData);
|
||||
return $this->db->runQuery($queryData);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -104,7 +104,7 @@ final class Config extends BaseRepository implements ConfigRepository
|
||||
|
||||
$queryData = QueryData::buildWithMapper($query, ConfigModel::class);
|
||||
|
||||
return $this->db->doSelect($queryData);
|
||||
return $this->db->runQuery($queryData);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -124,6 +124,6 @@ final class Config extends BaseRepository implements ConfigRepository
|
||||
|
||||
$queryData = QueryData::build($query);
|
||||
|
||||
return $this->db->doSelect($queryData)->getNumRows() === 1;
|
||||
return $this->db->runQuery($queryData)->getNumRows() === 1;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -73,7 +73,7 @@ final class CustomFieldData extends BaseRepository implements CustomFieldDataRep
|
||||
]
|
||||
);
|
||||
|
||||
return $this->db->doQuery(QueryData::build($query))->getAffectedNumRows();
|
||||
return $this->db->runQuery(QueryData::build($query))->getAffectedNumRows();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -103,7 +103,7 @@ final class CustomFieldData extends BaseRepository implements CustomFieldDataRep
|
||||
]
|
||||
);
|
||||
|
||||
return $this->db->doQuery(QueryData::build($query))->getNumRows() > 0;
|
||||
return $this->db->runQuery(QueryData::build($query))->getNumRows() > 0;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -129,7 +129,7 @@ final class CustomFieldData extends BaseRepository implements CustomFieldDataRep
|
||||
'key' => $customFieldData->getKey(),
|
||||
]);
|
||||
|
||||
return $this->db->doQuery(QueryData::build($query));
|
||||
return $this->db->runQuery(QueryData::build($query));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -155,7 +155,7 @@ final class CustomFieldData extends BaseRepository implements CustomFieldDataRep
|
||||
->where('moduleId = :moduleId')
|
||||
->bindValues(['itemIds' => $itemIds, 'moduleId' => $moduleId]);
|
||||
|
||||
return $this->db->doQuery(QueryData::build($query));
|
||||
return $this->db->runQuery(QueryData::build($query));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -170,7 +170,7 @@ final class CustomFieldData extends BaseRepository implements CustomFieldDataRep
|
||||
->from(self::TABLE)
|
||||
->cols(CustomFieldDataModel::getCols());
|
||||
|
||||
return $this->db->doSelect(QueryData::buildWithMapper($query, CustomFieldDataModel::class));
|
||||
return $this->db->runQuery(QueryData::buildWithMapper($query, CustomFieldDataModel::class));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -187,7 +187,7 @@ final class CustomFieldData extends BaseRepository implements CustomFieldDataRep
|
||||
->where('key IS NOT NULL')
|
||||
->orderBy(['definitionId ASC']);
|
||||
|
||||
return $this->db->doSelect(QueryData::buildWithMapper($query, CustomFieldDataModel::class));
|
||||
return $this->db->runQuery(QueryData::buildWithMapper($query, CustomFieldDataModel::class));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -226,6 +226,6 @@ final class CustomFieldData extends BaseRepository implements CustomFieldDataRep
|
||||
'itemId' => $itemId
|
||||
]);
|
||||
|
||||
return $this->db->doSelect(QueryData::build($query));
|
||||
return $this->db->runQuery(QueryData::build($query));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -75,7 +75,7 @@ final class CustomFieldDefinition extends BaseRepository implements CustomFieldD
|
||||
|
||||
$queryData = QueryData::build($query)->setOnErrorMessage(__u('Error while creating the custom field'));
|
||||
|
||||
return $this->db->doQuery($queryData);
|
||||
return $this->db->runQuery($queryData);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -97,7 +97,7 @@ final class CustomFieldDefinition extends BaseRepository implements CustomFieldD
|
||||
->bindValues(['id' => $customFieldDefinition->getId()]);
|
||||
|
||||
$queryData = QueryData::build($query)->setOnErrorMessage(__u('Error while updating the custom field'));
|
||||
return $this->db->doQuery($queryData)->getAffectedNumRows();
|
||||
return $this->db->runQuery($queryData)->getAffectedNumRows();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -119,7 +119,7 @@ final class CustomFieldDefinition extends BaseRepository implements CustomFieldD
|
||||
|
||||
$queryData = QueryData::buildWithMapper($query, CustomFieldDefinitionModel::class);
|
||||
|
||||
return $this->db->doSelect($queryData);
|
||||
return $this->db->runQuery($queryData);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -135,7 +135,7 @@ final class CustomFieldDefinition extends BaseRepository implements CustomFieldD
|
||||
->cols(CustomFieldDefinitionModel::getCols())
|
||||
->orderBy(['moduleId ASC']);
|
||||
|
||||
return $this->db->doSelect(QueryData::buildWithMapper($query, CustomFieldDefinitionModel::class));
|
||||
return $this->db->runQuery(QueryData::buildWithMapper($query, CustomFieldDefinitionModel::class));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -161,7 +161,7 @@ final class CustomFieldDefinition extends BaseRepository implements CustomFieldD
|
||||
|
||||
$queryData = QueryData::build($query)->setOnErrorMessage(__u('Error while removing the custom fields'));
|
||||
|
||||
return $this->db->doQuery($queryData);
|
||||
return $this->db->runQuery($queryData);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -183,7 +183,7 @@ final class CustomFieldDefinition extends BaseRepository implements CustomFieldD
|
||||
|
||||
$queryData = QueryData::build($query)->setOnErrorMessage(__u('Error while removing the custom field'));
|
||||
|
||||
return $this->db->doQuery($queryData);
|
||||
return $this->db->runQuery($queryData);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -217,6 +217,6 @@ final class CustomFieldDefinition extends BaseRepository implements CustomFieldD
|
||||
|
||||
$queryData = QueryData::build($query)->setMapClassName(CustomFieldDefinitionModel::class);
|
||||
|
||||
return $this->db->doSelect($queryData, true);
|
||||
return $this->db->runQuery($queryData, true);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -55,6 +55,6 @@ final class CustomFieldType extends BaseRepository implements CustomFieldTypeRep
|
||||
->cols(CustomFieldTypeModel::getCols())
|
||||
->orderBy(['name ASC']);
|
||||
|
||||
return $this->db->doSelect(QueryData::buildWithMapper($query, CustomFieldTypeModel::class));
|
||||
return $this->db->runQuery(QueryData::buildWithMapper($query, CustomFieldTypeModel::class));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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.
|
||||
*
|
||||
@@ -32,9 +32,9 @@ use PDOStatement;
|
||||
use SP\Core\Events\Event;
|
||||
use SP\Core\Events\EventDispatcher;
|
||||
use SP\Core\Events\EventMessage;
|
||||
use SP\Domain\Core\Events\EventDispatcherInterface;
|
||||
use SP\Domain\Core\Exceptions\ConstraintException;
|
||||
use SP\Domain\Core\Exceptions\QueryException;
|
||||
use SP\Domain\Core\Exceptions\SPException;
|
||||
|
||||
use function SP\__u;
|
||||
use function SP\logger;
|
||||
@@ -42,92 +42,21 @@ use function SP\processException;
|
||||
|
||||
/**
|
||||
* Class Database
|
||||
*
|
||||
* @package SP\Storage
|
||||
*/
|
||||
final class Database implements DatabaseInterface
|
||||
{
|
||||
protected DbStorageInterface $dbHandler;
|
||||
protected int $numRows = 0;
|
||||
protected int $numFields = 0;
|
||||
protected ?array $lastResult = null;
|
||||
private EventDispatcher $eventDispatcher;
|
||||
private ?int $lastId = null;
|
||||
private ?int $lastId = null;
|
||||
|
||||
/**
|
||||
* DB constructor.
|
||||
*
|
||||
* @param DbStorageInterface $dbHandler
|
||||
* @param DbStorageHandler $dbStorageHandler
|
||||
* @param EventDispatcher $eventDispatcher
|
||||
*/
|
||||
public function __construct(
|
||||
DbStorageInterface $dbHandler,
|
||||
EventDispatcher $eventDispatcher
|
||||
private readonly DbStorageHandler $dbStorageHandler,
|
||||
private readonly EventDispatcherInterface $eventDispatcher
|
||||
) {
|
||||
$this->dbHandler = $dbHandler;
|
||||
$this->eventDispatcher = $eventDispatcher;
|
||||
}
|
||||
|
||||
public function getNumRows(): int
|
||||
{
|
||||
return $this->numRows;
|
||||
}
|
||||
|
||||
public function getNumFields(): int
|
||||
{
|
||||
return $this->numFields;
|
||||
}
|
||||
|
||||
public function getLastResult(): ?array
|
||||
{
|
||||
return $this->lastResult;
|
||||
}
|
||||
|
||||
public function getLastId(): ?int
|
||||
{
|
||||
return $this->lastId;
|
||||
}
|
||||
|
||||
public function getDbHandler(): DbStorageInterface
|
||||
{
|
||||
return $this->dbHandler;
|
||||
}
|
||||
|
||||
/**
|
||||
* Perform a SELECT type query
|
||||
*
|
||||
* @throws ConstraintException
|
||||
* @throws QueryException
|
||||
*/
|
||||
public function doSelect(QueryData $queryData, bool $fullCount = false): QueryResult
|
||||
{
|
||||
if ($queryData->getQuery()->getStatement()) {
|
||||
throw new QueryException($queryData->getOnErrorMessage(), SPException::ERROR, __u('Blank query'));
|
||||
}
|
||||
|
||||
try {
|
||||
$queryResult = $this->doQuery($queryData);
|
||||
|
||||
if ($fullCount === true) {
|
||||
$queryResult->setTotalNumRows($this->getFullRowCount($queryData));
|
||||
}
|
||||
|
||||
return $queryResult;
|
||||
} catch (ConstraintException|QueryException $e) {
|
||||
processException($e);
|
||||
|
||||
throw $e;
|
||||
} catch (Exception $e) {
|
||||
processException($e);
|
||||
|
||||
throw new QueryException(
|
||||
$queryData->getOnErrorMessage(),
|
||||
SPException::ERROR,
|
||||
$e->getMessage(),
|
||||
$e->getCode(),
|
||||
$e
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -136,22 +65,39 @@ final class Database implements DatabaseInterface
|
||||
* @throws QueryException
|
||||
* @throws ConstraintException
|
||||
*/
|
||||
public function doQuery(QueryData $queryData): QueryResult
|
||||
public function runQuery(QueryDataInterface $queryData, bool $fullCount = false): QueryResult
|
||||
{
|
||||
$stmt = $this->prepareQueryData($queryData->getQuery());
|
||||
try {
|
||||
$query = $queryData->getQuery();
|
||||
|
||||
$this->eventDispatcher->notify(
|
||||
'database.query',
|
||||
new Event($this, EventMessage::factory()->addDescription($queryData->getQuery()->getStatement()))
|
||||
);
|
||||
if (empty($query->getStatement())) {
|
||||
throw QueryException::error($queryData->getOnErrorMessage(), __u('Blank query'));
|
||||
}
|
||||
|
||||
if ($queryData->getQuery() instanceof SelectInterface) {
|
||||
$this->numFields = $stmt->columnCount();
|
||||
$stmt = $this->prepareAndRunQuery($query);
|
||||
|
||||
return new QueryResult($this->fetch($queryData, $stmt));
|
||||
$this->eventDispatcher->notify(
|
||||
'database.query',
|
||||
new Event($this, EventMessage::factory()->addDescription($query->getStatement()))
|
||||
);
|
||||
|
||||
if ($query instanceof SelectInterface) {
|
||||
if ($fullCount === true) {
|
||||
return QueryResult::withTotalNumRows(
|
||||
$this->fetch($stmt, $queryData->getMapClassName()),
|
||||
$this->getFullRowCount($queryData)
|
||||
);
|
||||
}
|
||||
|
||||
return new QueryResult($this->fetch($stmt, $queryData->getMapClassName()));
|
||||
}
|
||||
|
||||
return new QueryResult(null, $stmt->rowCount(), $this->lastId);
|
||||
} catch (ConstraintException|QueryException $e) {
|
||||
processException($e);
|
||||
|
||||
throw $e;
|
||||
}
|
||||
|
||||
return (new QueryResult())->setAffectedNumRows($stmt->rowCount())->setLastId($this->lastId);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -164,35 +110,25 @@ final class Database implements DatabaseInterface
|
||||
* @throws ConstraintException
|
||||
* @throws QueryException
|
||||
*/
|
||||
private function prepareQueryData(
|
||||
QueryInterface $query,
|
||||
array $options = []
|
||||
): PDOStatement {
|
||||
private function prepareAndRunQuery(QueryInterface $query, array $options = []): PDOStatement
|
||||
{
|
||||
try {
|
||||
$connection = $this->dbHandler->getConnection();
|
||||
$connection = $this->dbStorageHandler->getConnection();
|
||||
|
||||
if (count($query->getBindValues()) !== 0) {
|
||||
$stmt = $connection->prepare($query->getStatement(), $options);
|
||||
$stmt = $connection->prepare($query->getStatement(), $options);
|
||||
|
||||
foreach ($query->getBindValues() as $param => $value) {
|
||||
// Si la clave es un número utilizamos marcadores de posición "?" en
|
||||
// la consulta. En caso contrario marcadores de nombre
|
||||
$param = is_int($param) ? $param + 1 : ':' . $param;
|
||||
foreach ($query->getBindValues() as $param => $value) {
|
||||
$type = match (true) {
|
||||
is_int($value) => PDO::PARAM_INT,
|
||||
is_bool($value) => PDO::PARAM_BOOL,
|
||||
default => PDO::PARAM_STR
|
||||
};
|
||||
|
||||
if ($param === 'blobcontent') {
|
||||
$stmt->bindValue($param, $value, PDO::PARAM_LOB);
|
||||
} elseif (is_int($value)) {
|
||||
$stmt->bindValue($param, $value, PDO::PARAM_INT);
|
||||
} else {
|
||||
$stmt->bindValue($param, $value);
|
||||
}
|
||||
}
|
||||
|
||||
$stmt->execute();
|
||||
} else {
|
||||
$stmt = $connection->query($query);
|
||||
$stmt->bindValue($param, $value, $type);
|
||||
}
|
||||
|
||||
$stmt->execute();
|
||||
|
||||
$this->lastId = $connection->lastInsertId();
|
||||
|
||||
return $stmt;
|
||||
@@ -200,47 +136,35 @@ final class Database implements DatabaseInterface
|
||||
processException($e);
|
||||
|
||||
if ((int)$e->getCode() === 23000) {
|
||||
throw new ConstraintException(
|
||||
__u('Integrity constraint'),
|
||||
SPException::ERROR,
|
||||
$e->getMessage(),
|
||||
$e->getCode(),
|
||||
$e
|
||||
);
|
||||
throw ConstraintException::error(__u('Integrity constraint'), $e->getMessage(), $e->getCode(), $e);
|
||||
}
|
||||
|
||||
throw new QueryException(
|
||||
$e->getMessage(),
|
||||
SPException::CRITICAL,
|
||||
$e->getCode(),
|
||||
0,
|
||||
$e
|
||||
);
|
||||
throw QueryException::critical($e->getMessage(), $e->getCode(), 0, $e);
|
||||
}
|
||||
}
|
||||
|
||||
private function fetch(QueryData $queryData, PDOStatement $stmt): array
|
||||
private function fetch(PDOStatement $stmt, ?string $class = null): array
|
||||
{
|
||||
if ($queryData->getMapClassName()) {
|
||||
return $stmt->fetchAll(PDO::FETCH_CLASS | PDO::FETCH_PROPS_LATE, $queryData->getMapClassName());
|
||||
$fetchArgs = [PDO::FETCH_DEFAULT];
|
||||
|
||||
if ($class) {
|
||||
$fetchArgs = [PDO::FETCH_CLASS | PDO::FETCH_PROPS_LATE, $class];
|
||||
}
|
||||
|
||||
return $stmt->fetchAll();
|
||||
return $stmt->fetchAll(...$fetchArgs);
|
||||
}
|
||||
|
||||
/**
|
||||
* Obtener el número de filas de una consulta realizada
|
||||
*
|
||||
* @param QueryDataInterface $queryData
|
||||
* @return int Número de filas de la consulta
|
||||
* @throws SPException
|
||||
* @throws ConstraintException
|
||||
* @throws QueryException
|
||||
*/
|
||||
public function getFullRowCount(QueryData $queryData): int
|
||||
private function getFullRowCount(QueryDataInterface $queryData): int
|
||||
{
|
||||
$queryRes = $this->prepareQueryData($queryData->getQueryCount());
|
||||
$num = (int)$queryRes->fetchColumn();
|
||||
$queryRes->closeCursor();
|
||||
|
||||
return $num;
|
||||
return (int)$this->prepareAndRunQuery($queryData->getQueryCount())->fetchColumn();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -248,27 +172,41 @@ final class Database implements DatabaseInterface
|
||||
*
|
||||
* @param QueryData $queryData
|
||||
* @param array $options
|
||||
* @param int $mode Fech mode
|
||||
* @param bool|null $buffered Set buffered behavior (useful for big datasets)
|
||||
*
|
||||
* @return PDOStatement
|
||||
* @throws ConstraintException
|
||||
* @throws QueryException|DatabaseException
|
||||
* @throws QueryException
|
||||
*/
|
||||
public function doQueryRaw(
|
||||
QueryData $queryData,
|
||||
array $options = [],
|
||||
?bool $buffered = null
|
||||
): PDOStatement {
|
||||
if ($buffered === false && ($this->dbHandler instanceof MysqlHandler)) {
|
||||
$this->dbHandler
|
||||
->getConnection()
|
||||
->setAttribute(
|
||||
PDO::MYSQL_ATTR_USE_BUFFERED_QUERY,
|
||||
false
|
||||
);
|
||||
public function doFetchWithOptions(
|
||||
QueryDataInterface $queryData,
|
||||
array $options = [],
|
||||
int $mode = PDO::FETCH_DEFAULT,
|
||||
?bool $buffered = true
|
||||
): iterable {
|
||||
if ($this->dbStorageHandler->getDriver() === DbStorageDriver::mysql) {
|
||||
$options += [PDO::MYSQL_ATTR_USE_BUFFERED_QUERY => $buffered];
|
||||
}
|
||||
|
||||
return $this->prepareQueryData($queryData->getQuery(), $options);
|
||||
$stmt = $this->prepareAndRunQuery($queryData->getQuery(), $options);
|
||||
|
||||
while (($row = $stmt->fetch($mode)) !== false) {
|
||||
yield $row;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute a raw query
|
||||
*
|
||||
* @param string $query
|
||||
* @throws QueryException
|
||||
*/
|
||||
public function runQueryRaw(string $query): void
|
||||
{
|
||||
if ($this->dbStorageHandler->getConnection()->exec($query) === false) {
|
||||
throw QueryException::error(__u('Error executing the query'));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -276,7 +214,7 @@ final class Database implements DatabaseInterface
|
||||
*/
|
||||
public function beginTransaction(): bool
|
||||
{
|
||||
$conn = $this->dbHandler->getConnection();
|
||||
$conn = $this->dbStorageHandler->getConnection();
|
||||
|
||||
if (!$conn->inTransaction()) {
|
||||
$result = $conn->beginTransaction();
|
||||
@@ -302,7 +240,7 @@ final class Database implements DatabaseInterface
|
||||
*/
|
||||
public function endTransaction(): bool
|
||||
{
|
||||
$conn = $this->dbHandler->getConnection();
|
||||
$conn = $this->dbStorageHandler->getConnection();
|
||||
|
||||
$result = $conn->inTransaction() && $conn->commit();
|
||||
|
||||
@@ -322,7 +260,7 @@ final class Database implements DatabaseInterface
|
||||
*/
|
||||
public function rollbackTransaction(): bool
|
||||
{
|
||||
$conn = $this->dbHandler->getConnection();
|
||||
$conn = $this->dbStorageHandler->getConnection();
|
||||
|
||||
$result = $conn->inTransaction() && $conn->rollBack();
|
||||
|
||||
@@ -336,23 +274,4 @@ final class Database implements DatabaseInterface
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the columns of a table
|
||||
*
|
||||
* @param string $table
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getColumnsForTable(string $table): array
|
||||
{
|
||||
$conn = $this->dbHandler->getConnection()->query("SELECT * FROM `$table` LIMIT 0");
|
||||
$columns = [];
|
||||
|
||||
for ($i = 0; $i < $conn->columnCount(); $i++) {
|
||||
$columns[] = $conn->getColumnMeta($i)['name'];
|
||||
}
|
||||
|
||||
return $columns;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
*
|
||||
* @author nuxsmin
|
||||
* @link https://syspass.org
|
||||
* @copyright 2012-2022, Rubén Domínguez nuxsmin@$syspass.org
|
||||
* @copyright 2012-2024, Rubén Domínguez nuxsmin@$syspass.org
|
||||
*
|
||||
* This file is part of sysPass.
|
||||
*
|
||||
@@ -24,7 +24,6 @@
|
||||
|
||||
namespace SP\Infrastructure\Database;
|
||||
|
||||
use PDOStatement;
|
||||
use SP\Domain\Core\Exceptions\ConstraintException;
|
||||
use SP\Domain\Core\Exceptions\QueryException;
|
||||
|
||||
@@ -35,35 +34,18 @@ use SP\Domain\Core\Exceptions\QueryException;
|
||||
*/
|
||||
interface DatabaseInterface
|
||||
{
|
||||
public function doSelect(QueryData $queryData, bool $fullCount = false): QueryResult;
|
||||
|
||||
/**
|
||||
* Performs a DB query
|
||||
* Perform any type of query
|
||||
*
|
||||
* @throws QueryException
|
||||
* @throws ConstraintException
|
||||
*/
|
||||
public function doQuery(QueryData $queryData): QueryResult;
|
||||
public function runQuery(QueryDataInterface $queryData, bool $fullCount = false): QueryResult;
|
||||
|
||||
/**
|
||||
* Don't fetch records and return prepared statement
|
||||
*/
|
||||
public function doQueryRaw(QueryData $queryData): PDOStatement;
|
||||
|
||||
/**
|
||||
* Returns the total number of records
|
||||
*/
|
||||
public function getFullRowCount(QueryData $queryData): int;
|
||||
|
||||
public function getDbHandler(): DbStorageInterface;
|
||||
|
||||
public function getNumRows(): int;
|
||||
|
||||
public function getNumFields(): int;
|
||||
|
||||
public function getLastResult(): ?array;
|
||||
|
||||
public function getLastId(): ?int;
|
||||
public function doFetchWithOptions(QueryDataInterface $queryData): iterable;
|
||||
|
||||
public function beginTransaction(): bool;
|
||||
|
||||
@@ -71,5 +53,11 @@ interface DatabaseInterface
|
||||
|
||||
public function rollbackTransaction(): bool;
|
||||
|
||||
public function getColumnsForTable(string $table): array;
|
||||
/**
|
||||
* Execute a raw query
|
||||
*
|
||||
* @param string $query
|
||||
* @throws QueryException
|
||||
*/
|
||||
public function runQueryRaw(string $query): void;
|
||||
}
|
||||
|
||||
@@ -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.
|
||||
*
|
||||
@@ -71,7 +71,7 @@ class DatabaseUtil
|
||||
/**
|
||||
* DatabaseUtil constructor.
|
||||
*/
|
||||
public function __construct(private readonly DbStorageInterface $dbStorage)
|
||||
public function __construct(private readonly DbStorageHandler $dbStorage)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
33
lib/SP/Infrastructure/Database/DbStorageDriver.php
Normal file
33
lib/SP/Infrastructure/Database/DbStorageDriver.php
Normal file
@@ -0,0 +1,33 @@
|
||||
<?php
|
||||
/*
|
||||
* sysPass
|
||||
*
|
||||
* @author nuxsmin
|
||||
* @link https://syspass.org
|
||||
* @copyright 2012-2024, Rubén Domínguez nuxsmin@$syspass.org
|
||||
*
|
||||
* This file is part of sysPass.
|
||||
*
|
||||
* sysPass is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* sysPass is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with sysPass. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
namespace SP\Infrastructure\Database;
|
||||
|
||||
/**
|
||||
* Enum DbStorageDriver
|
||||
*/
|
||||
enum DbStorageDriver
|
||||
{
|
||||
case mysql;
|
||||
}
|
||||
@@ -4,7 +4,7 @@
|
||||
*
|
||||
* @author nuxsmin
|
||||
* @link https://syspass.org
|
||||
* @copyright 2012-2022, Rubén Domínguez nuxsmin@$syspass.org
|
||||
* @copyright 2012-2024, Rubén Domínguez nuxsmin@$syspass.org
|
||||
*
|
||||
* This file is part of sysPass.
|
||||
*
|
||||
@@ -31,7 +31,7 @@ use PDO;
|
||||
*
|
||||
* @package SP\Storage
|
||||
*/
|
||||
interface DbStorageInterface
|
||||
interface DbStorageHandler
|
||||
{
|
||||
/**
|
||||
* Obtener una conexión PDO
|
||||
@@ -63,4 +63,6 @@ interface DbStorageInterface
|
||||
* @return string|null
|
||||
*/
|
||||
public function getDatabaseName(): ?string;
|
||||
}
|
||||
|
||||
public function getDriver(): DbStorageDriver;
|
||||
}
|
||||
@@ -4,7 +4,7 @@
|
||||
*
|
||||
* @author nuxsmin
|
||||
* @link https://syspass.org
|
||||
* @copyright 2012-2022, Rubén Domínguez nuxsmin@$syspass.org
|
||||
* @copyright 2012-2024, Rubén Domínguez nuxsmin@$syspass.org
|
||||
*
|
||||
* This file is part of sysPass.
|
||||
*
|
||||
@@ -28,21 +28,19 @@ use Exception;
|
||||
use PDO;
|
||||
use SP\Domain\Core\Exceptions\SPException;
|
||||
|
||||
defined('APP_ROOT') || die();
|
||||
|
||||
/**
|
||||
* Class MySQLHandler
|
||||
*
|
||||
* Esta clase se encarga de crear las conexiones a la BD
|
||||
*/
|
||||
final class MysqlHandler implements DbStorageInterface
|
||||
final class MysqlHandler implements DbStorageHandler
|
||||
{
|
||||
public const STATUS_OK = 0;
|
||||
public const STATUS_KO = 1;
|
||||
public const PDO_OPTS = [
|
||||
PDO::ATTR_EMULATE_PREPARES => false,
|
||||
PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION,
|
||||
PDO::MYSQL_ATTR_FOUND_ROWS => true,
|
||||
PDO::ATTR_EMULATE_PREPARES => false,
|
||||
PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION,
|
||||
PDO::MYSQL_ATTR_FOUND_ROWS => true,
|
||||
PDO::ATTR_DEFAULT_FETCH_MODE => PDO::FETCH_OBJ,
|
||||
];
|
||||
|
||||
@@ -123,20 +121,20 @@ final class MysqlHandler implements DbStorageInterface
|
||||
$dsn = ['charset=utf8'];
|
||||
|
||||
if (empty($this->connectionData->getDbSocket())) {
|
||||
$dsn[] = 'host='.$this->connectionData->getDbHost();
|
||||
$dsn[] = 'host=' . $this->connectionData->getDbHost();
|
||||
|
||||
if (null !== $this->connectionData->getDbPort()) {
|
||||
$dsn[] = 'port='.$this->connectionData->getDbPort();
|
||||
$dsn[] = 'port=' . $this->connectionData->getDbPort();
|
||||
}
|
||||
} else {
|
||||
$dsn[] = 'unix_socket='.$this->connectionData->getDbSocket();
|
||||
$dsn[] = 'unix_socket=' . $this->connectionData->getDbSocket();
|
||||
}
|
||||
|
||||
if (!empty($this->connectionData->getDbName())) {
|
||||
$dsn[] = 'dbname='.$this->connectionData->getDbName();
|
||||
$dsn[] = 'dbname=' . $this->connectionData->getDbName();
|
||||
}
|
||||
|
||||
return 'mysql:'.implode(';', $dsn);
|
||||
return 'mysql:' . implode(';', $dsn);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -160,7 +158,7 @@ final class MysqlHandler implements DbStorageInterface
|
||||
try {
|
||||
$opts = [
|
||||
PDO::ATTR_EMULATE_PREPARES => true,
|
||||
PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION,
|
||||
PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION,
|
||||
];
|
||||
|
||||
$this->db = new PDO(
|
||||
|
||||
@@ -34,7 +34,7 @@ use function SP\__u;
|
||||
/**
|
||||
* Class QueryData
|
||||
*/
|
||||
final class QueryData
|
||||
final class QueryData implements QueryDataInterface
|
||||
{
|
||||
private const DEFAULT_MAP_CLASS = Simple::class;
|
||||
protected string $mapClassName = self::DEFAULT_MAP_CLASS;
|
||||
|
||||
@@ -22,31 +22,28 @@
|
||||
* along with sysPass. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
namespace SP\Infrastructure\File;
|
||||
namespace SP\Infrastructure\Database;
|
||||
|
||||
use Aura\SqlQuery\QueryInterface;
|
||||
use SP\Domain\Core\Exceptions\QueryException;
|
||||
|
||||
/**
|
||||
* Class CsvFileHandler
|
||||
* Class QueryData
|
||||
*/
|
||||
final class CsvFileHandler implements \SP\Domain\File\Ports\CsvFileHandler
|
||||
interface QueryDataInterface
|
||||
{
|
||||
public function getQuery(): QueryInterface;
|
||||
|
||||
public function __construct(private readonly FileHandlerInterface $fileHandler)
|
||||
{
|
||||
}
|
||||
public function getMapClassName(): string;
|
||||
|
||||
public function setMapClassName(string $class): QueryData;
|
||||
|
||||
/**
|
||||
* Read a CSV file
|
||||
*
|
||||
* @throws FileException
|
||||
* @throws QueryException
|
||||
*/
|
||||
public function readCsv(string $delimiter): iterable
|
||||
{
|
||||
$handler = $this->fileHandler->open();
|
||||
public function getQueryCount(): QueryInterface;
|
||||
|
||||
while (($fields = fgetcsv($handler, 0, $delimiter)) !== false) {
|
||||
yield $fields;
|
||||
}
|
||||
public function getOnErrorMessage(): string;
|
||||
|
||||
$this->fileHandler->close();
|
||||
}
|
||||
public function setOnErrorMessage(string $onErrorMessage): QueryData;
|
||||
}
|
||||
@@ -39,18 +39,17 @@ class QueryResult
|
||||
{
|
||||
private readonly SplFixedArray $data;
|
||||
private readonly int $numRows;
|
||||
private int $totalNumRows = 0;
|
||||
private int $affectedNumRows = 0;
|
||||
private int $statusCode = 0;
|
||||
private int $lastId = 0;
|
||||
private int $totalNumRows = 0;
|
||||
private int $statusCode = 0;
|
||||
|
||||
/**
|
||||
* QueryResult constructor.
|
||||
*
|
||||
* @param array|null $data
|
||||
*/
|
||||
public function __construct(?array $data = null)
|
||||
{
|
||||
public function __construct(
|
||||
?array $data = null,
|
||||
private readonly int $affectedNumRows = 0,
|
||||
private readonly int $lastId = 0
|
||||
) {
|
||||
if (null !== $data) {
|
||||
$this->data = SplFixedArray::fromArray($data);
|
||||
$this->numRows = $this->data->count();
|
||||
@@ -123,14 +122,6 @@ class QueryResult
|
||||
return $this->totalNumRows;
|
||||
}
|
||||
|
||||
public function setTotalNumRows(int $totalNumRows): QueryResult
|
||||
{
|
||||
$self = clone $this;
|
||||
$self->totalNumRows = $totalNumRows;
|
||||
|
||||
return $self;
|
||||
}
|
||||
|
||||
public function getStatusCode(): int
|
||||
{
|
||||
return $this->statusCode;
|
||||
@@ -141,24 +132,8 @@ class QueryResult
|
||||
return $this->affectedNumRows;
|
||||
}
|
||||
|
||||
public function setAffectedNumRows(int $affectedNumRows): QueryResult
|
||||
{
|
||||
$self = clone $this;
|
||||
$self->affectedNumRows = $affectedNumRows;
|
||||
|
||||
return $self;
|
||||
}
|
||||
|
||||
public function getLastId(): int
|
||||
{
|
||||
return $this->lastId;
|
||||
}
|
||||
|
||||
public function setLastId(int $lastId): QueryResult
|
||||
{
|
||||
$self = clone $this;
|
||||
$self->lastId = $lastId;
|
||||
|
||||
return $self;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -63,7 +63,7 @@ class ItemPreset extends BaseRepository implements ItemPresetRepository
|
||||
|
||||
$queryData = QueryData::build($query)->setOnErrorMessage(__u('Error while creating the permission'));
|
||||
|
||||
return $this->db->doQuery($queryData);
|
||||
return $this->db->runQuery($queryData);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -88,7 +88,7 @@ class ItemPreset extends BaseRepository implements ItemPresetRepository
|
||||
|
||||
$queryData = QueryData::build($query)->setOnErrorMessage(__u('Error while updating the permission'));
|
||||
|
||||
return $this->db->doQuery($queryData)->getAffectedNumRows();
|
||||
return $this->db->runQuery($queryData)->getAffectedNumRows();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -107,7 +107,7 @@ class ItemPreset extends BaseRepository implements ItemPresetRepository
|
||||
|
||||
$queryData = QueryData::build($query)->setOnErrorMessage(__u('Error while deleting the permission'));
|
||||
|
||||
return $this->db->doQuery($queryData);
|
||||
return $this->db->runQuery($queryData);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -129,7 +129,7 @@ class ItemPreset extends BaseRepository implements ItemPresetRepository
|
||||
|
||||
$queryData = QueryData::buildWithMapper($query, ItemPresetModel::class);
|
||||
|
||||
return $this->db->doSelect($queryData);
|
||||
return $this->db->runQuery($queryData);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -173,7 +173,7 @@ class ItemPreset extends BaseRepository implements ItemPresetRepository
|
||||
|
||||
$queryData = QueryData::buildWithMapper($query, ItemPresetModel::class);
|
||||
|
||||
return $this->db->doSelect($queryData);
|
||||
return $this->db->runQuery($queryData);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -188,7 +188,7 @@ class ItemPreset extends BaseRepository implements ItemPresetRepository
|
||||
->from(self::TABLE)
|
||||
->cols(ItemPresetModel::getCols());
|
||||
|
||||
return $this->db->doSelect(QueryData::buildWithMapper($query, ItemPresetModel::class));
|
||||
return $this->db->runQuery(QueryData::buildWithMapper($query, ItemPresetModel::class));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -210,7 +210,7 @@ class ItemPreset extends BaseRepository implements ItemPresetRepository
|
||||
|
||||
$queryData = QueryData::build($query)->setOnErrorMessage(__u('Error while removing the permissions'));
|
||||
|
||||
return $this->db->doQuery($queryData);
|
||||
return $this->db->runQuery($queryData);
|
||||
}
|
||||
|
||||
|
||||
@@ -268,6 +268,6 @@ class ItemPreset extends BaseRepository implements ItemPresetRepository
|
||||
|
||||
$queryData = QueryData::build($query)->setMapClassName(ItemPresetModel::class);
|
||||
|
||||
return $this->db->doSelect($queryData, true);
|
||||
return $this->db->runQuery($queryData, true);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -66,7 +66,7 @@ final class Notification extends BaseRepository implements NotificationRepositor
|
||||
|
||||
$queryData = QueryData::build($query)->setOnErrorMessage(__u('Error while adding the notification'));
|
||||
|
||||
return $this->db->doQuery($queryData);
|
||||
return $this->db->runQuery($queryData);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -90,7 +90,7 @@ final class Notification extends BaseRepository implements NotificationRepositor
|
||||
|
||||
$queryData = QueryData::build($query)->setOnErrorMessage(__u('Error while updating the notification'));
|
||||
|
||||
return $this->db->doQuery($queryData)->getAffectedNumRows();
|
||||
return $this->db->runQuery($queryData)->getAffectedNumRows();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -112,7 +112,7 @@ final class Notification extends BaseRepository implements NotificationRepositor
|
||||
|
||||
$queryData = QueryData::build($query)->setOnErrorMessage(__u('Error while deleting the notification'));
|
||||
|
||||
return $this->db->doQuery($queryData);
|
||||
return $this->db->runQuery($queryData);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -134,7 +134,7 @@ final class Notification extends BaseRepository implements NotificationRepositor
|
||||
|
||||
$queryData = QueryData::build($query)->setOnErrorMessage(__u('Error while deleting the notification'));
|
||||
|
||||
return $this->db->doQuery($queryData);
|
||||
return $this->db->runQuery($queryData);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -159,7 +159,7 @@ final class Notification extends BaseRepository implements NotificationRepositor
|
||||
|
||||
$queryData = QueryData::build($query)->setOnErrorMessage(__u('Error while deleting the notifications'));
|
||||
|
||||
return $this->db->doQuery($queryData);
|
||||
return $this->db->runQuery($queryData);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -181,7 +181,7 @@ final class Notification extends BaseRepository implements NotificationRepositor
|
||||
|
||||
$queryData = QueryData::buildWithMapper($query, NotificationModel::class);
|
||||
|
||||
return $this->db->doSelect($queryData);
|
||||
return $this->db->runQuery($queryData);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -197,7 +197,7 @@ final class Notification extends BaseRepository implements NotificationRepositor
|
||||
->cols(NotificationModel::getCols())
|
||||
->orderBy(['id']);
|
||||
|
||||
return $this->db->doSelect(QueryData::buildWithMapper($query, NotificationModel::class));
|
||||
return $this->db->runQuery(QueryData::buildWithMapper($query, NotificationModel::class));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -217,7 +217,7 @@ final class Notification extends BaseRepository implements NotificationRepositor
|
||||
|
||||
$queryData = QueryData::buildWithMapper($query, NotificationModel::class);
|
||||
|
||||
return $this->db->doSelect($queryData);
|
||||
return $this->db->runQuery($queryData);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -241,7 +241,7 @@ final class Notification extends BaseRepository implements NotificationRepositor
|
||||
|
||||
$queryData = QueryData::build($query)->setOnErrorMessage(__u('Error while deleting the notifications'));
|
||||
|
||||
return $this->db->doQuery($queryData);
|
||||
return $this->db->runQuery($queryData);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -262,7 +262,7 @@ final class Notification extends BaseRepository implements NotificationRepositor
|
||||
|
||||
$queryData = QueryData::build($query)->setMapClassName(NotificationModel::class);
|
||||
|
||||
return $this->db->doSelect($queryData, true);
|
||||
return $this->db->runQuery($queryData, true);
|
||||
}
|
||||
|
||||
private function getBaseSearch(ItemSearchData $itemSearchData): SelectInterface
|
||||
@@ -301,7 +301,7 @@ final class Notification extends BaseRepository implements NotificationRepositor
|
||||
|
||||
$queryData = QueryData::build($query)->setMapClassName(NotificationModel::class);
|
||||
|
||||
return $this->db->doSelect($queryData, true);
|
||||
return $this->db->runQuery($queryData, true);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -324,7 +324,7 @@ final class Notification extends BaseRepository implements NotificationRepositor
|
||||
|
||||
$queryData = QueryData::build($query)->setOnErrorMessage(__u('Error while updating the notification'));
|
||||
|
||||
return $this->db->doQuery($queryData)->getAffectedNumRows();
|
||||
return $this->db->runQuery($queryData)->getAffectedNumRows();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -350,7 +350,7 @@ final class Notification extends BaseRepository implements NotificationRepositor
|
||||
|
||||
$queryData = QueryData::buildWithMapper($query, NotificationModel::class);
|
||||
|
||||
return $this->db->doSelect($queryData);
|
||||
return $this->db->runQuery($queryData);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -370,7 +370,7 @@ final class Notification extends BaseRepository implements NotificationRepositor
|
||||
|
||||
$queryData = QueryData::buildWithMapper($query, NotificationModel::class);
|
||||
|
||||
return $this->db->doSelect($queryData);
|
||||
return $this->db->runQuery($queryData);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -389,7 +389,7 @@ final class Notification extends BaseRepository implements NotificationRepositor
|
||||
|
||||
$queryData = QueryData::buildWithMapper($query, NotificationModel::class);
|
||||
|
||||
return $this->db->doSelect($queryData);
|
||||
return $this->db->runQuery($queryData);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -409,6 +409,6 @@ final class Notification extends BaseRepository implements NotificationRepositor
|
||||
|
||||
$queryData = QueryData::buildWithMapper($query, NotificationModel::class);
|
||||
|
||||
return $this->db->doSelect($queryData);
|
||||
return $this->db->runQuery($queryData);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -66,7 +66,7 @@ final class Plugin extends BaseRepository implements PluginRepository
|
||||
|
||||
$queryData = QueryData::build($query)->setOnErrorMessage(__u('Error while adding the plugin'));
|
||||
|
||||
return $this->db->doQuery($queryData);
|
||||
return $this->db->runQuery($queryData);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -89,7 +89,7 @@ final class Plugin extends BaseRepository implements PluginRepository
|
||||
|
||||
$queryData = QueryData::build($query)->setOnErrorMessage(__u('Error while updating the plugin'));
|
||||
|
||||
return $this->db->doQuery($queryData)->getAffectedNumRows();
|
||||
return $this->db->runQuery($queryData)->getAffectedNumRows();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -107,7 +107,7 @@ final class Plugin extends BaseRepository implements PluginRepository
|
||||
|
||||
$queryData = QueryData::buildWithMapper($query, PluginModel::class);
|
||||
|
||||
return $this->db->doSelect($queryData);
|
||||
return $this->db->runQuery($queryData);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -129,7 +129,7 @@ final class Plugin extends BaseRepository implements PluginRepository
|
||||
|
||||
$queryData = QueryData::buildWithMapper($query, PluginModel::class);
|
||||
|
||||
return $this->db->doSelect($queryData);
|
||||
return $this->db->runQuery($queryData);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -145,7 +145,7 @@ final class Plugin extends BaseRepository implements PluginRepository
|
||||
->cols(PluginModel::getCols())
|
||||
->orderBy(['name']);
|
||||
|
||||
return $this->db->doSelect(QueryData::buildWithMapper($query, PluginModel::class));
|
||||
return $this->db->runQuery(QueryData::buildWithMapper($query, PluginModel::class));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -166,7 +166,7 @@ final class Plugin extends BaseRepository implements PluginRepository
|
||||
|
||||
$queryData = QueryData::buildWithMapper($query, PluginModel::class);
|
||||
|
||||
return $this->db->doSelect($queryData);
|
||||
return $this->db->runQuery($queryData);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -192,7 +192,7 @@ final class Plugin extends BaseRepository implements PluginRepository
|
||||
|
||||
$queryData = QueryData::build($query)->setOnErrorMessage(__u('Error while deleting the plugins'));
|
||||
|
||||
return $this->db->doQuery($queryData);
|
||||
return $this->db->runQuery($queryData);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -214,7 +214,7 @@ final class Plugin extends BaseRepository implements PluginRepository
|
||||
|
||||
$queryData = QueryData::build($query)->setOnErrorMessage(__u('Error while deleting the plugin'));
|
||||
|
||||
return $this->db->doQuery($queryData);
|
||||
return $this->db->runQuery($queryData);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -244,7 +244,7 @@ final class Plugin extends BaseRepository implements PluginRepository
|
||||
|
||||
$queryData = QueryData::build($query)->setMapClassName(PluginModel::class);
|
||||
|
||||
return $this->db->doSelect($queryData, true);
|
||||
return $this->db->runQuery($queryData, true);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -265,7 +265,7 @@ final class Plugin extends BaseRepository implements PluginRepository
|
||||
|
||||
$queryData = QueryData::buildWithMapper($query, PluginModel::class);
|
||||
|
||||
return $this->db->doSelect($queryData);
|
||||
return $this->db->runQuery($queryData);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -289,7 +289,7 @@ final class Plugin extends BaseRepository implements PluginRepository
|
||||
|
||||
$queryData = QueryData::build($query)->setOnErrorMessage(__u('Error while updating the plugin'));
|
||||
|
||||
return $this->db->doQuery($queryData)->getAffectedNumRows();
|
||||
return $this->db->runQuery($queryData)->getAffectedNumRows();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -313,7 +313,7 @@ final class Plugin extends BaseRepository implements PluginRepository
|
||||
|
||||
$queryData = QueryData::build($query)->setOnErrorMessage(__u('Error while updating the plugin'));
|
||||
|
||||
return $this->db->doQuery($queryData)->getAffectedNumRows();
|
||||
return $this->db->runQuery($queryData)->getAffectedNumRows();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -337,7 +337,7 @@ final class Plugin extends BaseRepository implements PluginRepository
|
||||
|
||||
$queryData = QueryData::build($query)->setOnErrorMessage(__u('Error while updating the plugin'));
|
||||
|
||||
return $this->db->doQuery($queryData)->getAffectedNumRows();
|
||||
return $this->db->runQuery($queryData)->getAffectedNumRows();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -361,7 +361,7 @@ final class Plugin extends BaseRepository implements PluginRepository
|
||||
|
||||
$queryData = QueryData::build($query)->setOnErrorMessage(__u('Error while updating the plugin'));
|
||||
|
||||
return $this->db->doQuery($queryData)->getAffectedNumRows();
|
||||
return $this->db->runQuery($queryData)->getAffectedNumRows();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -384,6 +384,6 @@ final class Plugin extends BaseRepository implements PluginRepository
|
||||
|
||||
$queryData = QueryData::build($query)->setOnErrorMessage(__u('Error while updating the plugin'));
|
||||
|
||||
return $this->db->doQuery($queryData)->getAffectedNumRows();
|
||||
return $this->db->runQuery($queryData)->getAffectedNumRows();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -64,7 +64,7 @@ final class PluginData extends BaseRepository implements PluginDataRepository
|
||||
|
||||
$queryData = QueryData::build($query)->setOnErrorMessage(__u('Error while adding plugin\'s data'));
|
||||
|
||||
return $this->db->doQuery($queryData);
|
||||
return $this->db->runQuery($queryData);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -90,7 +90,7 @@ final class PluginData extends BaseRepository implements PluginDataRepository
|
||||
|
||||
$queryData = QueryData::build($query)->setOnErrorMessage(__u('Error while updating plugin\'s data'));
|
||||
|
||||
return $this->db->doQuery($queryData)->getAffectedNumRows();
|
||||
return $this->db->runQuery($queryData)->getAffectedNumRows();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -112,7 +112,7 @@ final class PluginData extends BaseRepository implements PluginDataRepository
|
||||
|
||||
$queryData = QueryData::build($query)->setOnErrorMessage(__u('Error while deleting plugin\'s data'));
|
||||
|
||||
return $this->db->doQuery($queryData);
|
||||
return $this->db->runQuery($queryData);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -135,7 +135,7 @@ final class PluginData extends BaseRepository implements PluginDataRepository
|
||||
|
||||
$queryData = QueryData::build($query)->setOnErrorMessage(__u('Error while deleting plugin\'s data'));
|
||||
|
||||
return $this->db->doQuery($queryData);
|
||||
return $this->db->runQuery($queryData);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -155,7 +155,7 @@ final class PluginData extends BaseRepository implements PluginDataRepository
|
||||
|
||||
$queryData = QueryData::buildWithMapper($query, PluginDataModel::class);
|
||||
|
||||
return $this->db->doSelect($queryData);
|
||||
return $this->db->runQuery($queryData);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -171,7 +171,7 @@ final class PluginData extends BaseRepository implements PluginDataRepository
|
||||
->cols(PluginDataModel::getCols())
|
||||
->orderBy(['name']);
|
||||
|
||||
return $this->db->doSelect(QueryData::buildWithMapper($query, PluginDataModel::class));
|
||||
return $this->db->runQuery(QueryData::buildWithMapper($query, PluginDataModel::class));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -196,7 +196,7 @@ final class PluginData extends BaseRepository implements PluginDataRepository
|
||||
|
||||
$queryData = QueryData::buildWithMapper($query, PluginDataModel::class);
|
||||
|
||||
return $this->db->doSelect($queryData);
|
||||
return $this->db->runQuery($queryData);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -221,7 +221,7 @@ final class PluginData extends BaseRepository implements PluginDataRepository
|
||||
|
||||
$queryData = QueryData::build($query)->setOnErrorMessage(__u('Error while deleting plugin\'s data'));
|
||||
|
||||
return $this->db->doQuery($queryData);
|
||||
return $this->db->runQuery($queryData);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -243,6 +243,6 @@ final class PluginData extends BaseRepository implements PluginDataRepository
|
||||
|
||||
$queryData = QueryData::buildWithMapper($query, PluginDataModel::class);
|
||||
|
||||
return $this->db->doSelect($queryData);
|
||||
return $this->db->runQuery($queryData);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -59,7 +59,7 @@ final class Eventlog extends BaseRepository implements EventlogRepository
|
||||
|
||||
$queryData = QueryData::build($query)->setOnErrorMessage(__u('Error while clearing the event log out'));
|
||||
|
||||
return $this->db->doQuery($queryData)->getAffectedNumRows() > 0;
|
||||
return $this->db->runQuery($queryData)->getAffectedNumRows() > 0;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -90,7 +90,7 @@ final class Eventlog extends BaseRepository implements EventlogRepository
|
||||
|
||||
$queryData = QueryData::build($query)->setMapClassName(EventlogModel::class);
|
||||
|
||||
return $this->db->doSelect($queryData, true);
|
||||
return $this->db->runQuery($queryData, true);
|
||||
}
|
||||
|
||||
|
||||
@@ -111,6 +111,6 @@ final class Eventlog extends BaseRepository implements EventlogRepository
|
||||
|
||||
$queryData = QueryData::build($query)->setOnErrorMessage(__u('Error while adding the plugin'));
|
||||
|
||||
return $this->db->doQuery($queryData);
|
||||
return $this->db->runQuery($queryData);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -61,7 +61,7 @@ final class Track extends BaseRepository implements TrackRepository
|
||||
|
||||
$queryData = QueryData::build($query)->setOnErrorMessage(__u('Error while creating track'));
|
||||
|
||||
return $this->db->doQuery($queryData);
|
||||
return $this->db->runQuery($queryData);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -82,7 +82,7 @@ final class Track extends BaseRepository implements TrackRepository
|
||||
|
||||
$queryData = QueryData::build($query)->setOnErrorMessage(__u('Error while updating the track'));
|
||||
|
||||
return $this->db->doQuery($queryData)->getAffectedNumRows();
|
||||
return $this->db->runQuery($queryData)->getAffectedNumRows();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -100,7 +100,7 @@ final class Track extends BaseRepository implements TrackRepository
|
||||
|
||||
$queryData = QueryData::build($query)->setOnErrorMessage(__u('Error while clearing the tracks out'));
|
||||
|
||||
return $this->db->doQuery($queryData)->getAffectedNumRows() > 0;
|
||||
return $this->db->runQuery($queryData)->getAffectedNumRows() > 0;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -127,7 +127,7 @@ final class Track extends BaseRepository implements TrackRepository
|
||||
|
||||
$queryData = QueryData::buildWithMapper($query, TrackModel::class);
|
||||
|
||||
return $this->db->doSelect($queryData);
|
||||
return $this->db->runQuery($queryData);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -161,6 +161,6 @@ final class Track extends BaseRepository implements TrackRepository
|
||||
|
||||
$queryData = QueryData::build($query)->setMapClassName(TrackModel::class);
|
||||
|
||||
return $this->db->doSelect($queryData, true);
|
||||
return $this->db->runQuery($queryData, true);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -72,7 +72,7 @@ final class Tag extends BaseRepository implements TagRepository
|
||||
|
||||
$queryData = QueryData::build($query)->setOnErrorMessage(__u('Error while creating the tag'));
|
||||
|
||||
return $this->db->doQuery($queryData);
|
||||
return $this->db->runQuery($queryData);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -98,7 +98,7 @@ final class Tag extends BaseRepository implements TagRepository
|
||||
]
|
||||
);
|
||||
|
||||
return $this->db->doQuery(QueryData::build($query))->getNumRows() > 0;
|
||||
return $this->db->runQuery(QueryData::build($query))->getNumRows() > 0;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -132,7 +132,7 @@ final class Tag extends BaseRepository implements TagRepository
|
||||
|
||||
$queryData = QueryData::build($query)->setOnErrorMessage(__u('Error while updating the tag'));
|
||||
|
||||
return $this->db->doQuery($queryData)->getAffectedNumRows();
|
||||
return $this->db->runQuery($queryData)->getAffectedNumRows();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -160,7 +160,7 @@ final class Tag extends BaseRepository implements TagRepository
|
||||
]
|
||||
);
|
||||
|
||||
return $this->db->doQuery(QueryData::build($query))->getNumRows() > 0;
|
||||
return $this->db->runQuery(QueryData::build($query))->getNumRows() > 0;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -182,7 +182,7 @@ final class Tag extends BaseRepository implements TagRepository
|
||||
|
||||
$queryData = QueryData::buildWithMapper($query, TagModel::class);
|
||||
|
||||
return $this->db->doSelect($queryData);
|
||||
return $this->db->runQuery($queryData);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -204,7 +204,7 @@ final class Tag extends BaseRepository implements TagRepository
|
||||
|
||||
$queryData = QueryData::buildWithMapper($query, TagModel::class);
|
||||
|
||||
return $this->db->doSelect($queryData);
|
||||
return $this->db->runQuery($queryData);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -220,7 +220,7 @@ final class Tag extends BaseRepository implements TagRepository
|
||||
->cols(TagModel::getCols())
|
||||
->orderBy(['name']);
|
||||
|
||||
return $this->db->doSelect(QueryData::buildWithMapper($query, TagModel::class));
|
||||
return $this->db->runQuery(QueryData::buildWithMapper($query, TagModel::class));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -245,7 +245,7 @@ final class Tag extends BaseRepository implements TagRepository
|
||||
|
||||
$queryData = QueryData::build($query)->setOnErrorMessage(__u('Error while deleting the tags'));
|
||||
|
||||
return $this->db->doQuery($queryData);
|
||||
return $this->db->runQuery($queryData);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -268,7 +268,7 @@ final class Tag extends BaseRepository implements TagRepository
|
||||
|
||||
$queryData = QueryData::build($query)->setOnErrorMessage(__u('Error while removing the tag'));
|
||||
|
||||
return $this->db->doQuery($queryData);
|
||||
return $this->db->runQuery($queryData);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -298,6 +298,6 @@ final class Tag extends BaseRepository implements TagRepository
|
||||
|
||||
$queryData = QueryData::build($query)->setMapClassName(TagModel::class);
|
||||
|
||||
return $this->db->doSelect($queryData, true);
|
||||
return $this->db->runQuery($queryData, true);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -80,7 +80,7 @@ final class User extends BaseRepository implements UserRepository
|
||||
|
||||
$queryData = QueryData::build($query)->setOnErrorMessage(__u('Error while updating the user'));
|
||||
|
||||
return $this->db->doQuery($queryData)->getAffectedNumRows();
|
||||
return $this->db->runQuery($queryData)->getAffectedNumRows();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -113,7 +113,7 @@ final class User extends BaseRepository implements UserRepository
|
||||
]
|
||||
);
|
||||
|
||||
return $this->db->doQuery(QueryData::build($query))->getNumRows() > 0;
|
||||
return $this->db->runQuery(QueryData::build($query))->getNumRows() > 0;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -139,7 +139,7 @@ final class User extends BaseRepository implements UserRepository
|
||||
|
||||
$queryData = QueryData::build($query)->setOnErrorMessage(__u('Error while updating the password'));
|
||||
|
||||
return $this->db->doQuery($queryData)->getAffectedNumRows();
|
||||
return $this->db->runQuery($queryData)->getAffectedNumRows();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -161,7 +161,7 @@ final class User extends BaseRepository implements UserRepository
|
||||
|
||||
$queryData = QueryData::build($query)->setOnErrorMessage(__u('Error while deleting the user'));
|
||||
|
||||
return $this->db->doQuery($queryData);
|
||||
return $this->db->runQuery($queryData);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -189,7 +189,7 @@ final class User extends BaseRepository implements UserRepository
|
||||
->bindValues(['id' => $id])
|
||||
->limit(1);
|
||||
|
||||
return $this->db->doSelect(QueryData::buildWithMapper($query, UserModel::class));
|
||||
return $this->db->runQuery(QueryData::buildWithMapper($query, UserModel::class));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -214,7 +214,7 @@ final class User extends BaseRepository implements UserRepository
|
||||
|
||||
$queryData = QueryData::build($query)->setOnErrorMessage(__u('Error while deleting the users'));
|
||||
|
||||
return $this->db->doQuery($queryData);
|
||||
return $this->db->runQuery($queryData);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -261,7 +261,7 @@ final class User extends BaseRepository implements UserRepository
|
||||
|
||||
$queryData = QueryData::build($query)->setMapClassName(UserModel::class);
|
||||
|
||||
return $this->db->doSelect($queryData, true);
|
||||
return $this->db->runQuery($queryData, true);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -286,7 +286,7 @@ final class User extends BaseRepository implements UserRepository
|
||||
|
||||
$queryData = QueryData::build($query)->setOnErrorMessage(__u('Error while creating the user'));
|
||||
|
||||
return $this->db->doQuery($queryData);
|
||||
return $this->db->runQuery($queryData);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -317,7 +317,7 @@ final class User extends BaseRepository implements UserRepository
|
||||
]
|
||||
);
|
||||
|
||||
return $this->db->doQuery(QueryData::build($query))->getNumRows() > 0;
|
||||
return $this->db->runQuery(QueryData::build($query))->getNumRows() > 0;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -344,7 +344,7 @@ final class User extends BaseRepository implements UserRepository
|
||||
->bindValues(['login' => $login])
|
||||
->limit(1);
|
||||
|
||||
return $this->db->doSelect(QueryData::buildWithMapper($query, UserModel::class));
|
||||
return $this->db->runQuery(QueryData::buildWithMapper($query, UserModel::class));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -360,7 +360,7 @@ final class User extends BaseRepository implements UserRepository
|
||||
->cols(UserModel::getCols())
|
||||
->orderBy(['name']);
|
||||
|
||||
return $this->db->doSelect(QueryData::buildWithMapper($query, UserModel::class));
|
||||
return $this->db->runQuery(QueryData::buildWithMapper($query, UserModel::class));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -386,7 +386,7 @@ final class User extends BaseRepository implements UserRepository
|
||||
->where('id = :id', ['id' => $id])
|
||||
->limit(1);
|
||||
|
||||
return $this->db->doQuery(QueryData::build($query))->getAffectedNumRows();
|
||||
return $this->db->runQuery(QueryData::build($query))->getAffectedNumRows();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -408,7 +408,7 @@ final class User extends BaseRepository implements UserRepository
|
||||
->where('id = :id', ['id' => $id])
|
||||
->limit(1);
|
||||
|
||||
return $this->db->doQuery(QueryData::build($query))->getAffectedNumRows();
|
||||
return $this->db->runQuery(QueryData::build($query))->getAffectedNumRows();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -426,7 +426,7 @@ final class User extends BaseRepository implements UserRepository
|
||||
->where('UPPER(ssoLogin) = UPPER(:login)')
|
||||
->bindValues(['login' => $login]);
|
||||
|
||||
return $this->db->doSelect(QueryData::build($query))->getNumRows() > 0;
|
||||
return $this->db->runQuery(QueryData::build($query))->getNumRows() > 0;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -456,7 +456,7 @@ final class User extends BaseRepository implements UserRepository
|
||||
->bindValues(['login' => $user->getLogin()])
|
||||
->limit(1);
|
||||
|
||||
return $this->db->doQuery(QueryData::build($query))->getAffectedNumRows();
|
||||
return $this->db->runQuery(QueryData::build($query))->getAffectedNumRows();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -481,7 +481,7 @@ final class User extends BaseRepository implements UserRepository
|
||||
->where('id = :id', ['id' => $id])
|
||||
->limit(1);
|
||||
|
||||
return $this->db->doQuery(QueryData::build($query))->getAffectedNumRows();
|
||||
return $this->db->runQuery(QueryData::build($query))->getAffectedNumRows();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -520,7 +520,7 @@ final class User extends BaseRepository implements UserRepository
|
||||
->orderBy([sprintf('%s.login', UserModel::TABLE)])
|
||||
->bindValues(['userGroupId' => $groupId]);
|
||||
|
||||
return $this->db->doSelect(QueryData::build($query)->setMapClassName(UserModel::class));
|
||||
return $this->db->runQuery(QueryData::build($query)->setMapClassName(UserModel::class));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -538,7 +538,7 @@ final class User extends BaseRepository implements UserRepository
|
||||
->where('isDisabled = 0')
|
||||
->orderBy(['login']);
|
||||
|
||||
return $this->db->doSelect(QueryData::build($query)->setMapClassName(UserModel::class));
|
||||
return $this->db->runQuery(QueryData::build($query)->setMapClassName(UserModel::class));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -559,7 +559,7 @@ final class User extends BaseRepository implements UserRepository
|
||||
->where('isDisabled = 0')
|
||||
->orderBy(['login']);
|
||||
|
||||
return $this->db->doSelect(QueryData::build($query)->setMapClassName(UserModel::class));
|
||||
return $this->db->runQuery(QueryData::build($query)->setMapClassName(UserModel::class));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -674,6 +674,6 @@ final class User extends BaseRepository implements UserRepository
|
||||
->orderBy(['Items.ref'])
|
||||
->bindValues(['userId' => $id]);
|
||||
|
||||
return $this->db->doSelect(QueryData::build($query));
|
||||
return $this->db->runQuery(QueryData::build($query));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -67,7 +67,7 @@ final class UserGroup extends BaseRepository implements UserGroupRepository
|
||||
|
||||
$queryData = QueryData::build($query)->setOnErrorMessage(__u('Error while deleting the group'));
|
||||
|
||||
return $this->db->doQuery($queryData);
|
||||
return $this->db->runQuery($queryData);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -97,7 +97,7 @@ final class UserGroup extends BaseRepository implements UserGroupRepository
|
||||
->where('userGroupId = :userGroupId')
|
||||
->bindValues(['userGroupId' => $userGroupId]);
|
||||
|
||||
return $this->db->doSelect(QueryData::build($query));
|
||||
return $this->db->runQuery(QueryData::build($query));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -137,7 +137,7 @@ final class UserGroup extends BaseRepository implements UserGroupRepository
|
||||
->innerJoin(UserModel::TABLE, sprintf('%s.id = %s.id', UserModel::TABLE, 'Users'))
|
||||
->bindValues(['userGroupId' => $userGroupId],);
|
||||
|
||||
return $this->db->doSelect(QueryData::build($query));
|
||||
return $this->db->runQuery(QueryData::build($query));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -156,7 +156,7 @@ final class UserGroup extends BaseRepository implements UserGroupRepository
|
||||
->where('id = :id', ['id' => $id])
|
||||
->limit(1);
|
||||
|
||||
return $this->db->doSelect(QueryData::buildWithMapper($query, UserGroupModel::class));
|
||||
return $this->db->runQuery(QueryData::buildWithMapper($query, UserGroupModel::class));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -175,7 +175,7 @@ final class UserGroup extends BaseRepository implements UserGroupRepository
|
||||
->where('name = :name', ['name' => $name])
|
||||
->limit(1);
|
||||
|
||||
return $this->db->doSelect(QueryData::buildWithMapper($query, UserGroupModel::class));
|
||||
return $this->db->runQuery(QueryData::buildWithMapper($query, UserGroupModel::class));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -191,7 +191,7 @@ final class UserGroup extends BaseRepository implements UserGroupRepository
|
||||
->cols(UserGroupModel::getCols())
|
||||
->orderBy(['name']);
|
||||
|
||||
return $this->db->doSelect(QueryData::buildWithMapper($query, UserGroupModel::class));
|
||||
return $this->db->runQuery(QueryData::buildWithMapper($query, UserGroupModel::class));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -214,7 +214,7 @@ final class UserGroup extends BaseRepository implements UserGroupRepository
|
||||
->from(UserGroupModel::TABLE)
|
||||
->where('id IN (:ids)', ['ids' => $ids]);
|
||||
|
||||
return $this->db->doQuery(QueryData::build($query));
|
||||
return $this->db->runQuery(QueryData::build($query));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -244,7 +244,7 @@ final class UserGroup extends BaseRepository implements UserGroupRepository
|
||||
|
||||
$queryData = QueryData::build($query)->setMapClassName(UserGroupModel::class);
|
||||
|
||||
return $this->db->doSelect($queryData, true);
|
||||
return $this->db->runQuery($queryData, true);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -270,7 +270,7 @@ final class UserGroup extends BaseRepository implements UserGroupRepository
|
||||
|
||||
$queryData = QueryData::build($query)->setOnErrorMessage(__u('Error while creating the group'));
|
||||
|
||||
return $this->db->doQuery($queryData);
|
||||
return $this->db->runQuery($queryData);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -290,7 +290,7 @@ final class UserGroup extends BaseRepository implements UserGroupRepository
|
||||
->from(UserGroupModel::TABLE)
|
||||
->where('UPPER(:name) = UPPER(name)', ['name' => $userGroup->getName()]);
|
||||
|
||||
return $this->db->doQuery(QueryData::build($query))->getNumRows() > 0;
|
||||
return $this->db->runQuery(QueryData::build($query))->getNumRows() > 0;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -318,7 +318,7 @@ final class UserGroup extends BaseRepository implements UserGroupRepository
|
||||
|
||||
$queryData = QueryData::build($query)->setOnErrorMessage(__u('Error while updating the group'));
|
||||
|
||||
return $this->db->doQuery($queryData)->getAffectedNumRows();
|
||||
return $this->db->runQuery($queryData)->getAffectedNumRows();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -339,6 +339,6 @@ final class UserGroup extends BaseRepository implements UserGroupRepository
|
||||
->where('id <> :id', ['id' => $userGroup->getId()])
|
||||
->where('UPPER(:name) = UPPER(name)', ['name' => $userGroup->getName()]);
|
||||
|
||||
return $this->db->doQuery(QueryData::build($query))->getNumRows() > 0;
|
||||
return $this->db->runQuery(QueryData::build($query))->getNumRows() > 0;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -61,7 +61,7 @@ final class UserPassRecover extends BaseRepository implements UserPassRecoverRep
|
||||
->where('date >= :date')
|
||||
->bindValues(['userId' => $userId, 'date' => $time]);
|
||||
|
||||
return $this->db->doSelect(QueryData::build($query))->getNumRows();
|
||||
return $this->db->runQuery(QueryData::build($query))->getNumRows();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -85,7 +85,7 @@ final class UserPassRecover extends BaseRepository implements UserPassRecoverRep
|
||||
|
||||
$queryData = QueryData::build($query)->setOnErrorMessage(__u('Error while generating the recovering hash'));
|
||||
|
||||
return $this->db->doQuery($queryData);
|
||||
return $this->db->runQuery($queryData);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -111,7 +111,7 @@ final class UserPassRecover extends BaseRepository implements UserPassRecoverRep
|
||||
$queryData = QueryData::build($query);
|
||||
$queryData->setOnErrorMessage(__u('Error while checking hash'));
|
||||
|
||||
return $this->db->doQuery($queryData)->getAffectedNumRows();
|
||||
return $this->db->runQuery($queryData)->getAffectedNumRows();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -140,6 +140,6 @@ final class UserPassRecover extends BaseRepository implements UserPassRecoverRep
|
||||
]
|
||||
);
|
||||
|
||||
return $this->db->doSelect(QueryData::build($query)->setMapClassName(UserPassRecoverModel::class));
|
||||
return $this->db->runQuery(QueryData::build($query)->setMapClassName(UserPassRecoverModel::class));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -62,7 +62,7 @@ final class UserProfile extends BaseRepository implements UserProfileRepository
|
||||
|
||||
$queryData = QueryData::build($query)->setOnErrorMessage(__u('Error while removing the profile'));
|
||||
|
||||
return $this->db->doQuery($queryData);
|
||||
return $this->db->runQuery($queryData);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -81,7 +81,7 @@ final class UserProfile extends BaseRepository implements UserProfileRepository
|
||||
->where('id = :id', ['id' => $id])
|
||||
->limit(1);
|
||||
|
||||
return $this->db->doSelect(QueryData::buildWithMapper($query, UserProfileModel::class));
|
||||
return $this->db->runQuery(QueryData::buildWithMapper($query, UserProfileModel::class));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -97,7 +97,7 @@ final class UserProfile extends BaseRepository implements UserProfileRepository
|
||||
->cols(UserProfileModel::getCols())
|
||||
->orderBy(['name']);
|
||||
|
||||
return $this->db->doSelect(QueryData::buildWithMapper($query, UserProfileModel::class));
|
||||
return $this->db->runQuery(QueryData::buildWithMapper($query, UserProfileModel::class));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -120,7 +120,7 @@ final class UserProfile extends BaseRepository implements UserProfileRepository
|
||||
->from(UserProfileModel::TABLE)
|
||||
->where('id IN (:ids)', ['ids' => $ids]);
|
||||
|
||||
return $this->db->doQuery(QueryData::build($query));
|
||||
return $this->db->runQuery(QueryData::build($query));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -148,7 +148,7 @@ final class UserProfile extends BaseRepository implements UserProfileRepository
|
||||
|
||||
$queryData = QueryData::build($query)->setMapClassName(UserProfileModel::class);
|
||||
|
||||
return $this->db->doSelect($queryData, true);
|
||||
return $this->db->runQuery($queryData, true);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -174,7 +174,7 @@ final class UserProfile extends BaseRepository implements UserProfileRepository
|
||||
|
||||
$queryData = QueryData::build($query)->setOnErrorMessage(__u('Error while creating the profile'));
|
||||
|
||||
return $this->db->doQuery($queryData);
|
||||
return $this->db->runQuery($queryData);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -194,7 +194,7 @@ final class UserProfile extends BaseRepository implements UserProfileRepository
|
||||
->from(UserProfileModel::TABLE)
|
||||
->where('UPPER(:name) = UPPER(name)', ['name' => $userProfile->getName()]);
|
||||
|
||||
return $this->db->doQuery(QueryData::build($query))->getNumRows() > 0;
|
||||
return $this->db->runQuery(QueryData::build($query))->getNumRows() > 0;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -222,7 +222,7 @@ final class UserProfile extends BaseRepository implements UserProfileRepository
|
||||
|
||||
$queryData = QueryData::build($query)->setOnErrorMessage(__u('Error while updating the profile'));
|
||||
|
||||
return $this->db->doQuery($queryData)->getAffectedNumRows();
|
||||
return $this->db->runQuery($queryData)->getAffectedNumRows();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -243,6 +243,6 @@ final class UserProfile extends BaseRepository implements UserProfileRepository
|
||||
->where('id <> :id', ['id' => $userProfile->getId()])
|
||||
->where('UPPER(:name) = UPPER(name)', ['name' => $userProfile->getName()]);
|
||||
|
||||
return $this->db->doQuery(QueryData::build($query))->getNumRows() > 0;
|
||||
return $this->db->runQuery(QueryData::build($query))->getNumRows() > 0;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -60,7 +60,7 @@ final class UserToUserGroup extends BaseRepository implements UserToUserGroupRep
|
||||
->where('userId = :userId')
|
||||
->bindValues(['userGroupId' => $groupId, 'userId' => $userId]);
|
||||
|
||||
return $this->db->doSelect(QueryData::build($query))->getNumRows() === 1;
|
||||
return $this->db->runQuery(QueryData::build($query))->getNumRows() === 1;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -78,7 +78,7 @@ final class UserToUserGroup extends BaseRepository implements UserToUserGroupRep
|
||||
->cols(UserToUserGroupModel::getCols())
|
||||
->where('userId = :userId', ['userId' => $userId]);
|
||||
|
||||
return $this->db->doSelect(QueryData::build($query)->setMapClassName(UserToUserGroupModel::class));
|
||||
return $this->db->runQuery(QueryData::build($query)->setMapClassName(UserToUserGroupModel::class));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -121,7 +121,7 @@ final class UserToUserGroup extends BaseRepository implements UserToUserGroupRep
|
||||
|
||||
$queryData = QueryData::build($query)->setOnErrorMessage(__u('Error while deleting the group users'));
|
||||
|
||||
return $this->db->doQuery($queryData);
|
||||
return $this->db->runQuery($queryData);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -149,7 +149,7 @@ final class UserToUserGroup extends BaseRepository implements UserToUserGroupRep
|
||||
|
||||
$queryData = QueryData::build($query)->setOnErrorMessage(__u('Error while setting users in the group'));
|
||||
|
||||
return $this->db->doQuery($queryData);
|
||||
return $this->db->runQuery($queryData);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -168,6 +168,6 @@ final class UserToUserGroup extends BaseRepository implements UserToUserGroupRep
|
||||
->where('userGroupId = :userGroupId', ['userGroupId' => $id])
|
||||
->limit(1);
|
||||
|
||||
return $this->db->doSelect(QueryData::buildWithMapper($query, UserToUserGroupModel::class));
|
||||
return $this->db->runQuery(QueryData::buildWithMapper($query, UserToUserGroupModel::class));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -405,11 +405,11 @@ class AccountTest extends UnitaryTestCase
|
||||
|
||||
$encryptedPassword = new EncryptedPassword(self::$faker->password, self::$faker->password);
|
||||
|
||||
$result = new QueryResult();
|
||||
$result = new QueryResult(null, 1);
|
||||
|
||||
$this->accountRepository->expects(self::once())->method('updatePassword')
|
||||
->with($id, $encryptedPassword)
|
||||
->willReturn($result->setAffectedNumRows(1));
|
||||
->willReturn($result);
|
||||
|
||||
$this->account->updatePasswordMasterPass($id, $encryptedPassword);
|
||||
}
|
||||
@@ -425,12 +425,9 @@ class AccountTest extends UnitaryTestCase
|
||||
|
||||
$encryptedPassword = new EncryptedPassword(self::$faker->password, self::$faker->password);
|
||||
|
||||
$result = new QueryResult();
|
||||
$result->setAffectedNumRows(0);
|
||||
|
||||
$this->accountRepository->expects(self::once())->method('updatePassword')
|
||||
->with($id, $encryptedPassword)
|
||||
->willReturn($result);
|
||||
->willReturn(new QueryResult(null, 0));
|
||||
|
||||
$this->expectException(ServiceException::class);
|
||||
$this->expectExceptionMessage('Error while updating the password');
|
||||
@@ -675,7 +672,8 @@ class AccountTest extends UnitaryTestCase
|
||||
$queryResult = new QueryResult();
|
||||
|
||||
$this->accountRepository->expects(self::once())->method('delete')
|
||||
->with($id)->willReturn($queryResult->setAffectedNumRows(1));
|
||||
->with($id)
|
||||
->willReturn(new QueryResult(null, 1));
|
||||
|
||||
$this->account->delete($id);
|
||||
}
|
||||
@@ -698,11 +696,10 @@ class AccountTest extends UnitaryTestCase
|
||||
$this->accountHistoryService->expects(self::once())->method('create')
|
||||
->with($accountHistoryCreateDto);
|
||||
|
||||
$queryResult = new QueryResult();
|
||||
$queryResult->setAffectedNumRows(0);
|
||||
|
||||
$this->accountRepository->expects(self::once())->method('delete')
|
||||
->with($id)->willReturn($queryResult);
|
||||
->with($id)
|
||||
->willReturn(new QueryResult(null, 0));
|
||||
|
||||
$this->expectException(NoSuchItemException::class);
|
||||
$this->expectExceptionMessage('Account not found');
|
||||
@@ -718,10 +715,8 @@ class AccountTest extends UnitaryTestCase
|
||||
{
|
||||
$id = self::$faker->randomNumber();
|
||||
|
||||
$queryResult = new QueryResult();
|
||||
|
||||
$this->accountRepository->expects(self::once())->method('incrementViewCounter')
|
||||
->with($id)->willReturn($queryResult->setAffectedNumRows(1));
|
||||
->with($id)->willReturn(new QueryResult(null, 1));
|
||||
|
||||
$this->assertTrue($this->account->incrementViewCounter($id));
|
||||
}
|
||||
@@ -734,11 +729,9 @@ class AccountTest extends UnitaryTestCase
|
||||
{
|
||||
$id = self::$faker->randomNumber();
|
||||
|
||||
$queryResult = new QueryResult();
|
||||
$queryResult->setAffectedNumRows(0);
|
||||
|
||||
$this->accountRepository->expects(self::once())->method('incrementViewCounter')
|
||||
->with($id)->willReturn($queryResult);
|
||||
->with($id)
|
||||
->willReturn(new QueryResult(null, 0));
|
||||
|
||||
$this->assertFalse($this->account->incrementViewCounter($id));
|
||||
}
|
||||
@@ -801,8 +794,6 @@ class AccountTest extends UnitaryTestCase
|
||||
{
|
||||
$accountHistoryDto = AccountDataGenerator::factory()->buildAccountHistoryDto();
|
||||
|
||||
$queryResult = new QueryResult();
|
||||
|
||||
$this->accountRepository->expects(self::once())->method('createRemoved')
|
||||
->with(
|
||||
AccountModel::restoreRemoved(
|
||||
@@ -810,7 +801,7 @@ class AccountTest extends UnitaryTestCase
|
||||
$this->context->getUserData()->getId()
|
||||
)
|
||||
)
|
||||
->willReturn($queryResult->setAffectedNumRows(1));
|
||||
->willReturn(new QueryResult(null, 1));
|
||||
|
||||
$this->account->restoreRemoved($accountHistoryDto);
|
||||
}
|
||||
@@ -898,8 +889,6 @@ class AccountTest extends UnitaryTestCase
|
||||
$this->accountHistoryService->expects(self::once())->method('create')
|
||||
->with($accountHistoryCreateDto);
|
||||
|
||||
$queryResult = new QueryResult();
|
||||
|
||||
$this->accountRepository->expects(self::once())->method('restoreModified')
|
||||
->with(
|
||||
$accountHistoryDto->getAccountId(),
|
||||
@@ -908,7 +897,7 @@ class AccountTest extends UnitaryTestCase
|
||||
$this->context->getUserData()->getId()
|
||||
)
|
||||
)
|
||||
->willReturn($queryResult->setAffectedNumRows(1));
|
||||
->willReturn(new QueryResult(null, 1));
|
||||
|
||||
$this->account->restoreModified($accountHistoryDto);
|
||||
}
|
||||
@@ -936,8 +925,6 @@ class AccountTest extends UnitaryTestCase
|
||||
$this->accountHistoryService->expects(self::once())->method('create')
|
||||
->with($accountHistoryCreateDto);
|
||||
|
||||
$queryResult = new QueryResult();
|
||||
$queryResult->setAffectedNumRows(0);
|
||||
|
||||
$this->accountRepository->expects(self::once())->method('restoreModified')
|
||||
->with(
|
||||
@@ -947,7 +934,7 @@ class AccountTest extends UnitaryTestCase
|
||||
$this->context->getUserData()->getId()
|
||||
)
|
||||
)
|
||||
->willReturn($queryResult);
|
||||
->willReturn(new QueryResult(null, 0));
|
||||
|
||||
$this->expectException(ServiceException::class);
|
||||
$this->expectExceptionMessage('Error on restoring the account');
|
||||
@@ -1005,11 +992,9 @@ class AccountTest extends UnitaryTestCase
|
||||
->with(ItemPresetInterface::ITEM_TYPE_ACCOUNT_PRIVATE)
|
||||
->willReturn(null);
|
||||
|
||||
$queryResult = new QueryResult();
|
||||
|
||||
$this->accountRepository->expects(self::once())->method('create')
|
||||
->with(AccountModel::create($accountCreateDto))
|
||||
->willReturn($queryResult->setLastId($id));
|
||||
->willReturn(new QueryResult(null, 0, $id));
|
||||
|
||||
$this->accountItemsService->expects(self::once())->method('addItems')
|
||||
->with(true, $id, $accountCreateDto->withEncryptedPassword($encryptedPassword));
|
||||
@@ -1042,11 +1027,9 @@ class AccountTest extends UnitaryTestCase
|
||||
->with(ItemPresetInterface::ITEM_TYPE_ACCOUNT_PRIVATE)
|
||||
->willReturn(null);
|
||||
|
||||
$queryResult = new QueryResult();
|
||||
|
||||
$this->accountRepository->expects(self::once())->method('create')
|
||||
->with(AccountModel::create($accountCreateDto))
|
||||
->willReturn($queryResult->setLastId($id));
|
||||
->willReturn(new QueryResult(null, 0, $id));
|
||||
|
||||
$this->accountItemsService->expects(self::once())->method('addItems')
|
||||
->with(false, $id, $accountCreateDto->withEncryptedPassword($encryptedPassword));
|
||||
@@ -1089,15 +1072,13 @@ class AccountTest extends UnitaryTestCase
|
||||
->with(ItemPresetInterface::ITEM_TYPE_ACCOUNT_PRIVATE)
|
||||
->willReturn($itemPreset);
|
||||
|
||||
$queryResult = new QueryResult();
|
||||
|
||||
$this->accountRepository->expects(self::once())->method('create')
|
||||
->with(
|
||||
new Callback(function (AccountModel $account) {
|
||||
return $account->getIsPrivate() === 1 && $account->getIsPrivateGroup() === 0;
|
||||
}),
|
||||
)
|
||||
->willReturn($queryResult->setLastId($id));
|
||||
->willReturn(new QueryResult(null, 0, $id));
|
||||
|
||||
$this->accountItemsService->expects(self::once())->method('addItems')
|
||||
->with(
|
||||
@@ -1146,15 +1127,13 @@ class AccountTest extends UnitaryTestCase
|
||||
->with(ItemPresetInterface::ITEM_TYPE_ACCOUNT_PRIVATE)
|
||||
->willReturn($itemPreset);
|
||||
|
||||
$queryResult = new QueryResult();
|
||||
|
||||
$this->accountRepository->expects(self::once())->method('create')
|
||||
->with(
|
||||
new Callback(function (AccountModel $account) {
|
||||
return $account->getIsPrivate() === 0 && $account->getIsPrivateGroup() === 1;
|
||||
}),
|
||||
)
|
||||
->willReturn($queryResult->setLastId($id));
|
||||
->willReturn(new QueryResult(null, 0, $id));
|
||||
|
||||
$this->accountItemsService->expects(self::once())->method('addItems')
|
||||
->with(
|
||||
@@ -1179,10 +1158,8 @@ class AccountTest extends UnitaryTestCase
|
||||
{
|
||||
$num = self::$faker->randomNumber();
|
||||
|
||||
$queryResult = new QueryResult([new Simple(['num' => $num])]);
|
||||
|
||||
$this->accountRepository->expects(self::once())->method('getTotalNumAccounts')
|
||||
->willReturn($queryResult);
|
||||
->willReturn(new QueryResult([new Simple(['num' => $num])]));
|
||||
|
||||
$this->assertEquals($num, $this->account->getTotalNumAccounts());
|
||||
}
|
||||
@@ -1243,10 +1220,8 @@ class AccountTest extends UnitaryTestCase
|
||||
{
|
||||
$ids = array_map(fn() => self::$faker->randomNumber(), range(0, 4));
|
||||
|
||||
$queryResult = new QueryResult();
|
||||
|
||||
$this->accountRepository->expects(self::once())->method('deleteByIdBatch')
|
||||
->with($ids)->willReturn($queryResult->setAffectedNumRows(1));
|
||||
->with($ids)->willReturn(new QueryResult(null, 1));
|
||||
|
||||
$this->account->deleteByIdBatch($ids);
|
||||
}
|
||||
@@ -1259,10 +1234,8 @@ class AccountTest extends UnitaryTestCase
|
||||
{
|
||||
$ids = array_map(fn() => self::$faker->randomNumber(), range(0, 4));
|
||||
|
||||
$queryResult = new QueryResult();
|
||||
|
||||
$this->accountRepository->expects(self::once())->method('deleteByIdBatch')
|
||||
->with($ids)->willReturn($queryResult->setAffectedNumRows(0));
|
||||
->with($ids)->willReturn(new QueryResult(null, 0));
|
||||
|
||||
$this->expectException(ServiceException::class);
|
||||
$this->expectExceptionMessage('Error while deleting the accounts');
|
||||
@@ -1298,10 +1271,9 @@ class AccountTest extends UnitaryTestCase
|
||||
{
|
||||
$id = self::$faker->randomNumber();
|
||||
|
||||
$queryResult = new QueryResult();
|
||||
|
||||
$this->accountRepository->expects(self::once())->method('incrementDecryptCounter')
|
||||
->with($id)->willReturn($queryResult->setAffectedNumRows(1));
|
||||
->with($id)
|
||||
->willReturn(new QueryResult(null, 1));
|
||||
|
||||
$this->assertTrue($this->account->incrementDecryptCounter($id));
|
||||
}
|
||||
@@ -1317,7 +1289,8 @@ class AccountTest extends UnitaryTestCase
|
||||
$queryResult = new QueryResult();
|
||||
|
||||
$this->accountRepository->expects(self::once())->method('incrementDecryptCounter')
|
||||
->with($id)->willReturn($queryResult->setAffectedNumRows(0));
|
||||
->with($id)
|
||||
->willReturn(new QueryResult(null, 0));
|
||||
|
||||
$this->assertFalse($this->account->incrementDecryptCounter($id));
|
||||
}
|
||||
|
||||
@@ -513,8 +513,7 @@ class PublicLinkTest extends UnitaryTestCase
|
||||
public function testCreate()
|
||||
{
|
||||
$publicLinkData = PublicLinkDataGenerator::factory()->buildPublicLink();
|
||||
$result = new QueryResult();
|
||||
$result->setLastId(self::$faker->randomNumber());
|
||||
$result = new QueryResult(null, 0, self::$faker->randomNumber());
|
||||
|
||||
$this->publicLinkRepository
|
||||
->expects(self::once())
|
||||
|
||||
@@ -82,13 +82,11 @@ class AuthTokenTest extends UnitaryTestCase
|
||||
{
|
||||
$ids = array_map(fn() => self::$faker->randomNumber(), range(0, 4));
|
||||
|
||||
$queryResult = new QueryResult();
|
||||
|
||||
$this->authTokenRepository
|
||||
->expects(self::once())
|
||||
->method('deleteByIdBatch')
|
||||
->with($ids)
|
||||
->willReturn($queryResult->setAffectedNumRows(1));
|
||||
->willReturn(new QueryResult(null, 1));
|
||||
|
||||
$this->authToken->deleteByIdBatch($ids);
|
||||
}
|
||||
@@ -101,14 +99,11 @@ class AuthTokenTest extends UnitaryTestCase
|
||||
{
|
||||
$ids = array_map(fn() => self::$faker->randomNumber(), range(0, 4));
|
||||
|
||||
$queryResult = new QueryResult();
|
||||
$queryResult->setAffectedNumRows(0);
|
||||
|
||||
$this->authTokenRepository
|
||||
->expects(self::once())
|
||||
->method('deleteByIdBatch')
|
||||
->with($ids)
|
||||
->willReturn($queryResult);
|
||||
->willReturn(new QueryResult(null, 0));
|
||||
|
||||
$this->expectException(ServiceException::class);
|
||||
$this->expectExceptionMessage('Error while removing the tokens');
|
||||
@@ -149,8 +144,6 @@ class AuthTokenTest extends UnitaryTestCase
|
||||
->with($authToken->getUserId())
|
||||
->willReturn(new QueryResult([$authToken]));
|
||||
|
||||
$queryResult = new QueryResult([]);
|
||||
|
||||
$this->authTokenRepository
|
||||
->expects(self::once())
|
||||
->method('create')
|
||||
@@ -166,7 +159,7 @@ class AuthTokenTest extends UnitaryTestCase
|
||||
&& $current->getCreatedBy() === $this->context->getUserData()->getId();
|
||||
})
|
||||
)
|
||||
->willReturn($queryResult->setLastId(100));
|
||||
->willReturn(new QueryResult(null, 0, 100));
|
||||
|
||||
$out = $this->authToken->create($authToken);
|
||||
|
||||
@@ -190,8 +183,6 @@ class AuthTokenTest extends UnitaryTestCase
|
||||
->with($authToken->getUserId())
|
||||
->willReturn(new QueryResult([]));
|
||||
|
||||
$queryResult = new QueryResult([]);
|
||||
|
||||
$this->authTokenRepository
|
||||
->expects(self::once())
|
||||
->method('create')
|
||||
@@ -207,7 +198,7 @@ class AuthTokenTest extends UnitaryTestCase
|
||||
&& $current->getCreatedBy() === $this->context->getUserData()->getId();
|
||||
})
|
||||
)
|
||||
->willReturn($queryResult->setLastId(100));
|
||||
->willReturn(new QueryResult(null, 0, 100));
|
||||
|
||||
$out = $this->authToken->create($authToken);
|
||||
|
||||
@@ -236,8 +227,6 @@ class AuthTokenTest extends UnitaryTestCase
|
||||
->with($authToken->getUserId())
|
||||
->willReturn(new QueryResult([$authToken]));
|
||||
|
||||
$queryResult = new QueryResult([]);
|
||||
|
||||
$this->authTokenRepository
|
||||
->expects(self::once())
|
||||
->method('create')
|
||||
@@ -253,7 +242,7 @@ class AuthTokenTest extends UnitaryTestCase
|
||||
&& $current->getCreatedBy() === $this->context->getUserData()->getId();
|
||||
})
|
||||
)
|
||||
->willReturn($queryResult->setLastId(100));
|
||||
->willReturn(new QueryResult(null, 0, 100));
|
||||
|
||||
$password = $authToken->getHash() . $authToken->getToken();
|
||||
|
||||
@@ -293,9 +282,6 @@ class AuthTokenTest extends UnitaryTestCase
|
||||
|
||||
/**
|
||||
* @throws NoSuchItemException
|
||||
* @throws ConstraintException
|
||||
* @throws QueryException
|
||||
* @throws SPException
|
||||
*/
|
||||
public function testGetTokenByToken()
|
||||
{
|
||||
@@ -432,9 +418,6 @@ class AuthTokenTest extends UnitaryTestCase
|
||||
->with($authToken->getUserId())
|
||||
->willReturn(new QueryResult([$authToken]));
|
||||
|
||||
$queryResult = new QueryResult([]);
|
||||
$queryResult->setLastId(100);
|
||||
|
||||
$this->authTokenRepository
|
||||
->expects(self::once())
|
||||
->method('update')
|
||||
@@ -519,13 +502,11 @@ class AuthTokenTest extends UnitaryTestCase
|
||||
{
|
||||
$id = self::$faker->randomNumber();
|
||||
|
||||
$queryResult = new QueryResult([1]);
|
||||
|
||||
$this->authTokenRepository
|
||||
->expects(self::once())
|
||||
->method('delete')
|
||||
->with($id)
|
||||
->willReturn($queryResult->setAffectedNumRows(1));
|
||||
->willReturn(new QueryResult(null, 1));
|
||||
|
||||
$this->authToken->delete($id);
|
||||
}
|
||||
|
||||
@@ -122,13 +122,11 @@ class CategoryTest extends UnitaryTestCase
|
||||
{
|
||||
$id = self::$faker->randomNumber();
|
||||
|
||||
$queryResult = new QueryResult([1]);
|
||||
|
||||
$this->categoryRepository
|
||||
->expects(self::once())
|
||||
->method('delete')
|
||||
->with($id)
|
||||
->willReturn($queryResult->setAffectedNumRows(1));
|
||||
->willReturn(new QueryResult(null, 1));
|
||||
|
||||
$this->category->delete($id);
|
||||
}
|
||||
@@ -161,8 +159,7 @@ class CategoryTest extends UnitaryTestCase
|
||||
{
|
||||
$category = CategoryGenerator::factory()->buildCategory();
|
||||
|
||||
$queryResult = new QueryResult();
|
||||
$queryResult->setLastId(self::$faker->randomNumber());
|
||||
$queryResult = new QueryResult(null, 0, self::$faker->randomNumber());
|
||||
|
||||
$this->categoryRepository
|
||||
->expects(self::once())
|
||||
@@ -184,9 +181,6 @@ class CategoryTest extends UnitaryTestCase
|
||||
{
|
||||
$category = CategoryGenerator::factory()->buildCategory();
|
||||
|
||||
$queryResult = new QueryResult();
|
||||
$queryResult->setLastId(self::$faker->randomNumber());
|
||||
|
||||
$this->categoryRepository
|
||||
->expects(self::once())
|
||||
->method('update')
|
||||
@@ -250,13 +244,11 @@ class CategoryTest extends UnitaryTestCase
|
||||
{
|
||||
$ids = array_map(fn() => self::$faker->randomNumber(), range(0, 4));
|
||||
|
||||
$queryResult = new QueryResult();
|
||||
|
||||
$this->categoryRepository
|
||||
->expects(self::once())
|
||||
->method('deleteByIdBatch')
|
||||
->with($ids)
|
||||
->willReturn($queryResult->setAffectedNumRows(1));
|
||||
->willReturn(new QueryResult(null, 1));
|
||||
|
||||
$this->category->deleteByIdBatch($ids);
|
||||
}
|
||||
@@ -269,14 +261,11 @@ class CategoryTest extends UnitaryTestCase
|
||||
{
|
||||
$ids = array_map(fn() => self::$faker->randomNumber(), range(0, 4));
|
||||
|
||||
$queryResult = new QueryResult();
|
||||
$queryResult->setAffectedNumRows(0);
|
||||
|
||||
$this->categoryRepository
|
||||
->expects(self::once())
|
||||
->method('deleteByIdBatch')
|
||||
->with($ids)
|
||||
->willReturn($queryResult);
|
||||
->willReturn(new QueryResult(null, 0));
|
||||
|
||||
$this->expectException(ServiceException::class);
|
||||
$this->expectExceptionMessage('Error while deleting categories');
|
||||
|
||||
@@ -124,13 +124,11 @@ class ClientTest extends UnitaryTestCase
|
||||
{
|
||||
$id = self::$faker->randomNumber();
|
||||
|
||||
$queryResult = new QueryResult([1]);
|
||||
|
||||
$this->clientRepository
|
||||
->expects(self::once())
|
||||
->method('delete')
|
||||
->with($id)
|
||||
->willReturn($queryResult->setAffectedNumRows(1));
|
||||
->willReturn(new QueryResult(null, 1));
|
||||
|
||||
$this->client->delete($id);
|
||||
}
|
||||
@@ -163,8 +161,7 @@ class ClientTest extends UnitaryTestCase
|
||||
{
|
||||
$client = ClientGenerator::factory()->buildClient();
|
||||
|
||||
$queryResult = new QueryResult();
|
||||
$queryResult->setLastId(self::$faker->randomNumber());
|
||||
$queryResult = new QueryResult(null, 0, self::$faker->randomNumber());
|
||||
|
||||
$this->clientRepository
|
||||
->expects(self::once())
|
||||
@@ -249,13 +246,11 @@ class ClientTest extends UnitaryTestCase
|
||||
{
|
||||
$ids = array_map(fn() => self::$faker->randomNumber(), range(0, 4));
|
||||
|
||||
$queryResult = new QueryResult();
|
||||
|
||||
$this->clientRepository
|
||||
->expects(self::once())
|
||||
->method('deleteByIdBatch')
|
||||
->with($ids)
|
||||
->willReturn($queryResult->setAffectedNumRows(1));
|
||||
->willReturn(new QueryResult(null, 1));
|
||||
|
||||
$this->client->deleteByIdBatch($ids);
|
||||
}
|
||||
@@ -268,13 +263,11 @@ class ClientTest extends UnitaryTestCase
|
||||
{
|
||||
$ids = array_map(fn() => self::$faker->randomNumber(), range(0, 4));
|
||||
|
||||
$queryResult = new QueryResult();
|
||||
|
||||
$this->clientRepository
|
||||
->expects(self::once())
|
||||
->method('deleteByIdBatch')
|
||||
->with($ids)
|
||||
->willReturn($queryResult->setAffectedNumRows(0));
|
||||
->willReturn(new QueryResult(null, 0));
|
||||
|
||||
$this->expectException(ServiceException::class);
|
||||
$this->expectExceptionMessage('Error while deleting the clients');
|
||||
|
||||
@@ -58,8 +58,7 @@ class ConfigTest extends UnitaryTestCase
|
||||
{
|
||||
$config = ConfigGenerator::factory()->buildConfig();
|
||||
|
||||
$queryResult = new QueryResult();
|
||||
$queryResult->setLastId(self::$faker->randomNumber());
|
||||
$queryResult = new QueryResult(null, 0, self::$faker->randomNumber());
|
||||
|
||||
$this->configRepository
|
||||
->expects(self::once())
|
||||
@@ -86,8 +85,7 @@ class ConfigTest extends UnitaryTestCase
|
||||
->with($config->getParameter())
|
||||
->willReturn(false);
|
||||
|
||||
$queryResult = new QueryResult();
|
||||
$queryResult->setLastId(self::$faker->randomNumber());
|
||||
$queryResult = new QueryResult(null, 0, self::$faker->randomNumber());
|
||||
|
||||
$this->configRepository
|
||||
->expects(self::once())
|
||||
|
||||
@@ -97,8 +97,6 @@ class CustomFieldDefinitionTest extends UnitaryTestCase
|
||||
{
|
||||
$ids = array_map(fn() => self::$faker->randomNumber(), range(0, 4));
|
||||
|
||||
$queryResult = new QueryResult();
|
||||
|
||||
$this->customFieldDefinitionRepository
|
||||
->expects(self::once())
|
||||
->method('transactionAware')
|
||||
@@ -108,7 +106,7 @@ class CustomFieldDefinitionTest extends UnitaryTestCase
|
||||
->expects(self::once())
|
||||
->method('deleteByIdBatch')
|
||||
->with($ids)
|
||||
->willReturn($queryResult->setAffectedNumRows(5));
|
||||
->willReturn(new QueryResult(null, 5));
|
||||
|
||||
$this->customFieldDefinition->deleteByIdBatch($ids);
|
||||
}
|
||||
@@ -142,7 +140,7 @@ class CustomFieldDefinitionTest extends UnitaryTestCase
|
||||
->expects(self::once())
|
||||
->method('deleteByIdBatch')
|
||||
->with($ids)
|
||||
->willReturn($queryResult->setAffectedNumRows(0));
|
||||
->willReturn(new QueryResult(null, 0));
|
||||
|
||||
$this->customFieldDefinition->deleteByIdBatch($ids);
|
||||
}
|
||||
@@ -179,7 +177,7 @@ class CustomFieldDefinitionTest extends UnitaryTestCase
|
||||
->expects(self::once())
|
||||
->method('delete')
|
||||
->with($id)
|
||||
->willReturn($queryResult->setAffectedNumRows(1));
|
||||
->willReturn(new QueryResult(null, 1));
|
||||
|
||||
$this->customFieldDefinition->delete($id);
|
||||
}
|
||||
@@ -228,13 +226,11 @@ class CustomFieldDefinitionTest extends UnitaryTestCase
|
||||
{
|
||||
$customFieldDefinition = CustomFieldDefinitionGenerator::factory()->buildCustomFieldDefinition();
|
||||
|
||||
$queryResult = new QueryResult();
|
||||
|
||||
$this->customFieldDefinitionRepository
|
||||
->expects(self::once())
|
||||
->method('create')
|
||||
->with($customFieldDefinition)
|
||||
->willReturn($queryResult->setLastId(100));
|
||||
->willReturn(new QueryResult(null, 0, 100));
|
||||
|
||||
$this->assertEquals(100, $this->customFieldDefinition->create($customFieldDefinition));
|
||||
}
|
||||
@@ -263,13 +259,11 @@ class CustomFieldDefinitionTest extends UnitaryTestCase
|
||||
->method('delete')
|
||||
->with($customFieldDefinition->getId());
|
||||
|
||||
$queryResult = new QueryResult();
|
||||
|
||||
$this->customFieldDefinitionRepository
|
||||
->expects(self::once())
|
||||
->method('create')
|
||||
->with($customFieldDefinition)
|
||||
->willReturn($queryResult->setLastId(100));
|
||||
->willReturn(new QueryResult(null, 0, 100));
|
||||
|
||||
$out = $this->customFieldDefinition->changeModule($customFieldDefinition);
|
||||
|
||||
|
||||
@@ -25,7 +25,6 @@
|
||||
namespace SPT\Domain\Export\Services;
|
||||
|
||||
use PDO;
|
||||
use PDOStatement;
|
||||
use PHPUnit\Framework\Attributes\Group;
|
||||
use PHPUnit\Framework\Constraint\Callback;
|
||||
use PHPUnit\Framework\MockObject\Exception;
|
||||
@@ -38,7 +37,6 @@ use SP\Domain\Export\Ports\BackupFileHelperService;
|
||||
use SP\Domain\Export\Services\BackupFile;
|
||||
use SP\Infrastructure\Database\DatabaseInterface;
|
||||
use SP\Infrastructure\Database\DatabaseUtil;
|
||||
use SP\Infrastructure\Database\DbStorageInterface;
|
||||
use SP\Infrastructure\Database\QueryData;
|
||||
use SP\Infrastructure\Database\QueryResult;
|
||||
use SP\Infrastructure\File\ArchiveHandlerInterface;
|
||||
@@ -65,14 +63,6 @@ class FileBackupServiceTest extends UnitaryTestCase
|
||||
{
|
||||
$this->setupBackupFiles();
|
||||
|
||||
$dbStorage = $this->createStub(DbStorageInterface::class);
|
||||
$dbStorage->method('getDatabaseName')
|
||||
->willReturn('TestDatabase');
|
||||
|
||||
$this->database
|
||||
->method('getDbHandler')
|
||||
->willReturn($dbStorage);
|
||||
|
||||
$tablesCount = count(DatabaseUtil::TABLES);
|
||||
$tablesType = ['table', 'view'];
|
||||
|
||||
@@ -83,7 +73,7 @@ class FileBackupServiceTest extends UnitaryTestCase
|
||||
|
||||
$this->database
|
||||
->expects(self::exactly($tablesCount))
|
||||
->method('doQuery')
|
||||
->method('runQuery')
|
||||
->with(
|
||||
new Callback(static function (QueryData $queryData) {
|
||||
return preg_match('/^SHOW CREATE TABLE \w+$/', $queryData->getQuery()) === 1;
|
||||
@@ -91,23 +81,23 @@ class FileBackupServiceTest extends UnitaryTestCase
|
||||
)
|
||||
->willReturn(...$queryResults);
|
||||
|
||||
$statement = $this->createMock(PDOStatement::class);
|
||||
$statement->expects(self::exactly($tablesCount - 1))
|
||||
->method('fetch')
|
||||
->with(PDO::FETCH_NUM)
|
||||
->willReturn(['value1', 2, null], false);
|
||||
$rows = static function () {
|
||||
yield ['a', 1, false];
|
||||
yield ['b', 2, true];
|
||||
};
|
||||
|
||||
$this->database
|
||||
->expects(self::exactly($tablesCount - 2))
|
||||
->method('doQueryRaw')
|
||||
->method('doFetchWithOptions')
|
||||
->with(
|
||||
new Callback(static function (QueryData $queryData) {
|
||||
return preg_match('/^SELECT \* FROM `\w+`$/', $queryData->getQuery()) === 1;
|
||||
}),
|
||||
[PDO::ATTR_CURSOR => PDO::CURSOR_SCROLL],
|
||||
PDO::FETCH_NUM,
|
||||
false
|
||||
)
|
||||
->willReturn($statement);
|
||||
->willReturnCallback($rows);
|
||||
|
||||
$this->fileBackupService->doBackup(TMP_PATH);
|
||||
}
|
||||
|
||||
@@ -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.
|
||||
*
|
||||
@@ -37,7 +37,7 @@ use SP\Domain\Install\Adapters\InstallData;
|
||||
use SP\Domain\Install\Services\MysqlService;
|
||||
use SP\Infrastructure\Database\DatabaseFileInterface;
|
||||
use SP\Infrastructure\Database\DatabaseUtil;
|
||||
use SP\Infrastructure\Database\DbStorageInterface;
|
||||
use SP\Infrastructure\Database\DbStorageHandler;
|
||||
use SP\Infrastructure\File\FileException;
|
||||
use SPT\UnitaryTestCase;
|
||||
|
||||
@@ -51,8 +51,8 @@ use function SP\__u;
|
||||
#[Group('unitary')]
|
||||
class MySQLTest extends UnitaryTestCase
|
||||
{
|
||||
private DbStorageInterface|MockObject $dbStorage;
|
||||
private MysqlService $mysqlService;
|
||||
private DbStorageHandler|MockObject $dbStorage;
|
||||
private MysqlService $mysqlService;
|
||||
private PDO|MockObject $pdo;
|
||||
private InstallData $installData;
|
||||
private ConfigDataInterface $configData;
|
||||
@@ -818,7 +818,7 @@ class MySQLTest extends UnitaryTestCase
|
||||
|
||||
$this->pdo = $this->createMock(PDO::class);
|
||||
|
||||
$this->dbStorage = $this->createMock(DbStorageInterface::class);
|
||||
$this->dbStorage = $this->createMock(DbStorageHandler::class);
|
||||
$this->dbStorage->method('getConnection')->willReturn($this->pdo);
|
||||
$this->dbStorage->method('getConnectionSimple')->willReturn($this->pdo);
|
||||
|
||||
|
||||
@@ -94,13 +94,12 @@ class ItemPresetTest extends UnitaryTestCase
|
||||
{
|
||||
$itemPreset = ItemPresetDataGenerator::factory()->buildItemPresetData((object)['foo' => 'bar']);
|
||||
|
||||
$queryResult = new QueryResult([]);
|
||||
|
||||
$this->itemPresetRepository
|
||||
->expects(self::once())
|
||||
->method('create')
|
||||
->with($itemPreset)
|
||||
->willReturn($queryResult->setLastId(100));
|
||||
->willReturn(new QueryResult(null, 0, 100));
|
||||
|
||||
$this->assertEquals(100, $this->itemPreset->create($itemPreset));
|
||||
}
|
||||
@@ -141,7 +140,7 @@ class ItemPresetTest extends UnitaryTestCase
|
||||
->expects(self::once())
|
||||
->method('deleteByIdBatch')
|
||||
->with($ids)
|
||||
->willReturn($queryResult->setAffectedNumRows(5));
|
||||
->willReturn(new QueryResult(null, 5));
|
||||
|
||||
$this->assertEquals(5, $this->itemPreset->deleteByIdBatch($ids));
|
||||
}
|
||||
@@ -155,13 +154,11 @@ class ItemPresetTest extends UnitaryTestCase
|
||||
{
|
||||
$ids = array_map(static fn() => self::$faker->randomNumber(3), range(0, 4));
|
||||
|
||||
$queryResult = new QueryResult([]);
|
||||
|
||||
$this->itemPresetRepository
|
||||
->expects(self::once())
|
||||
->method('deleteByIdBatch')
|
||||
->with($ids)
|
||||
->willReturn($queryResult->setAffectedNumRows(4));
|
||||
->willReturn(new QueryResult(null, 4));
|
||||
|
||||
$this->expectException(ServiceException::class);
|
||||
$this->expectExceptionMessage('Error while deleting the values');
|
||||
|
||||
@@ -203,13 +203,11 @@ class NotificationTest extends UnitaryTestCase
|
||||
{
|
||||
$notification = NotificationDataGenerator::factory()->buildNotification();
|
||||
|
||||
$queryResult = new QueryResult([]);
|
||||
|
||||
$this->notificationRepository
|
||||
->expects($this->once())
|
||||
->method('create')
|
||||
->with($notification)
|
||||
->willReturn($queryResult->setLastId(100));
|
||||
->willReturn(new QueryResult(null, 0, 100));
|
||||
|
||||
$out = $this->notification->create($notification);
|
||||
|
||||
@@ -267,13 +265,11 @@ class NotificationTest extends UnitaryTestCase
|
||||
*/
|
||||
public function testDelete()
|
||||
{
|
||||
$queryResult = new QueryResult([]);
|
||||
|
||||
$this->notificationRepository
|
||||
->expects($this->once())
|
||||
->method('delete')
|
||||
->with(100)
|
||||
->willReturn($queryResult->setAffectedNumRows(1));
|
||||
->willReturn(new QueryResult(null, 1));
|
||||
|
||||
$this->notification->delete(100);
|
||||
}
|
||||
@@ -285,13 +281,11 @@ class NotificationTest extends UnitaryTestCase
|
||||
*/
|
||||
public function testDeleteWithException()
|
||||
{
|
||||
$queryResult = new QueryResult([]);
|
||||
|
||||
$this->notificationRepository
|
||||
->expects($this->once())
|
||||
->method('delete')
|
||||
->with(100)
|
||||
->willReturn($queryResult->setAffectedNumRows(0));
|
||||
->willReturn(new QueryResult(null, 0));
|
||||
|
||||
$this->expectException(NoSuchItemException::class);
|
||||
$this->expectExceptionMessage('Notification not found');
|
||||
@@ -403,13 +397,11 @@ class NotificationTest extends UnitaryTestCase
|
||||
*/
|
||||
public function testDeleteAdmin()
|
||||
{
|
||||
$queryResult = new QueryResult([]);
|
||||
|
||||
$this->notificationRepository
|
||||
->expects($this->once())
|
||||
->method('deleteAdmin')
|
||||
->with(100)
|
||||
->willReturn($queryResult->setAffectedNumRows(1));
|
||||
->willReturn(new QueryResult(null, 1));
|
||||
|
||||
$this->notification->deleteAdmin(100);
|
||||
}
|
||||
@@ -421,13 +413,11 @@ class NotificationTest extends UnitaryTestCase
|
||||
*/
|
||||
public function testDeleteAdminWithException()
|
||||
{
|
||||
$queryResult = new QueryResult([]);
|
||||
|
||||
$this->notificationRepository
|
||||
->expects($this->once())
|
||||
->method('deleteAdmin')
|
||||
->with(100)
|
||||
->willReturn($queryResult->setAffectedNumRows(0));
|
||||
->willReturn(new QueryResult(null, 0));
|
||||
|
||||
$this->expectException(NoSuchItemException::class);
|
||||
$this->expectExceptionMessage('Notification not found');
|
||||
@@ -442,13 +432,11 @@ class NotificationTest extends UnitaryTestCase
|
||||
*/
|
||||
public function testDeleteByIdBatch()
|
||||
{
|
||||
$queryResult = new QueryResult([]);
|
||||
|
||||
$this->notificationRepository
|
||||
->expects($this->once())
|
||||
->method('deleteByIdBatch')
|
||||
->with([100, 200, 300])
|
||||
->willReturn($queryResult->setAffectedNumRows(3));
|
||||
->willReturn(new QueryResult(null, 3));
|
||||
|
||||
$this->notification->deleteByIdBatch([100, 200, 300]);
|
||||
}
|
||||
@@ -460,13 +448,11 @@ class NotificationTest extends UnitaryTestCase
|
||||
*/
|
||||
public function testDeleteByIdBatchWithException()
|
||||
{
|
||||
$queryResult = new QueryResult([]);
|
||||
|
||||
$this->notificationRepository
|
||||
->expects($this->once())
|
||||
->method('deleteByIdBatch')
|
||||
->with([100, 200, 300])
|
||||
->willReturn($queryResult->setAffectedNumRows(1));
|
||||
->willReturn(new QueryResult(null, 1));
|
||||
|
||||
$this->expectException(ServiceException::class);
|
||||
$this->expectExceptionMessage('Error while deleting the notifications');
|
||||
@@ -481,13 +467,11 @@ class NotificationTest extends UnitaryTestCase
|
||||
*/
|
||||
public function testDeleteAdminBatch()
|
||||
{
|
||||
$queryResult = new QueryResult([]);
|
||||
|
||||
$this->notificationRepository
|
||||
->expects($this->once())
|
||||
->method('deleteAdminBatch')
|
||||
->with([100, 200, 300])
|
||||
->willReturn($queryResult->setAffectedNumRows(3));
|
||||
->willReturn(new QueryResult(null, 3));
|
||||
|
||||
$this->notification->deleteAdminBatch([100, 200, 300]);
|
||||
}
|
||||
@@ -499,13 +483,11 @@ class NotificationTest extends UnitaryTestCase
|
||||
*/
|
||||
public function testDeleteAdminBatchWithException()
|
||||
{
|
||||
$queryResult = new QueryResult([]);
|
||||
|
||||
$this->notificationRepository
|
||||
->expects($this->once())
|
||||
->method('deleteAdminBatch')
|
||||
->with([100, 200, 300])
|
||||
->willReturn($queryResult->setAffectedNumRows(1));
|
||||
->willReturn(new QueryResult(null, 1));
|
||||
|
||||
$this->expectException(ServiceException::class);
|
||||
$this->expectExceptionMessage('Error while deleting the notifications');
|
||||
|
||||
@@ -60,12 +60,11 @@ class PluginDataTest extends UnitaryTestCase
|
||||
*/
|
||||
public function testDelete()
|
||||
{
|
||||
$queryResult = new QueryResult();
|
||||
$this->pluginDataRepository
|
||||
->expects($this->once())
|
||||
->method('delete')
|
||||
->with('test_plugin')
|
||||
->willReturn($queryResult->setAffectedNumRows(1));
|
||||
->willReturn(new QueryResult(null, 1));
|
||||
|
||||
$this->pluginData->delete('test_plugin');
|
||||
}
|
||||
@@ -77,12 +76,11 @@ class PluginDataTest extends UnitaryTestCase
|
||||
*/
|
||||
public function testDeleteWithException()
|
||||
{
|
||||
$queryResult = new QueryResult();
|
||||
$this->pluginDataRepository
|
||||
->expects($this->once())
|
||||
->method('delete')
|
||||
->with('test_plugin')
|
||||
->willReturn($queryResult->setAffectedNumRows(0));
|
||||
->willReturn(new QueryResult(null, 0));
|
||||
|
||||
$this->expectException(NoSuchItemException::class);
|
||||
$this->expectExceptionMessage('Plugin\'s data not found');
|
||||
@@ -97,12 +95,11 @@ class PluginDataTest extends UnitaryTestCase
|
||||
*/
|
||||
public function testDeleteByItemId()
|
||||
{
|
||||
$queryResult = new QueryResult();
|
||||
$this->pluginDataRepository
|
||||
->expects($this->once())
|
||||
->method('deleteByItemId')
|
||||
->with('test_plugin', 100)
|
||||
->willReturn($queryResult->setAffectedNumRows(1));
|
||||
->willReturn(new QueryResult(null, 1));
|
||||
|
||||
$this->pluginData->deleteByItemId('test_plugin', 100);
|
||||
}
|
||||
@@ -114,12 +111,11 @@ class PluginDataTest extends UnitaryTestCase
|
||||
*/
|
||||
public function testDeleteByItemIdWithException()
|
||||
{
|
||||
$queryResult = new QueryResult();
|
||||
$this->pluginDataRepository
|
||||
->expects($this->once())
|
||||
->method('deleteByItemId')
|
||||
->with('test_plugin', 100)
|
||||
->willReturn($queryResult->setAffectedNumRows(0));
|
||||
->willReturn(new QueryResult(null, 0));
|
||||
|
||||
$this->expectException(NoSuchItemException::class);
|
||||
$this->expectExceptionMessage('Plugin\'s data not found');
|
||||
|
||||
@@ -140,12 +140,11 @@ class PluginManagerTest extends UnitaryTestCase
|
||||
*/
|
||||
public function testDelete()
|
||||
{
|
||||
$queryResult = new QueryResult();
|
||||
$this->pluginRepository
|
||||
->expects($this->once())
|
||||
->method('delete')
|
||||
->with(100)
|
||||
->willReturn($queryResult->setAffectedNumRows(1));
|
||||
->willReturn(new QueryResult(null, 1));
|
||||
|
||||
$this->pluginManager->delete(100);
|
||||
}
|
||||
@@ -157,12 +156,11 @@ class PluginManagerTest extends UnitaryTestCase
|
||||
*/
|
||||
public function testDeleteWithNotFound()
|
||||
{
|
||||
$queryResult = new QueryResult();
|
||||
$this->pluginRepository
|
||||
->expects($this->once())
|
||||
->method('delete')
|
||||
->with(100)
|
||||
->willReturn($queryResult->setAffectedNumRows(0));
|
||||
->willReturn(new QueryResult(null, 0));
|
||||
|
||||
$this->expectException(NoSuchItemException::class);
|
||||
$this->expectExceptionMessage('Plugin not found');
|
||||
@@ -344,13 +342,11 @@ class PluginManagerTest extends UnitaryTestCase
|
||||
*/
|
||||
public function testDeleteByIdBatch()
|
||||
{
|
||||
$queryResult = new QueryResult([]);
|
||||
|
||||
$this->pluginRepository
|
||||
->expects($this->once())
|
||||
->method('deleteByIdBatch')
|
||||
->with([100, 200, 300])
|
||||
->willReturn($queryResult->setAffectedNumRows(3));
|
||||
->willReturn(new QueryResult(null, 3));
|
||||
|
||||
$this->pluginManager->deleteByIdBatch([100, 200, 300]);
|
||||
}
|
||||
@@ -362,13 +358,11 @@ class PluginManagerTest extends UnitaryTestCase
|
||||
*/
|
||||
public function testDeleteByIdBatchWithException()
|
||||
{
|
||||
$queryResult = new QueryResult([]);
|
||||
|
||||
$this->pluginRepository
|
||||
->expects($this->once())
|
||||
->method('deleteByIdBatch')
|
||||
->with([100, 200, 300])
|
||||
->willReturn($queryResult->setAffectedNumRows(1));
|
||||
->willReturn(new QueryResult(null, 1));
|
||||
|
||||
$this->expectException(ServiceException::class);
|
||||
$this->expectExceptionMessage('Error while deleting the plugins');
|
||||
@@ -421,13 +415,11 @@ class PluginManagerTest extends UnitaryTestCase
|
||||
{
|
||||
$plugin = PluginGenerator::factory()->buildPlugin();
|
||||
|
||||
$queryResult = new QueryResult();
|
||||
|
||||
$this->pluginRepository
|
||||
->expects($this->once())
|
||||
->method('create')
|
||||
->with($plugin)
|
||||
->willReturn($queryResult->setLastId(100));
|
||||
->willReturn(new QueryResult(null, 0, 100));
|
||||
|
||||
$out = $this->pluginManager->create($plugin);
|
||||
|
||||
|
||||
@@ -105,7 +105,6 @@ class PluginOperationTest extends UnitaryTestCase
|
||||
{
|
||||
$pluginDataStorage = new PluginDataStub(100, 'test_data');
|
||||
|
||||
$queryResult = new QueryResult([]);
|
||||
$this->pluginDataService
|
||||
->expects($this->once())
|
||||
->method('create')
|
||||
@@ -117,7 +116,7 @@ class PluginOperationTest extends UnitaryTestCase
|
||||
&& $current->getKey() === null;
|
||||
})
|
||||
)
|
||||
->willReturn($queryResult->setLastId(10));
|
||||
->willReturn(new QueryResult(null, 0, 10));
|
||||
|
||||
$out = $this->pluginOperation->create(100, $pluginDataStorage);
|
||||
|
||||
|
||||
@@ -83,8 +83,6 @@ class EventlogTest extends UnitaryTestCase
|
||||
]
|
||||
);
|
||||
|
||||
$queryResult = new QueryResult();
|
||||
|
||||
$this->request
|
||||
->expects($this->once())
|
||||
->method('getClientAddress')
|
||||
@@ -102,7 +100,7 @@ class EventlogTest extends UnitaryTestCase
|
||||
&& $eventlog->getIpAddress() == '192.168.0.1';
|
||||
})
|
||||
)
|
||||
->willReturn($queryResult->setLastId(100));
|
||||
->willReturn(new QueryResult(null, 0, 100));
|
||||
|
||||
$this->assertEquals(100, $this->eventlog->create($eventlog));
|
||||
}
|
||||
|
||||
@@ -165,13 +165,11 @@ class TrackTest extends UnitaryTestCase
|
||||
'time' => $trackRequest->getTime()
|
||||
]);
|
||||
|
||||
$queryResult = new QueryResult();
|
||||
|
||||
$this->trackRepository
|
||||
->expects($this->once())
|
||||
->method('add')
|
||||
->with($track)
|
||||
->willReturn($queryResult->setLastId(100));
|
||||
->willReturn(new QueryResult(null, 0, 100));
|
||||
|
||||
$this->assertEquals(100, $this->track->add($trackRequest));
|
||||
}
|
||||
|
||||
@@ -71,7 +71,7 @@ class AccountFileTest extends UnitaryTestCase
|
||||
);
|
||||
|
||||
$this->database->expects(self::once())
|
||||
->method('doQuery')
|
||||
->method('runQuery')
|
||||
->with($callback)
|
||||
->willReturn(new QueryResult());
|
||||
|
||||
@@ -85,7 +85,7 @@ class AccountFileTest extends UnitaryTestCase
|
||||
public function testDeleteByIdBatchWithNoIds(): void
|
||||
{
|
||||
$this->database->expects(self::never())
|
||||
->method('doQuery');
|
||||
->method('runQuery');
|
||||
|
||||
$this->assertEquals(0, $this->accountFile->deleteByIdBatch([]));
|
||||
}
|
||||
@@ -98,8 +98,7 @@ class AccountFileTest extends UnitaryTestCase
|
||||
{
|
||||
$fileData = File::buildFromSimpleModel(FileDataGenerator::factory()->buildFileData());
|
||||
|
||||
$expected = new QueryResult();
|
||||
$expected->setLastId(1);
|
||||
$expected = new QueryResult(null, 0, 1);
|
||||
|
||||
$callback = new Callback(
|
||||
static function (QueryData $arg) use ($fileData) {
|
||||
@@ -118,7 +117,7 @@ class AccountFileTest extends UnitaryTestCase
|
||||
);
|
||||
|
||||
$this->database->expects(self::once())
|
||||
->method('doQuery')
|
||||
->method('runQuery')
|
||||
->with($callback)
|
||||
->willReturn($expected);
|
||||
|
||||
@@ -144,7 +143,7 @@ class AccountFileTest extends UnitaryTestCase
|
||||
);
|
||||
|
||||
$this->database->expects(self::once())
|
||||
->method('doSelect')
|
||||
->method('runQuery')
|
||||
->with($callback)
|
||||
->willReturn(new QueryResult());
|
||||
|
||||
@@ -157,25 +156,22 @@ class AccountFileTest extends UnitaryTestCase
|
||||
*/
|
||||
public function testDelete(): void
|
||||
{
|
||||
$id = 1;
|
||||
$queryResult = new QueryResult();
|
||||
|
||||
$callback = new Callback(
|
||||
static function (QueryData $arg) use ($id) {
|
||||
static function (QueryData $arg) {
|
||||
$query = $arg->getQuery();
|
||||
|
||||
return $query->getBindValues()['id'] === $id
|
||||
return $query->getBindValues()['id'] === 100
|
||||
&& !empty($query->getStatement());
|
||||
}
|
||||
);
|
||||
|
||||
$this->database
|
||||
->expects(self::once())
|
||||
->method('doQuery')
|
||||
->method('runQuery')
|
||||
->with($callback)
|
||||
->willReturn($queryResult->setAffectedNumRows(1));
|
||||
->willReturn(new QueryResult(null, 1));
|
||||
|
||||
$this->assertTrue($this->accountFile->delete($id));
|
||||
$this->assertTrue($this->accountFile->delete(100));
|
||||
}
|
||||
|
||||
public function testGetById(): void
|
||||
@@ -193,7 +189,7 @@ class AccountFileTest extends UnitaryTestCase
|
||||
);
|
||||
|
||||
$this->database->expects(self::once())
|
||||
->method('doSelect')
|
||||
->method('runQuery')
|
||||
->with($callback)
|
||||
->willReturn(new QueryResult());
|
||||
|
||||
@@ -220,7 +216,7 @@ class AccountFileTest extends UnitaryTestCase
|
||||
|
||||
$this->database
|
||||
->expects(self::once())
|
||||
->method('doSelect')
|
||||
->method('runQuery')
|
||||
->with($callback)
|
||||
->willReturn(new QueryResult());
|
||||
|
||||
|
||||
@@ -64,7 +64,7 @@ class AccountHistoryTest extends UnitaryTestCase
|
||||
);
|
||||
|
||||
$this->database->expects(self::once())
|
||||
->method('doSelect')
|
||||
->method('runQuery')
|
||||
->with($callback)
|
||||
->willReturn(new QueryResult());
|
||||
|
||||
@@ -84,7 +84,7 @@ class AccountHistoryTest extends UnitaryTestCase
|
||||
);
|
||||
|
||||
$this->database->expects(self::once())
|
||||
->method('doSelect')
|
||||
->method('runQuery')
|
||||
->with($callback)
|
||||
->willReturn(new QueryResult());
|
||||
|
||||
@@ -112,7 +112,7 @@ class AccountHistoryTest extends UnitaryTestCase
|
||||
);
|
||||
|
||||
$this->database->expects(self::once())
|
||||
->method('doQuery')
|
||||
->method('runQuery')
|
||||
->with($callback)
|
||||
->willReturn(new QueryResult());
|
||||
|
||||
@@ -126,7 +126,7 @@ class AccountHistoryTest extends UnitaryTestCase
|
||||
public function testDeleteByIdBatchWithoutIds(): void
|
||||
{
|
||||
$this->database->expects(self::never())
|
||||
->method('doQuery');
|
||||
->method('runQuery');
|
||||
|
||||
$this->accountHistory->deleteByIdBatch([]);
|
||||
}
|
||||
@@ -140,8 +140,6 @@ class AccountHistoryTest extends UnitaryTestCase
|
||||
$id = self::$faker->randomNumber();
|
||||
$encryptedPassword = new EncryptedPassword(self::$faker->password, self::$faker->password, self::$faker->sha1);
|
||||
|
||||
$queryResult = new QueryResult();
|
||||
|
||||
$callback = new Callback(
|
||||
static function (QueryData $arg) use ($id, $encryptedPassword) {
|
||||
$params = $arg->getQuery()->getBindValues();
|
||||
@@ -155,9 +153,9 @@ class AccountHistoryTest extends UnitaryTestCase
|
||||
);
|
||||
|
||||
$this->database->expects(self::once())
|
||||
->method('doQuery')
|
||||
->method('runQuery')
|
||||
->with($callback)
|
||||
->willReturn($queryResult->setAffectedNumRows(1));
|
||||
->willReturn(new QueryResult(null, 1));
|
||||
|
||||
$this->assertTrue($this->accountHistory->updatePassword($id, $encryptedPassword));
|
||||
}
|
||||
@@ -180,7 +178,7 @@ class AccountHistoryTest extends UnitaryTestCase
|
||||
|
||||
$this->database
|
||||
->expects(self::once())
|
||||
->method('doSelect')
|
||||
->method('runQuery')
|
||||
->with($callback)
|
||||
->willReturn(new QueryResult());
|
||||
|
||||
@@ -199,7 +197,7 @@ class AccountHistoryTest extends UnitaryTestCase
|
||||
|
||||
$this->database
|
||||
->expects(self::once())
|
||||
->method('doSelect')
|
||||
->method('runQuery')
|
||||
->with($callback)
|
||||
->willReturn(new QueryResult());
|
||||
|
||||
@@ -217,7 +215,7 @@ class AccountHistoryTest extends UnitaryTestCase
|
||||
|
||||
$this->database
|
||||
->expects(self::once())
|
||||
->method('doSelect')
|
||||
->method('runQuery')
|
||||
->with($callback)
|
||||
->willReturn(new QueryResult());
|
||||
|
||||
@@ -232,8 +230,7 @@ class AccountHistoryTest extends UnitaryTestCase
|
||||
{
|
||||
$dto = $this->buildAccountHistoryCreateDto();
|
||||
|
||||
$expected = new QueryResult();
|
||||
$expected->setLastId(1);
|
||||
$expected = new QueryResult(null, 0, self::$faker->randomNumber());
|
||||
|
||||
$callback = new Callback(
|
||||
static function (QueryData $arg) use ($dto) {
|
||||
@@ -271,7 +268,7 @@ class AccountHistoryTest extends UnitaryTestCase
|
||||
);
|
||||
|
||||
$this->database->expects(self::once())
|
||||
->method('doQuery')
|
||||
->method('runQuery')
|
||||
->with($callback)
|
||||
->willReturn($expected);
|
||||
|
||||
@@ -294,22 +291,19 @@ class AccountHistoryTest extends UnitaryTestCase
|
||||
*/
|
||||
public function testDelete(): void
|
||||
{
|
||||
$id = 1;
|
||||
$queryResult = new QueryResult();
|
||||
|
||||
$callback = new Callback(
|
||||
static function (QueryData $arg) use ($id) {
|
||||
return $arg->getQuery()->getBindValues()['id'] === $id
|
||||
return $arg->getQuery()->getBindValues()['id'] === 100
|
||||
&& !empty($arg->getQuery()->getStatement());
|
||||
}
|
||||
);
|
||||
|
||||
$this->database->expects(self::once())
|
||||
->method('doQuery')
|
||||
->method('runQuery')
|
||||
->with($callback)
|
||||
->willReturn($queryResult->setAffectedNumRows(1));
|
||||
->willReturn(new QueryResult(null, 1));
|
||||
|
||||
$this->assertTrue($this->accountHistory->delete($id));
|
||||
$this->assertTrue($this->accountHistory->delete(100));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -318,23 +312,19 @@ class AccountHistoryTest extends UnitaryTestCase
|
||||
*/
|
||||
public function testDeleteNoResults(): void
|
||||
{
|
||||
$id = 1;
|
||||
$expected = new QueryResult();
|
||||
$expected->setAffectedNumRows(0);
|
||||
|
||||
$callback = new Callback(
|
||||
static function (QueryData $arg) use ($id) {
|
||||
return $arg->getQuery()->getBindValues()['id'] === $id
|
||||
return $arg->getQuery()->getBindValues()['id'] === 100
|
||||
&& !empty($arg->getQuery()->getStatement());
|
||||
}
|
||||
);
|
||||
|
||||
$this->database->expects(self::once())
|
||||
->method('doQuery')
|
||||
->method('runQuery')
|
||||
->with($callback)
|
||||
->willReturn($expected);
|
||||
->willReturn(new QueryResult(null, 0));
|
||||
|
||||
$this->assertFalse($this->accountHistory->delete($id));
|
||||
$this->assertFalse($this->accountHistory->delete(100));
|
||||
}
|
||||
|
||||
public function testGetAll(): void
|
||||
@@ -348,7 +338,7 @@ class AccountHistoryTest extends UnitaryTestCase
|
||||
|
||||
$this->database
|
||||
->expects(self::once())
|
||||
->method('doSelect')
|
||||
->method('runQuery')
|
||||
->with($callback)
|
||||
->willReturn(new QueryResult());
|
||||
|
||||
@@ -376,7 +366,7 @@ class AccountHistoryTest extends UnitaryTestCase
|
||||
);
|
||||
|
||||
$this->database->expects(self::once())
|
||||
->method('doQuery')
|
||||
->method('runQuery')
|
||||
->with($callback)
|
||||
->willReturn(new QueryResult());
|
||||
|
||||
@@ -390,7 +380,7 @@ class AccountHistoryTest extends UnitaryTestCase
|
||||
public function testDeleteByAccountIdBatchWithoutIds(): void
|
||||
{
|
||||
$this->database->expects(self::never())
|
||||
->method('doQuery');
|
||||
->method('runQuery');
|
||||
|
||||
$this->accountHistory->deleteByAccountIdBatch([]);
|
||||
}
|
||||
|
||||
@@ -189,7 +189,7 @@ class AccountSearchTest extends UnitaryTestCase
|
||||
->method('buildFilter')
|
||||
->with(true, self::anything());
|
||||
$this->database->expects(self::once())
|
||||
->method('doSelect')
|
||||
->method('runQuery')
|
||||
->with(
|
||||
new Callback(static function (QueryData $data) {
|
||||
return !empty($data->getQuery()->getStatement()) &&
|
||||
@@ -210,7 +210,7 @@ class AccountSearchTest extends UnitaryTestCase
|
||||
->method('buildFilter');
|
||||
|
||||
$this->database->expects(self::once())
|
||||
->method('doSelect')
|
||||
->method('runQuery')
|
||||
->with(
|
||||
new Callback(static function (QueryData $data) {
|
||||
return !empty($data->getQuery()->getStatement()) &&
|
||||
|
||||
@@ -63,7 +63,7 @@ class AccountTest extends UnitaryTestCase
|
||||
}
|
||||
);
|
||||
|
||||
$this->database->expects(self::once())->method('doSelect')->with($callback, false);
|
||||
$this->database->expects(self::once())->method('runQuery')->with($callback, false);
|
||||
|
||||
$this->account->getTotalNumAccounts();
|
||||
}
|
||||
@@ -86,7 +86,7 @@ class AccountTest extends UnitaryTestCase
|
||||
->expects(self::once())
|
||||
->method('buildFilter');
|
||||
|
||||
$this->database->expects(self::once())->method('doSelect')->with($callback, false);
|
||||
$this->database->expects(self::once())->method('runQuery')->with($callback, false);
|
||||
|
||||
$this->account->getPasswordForId(1);
|
||||
}
|
||||
@@ -109,7 +109,7 @@ class AccountTest extends UnitaryTestCase
|
||||
->expects(self::once())
|
||||
->method('buildFilterHistory');
|
||||
|
||||
$this->database->expects(self::once())->method('doSelect')->with($callback, false);
|
||||
$this->database->expects(self::once())->method('runQuery')->with($callback, false);
|
||||
|
||||
$this->account->getPasswordHistoryForId(1);
|
||||
}
|
||||
@@ -132,7 +132,7 @@ class AccountTest extends UnitaryTestCase
|
||||
}
|
||||
);
|
||||
|
||||
$this->database->expects(self::once())->method('doQuery')->with($callback);
|
||||
$this->database->expects(self::once())->method('runQuery')->with($callback);
|
||||
|
||||
$this->account->incrementDecryptCounter($id);
|
||||
}
|
||||
@@ -155,7 +155,7 @@ class AccountTest extends UnitaryTestCase
|
||||
}
|
||||
);
|
||||
|
||||
$this->database->expects(self::once())->method('doQuery')->with($callback);
|
||||
$this->database->expects(self::once())->method('runQuery')->with($callback);
|
||||
|
||||
$this->account->incrementDecryptCounter($id);
|
||||
}
|
||||
@@ -195,7 +195,7 @@ class AccountTest extends UnitaryTestCase
|
||||
}
|
||||
);
|
||||
|
||||
$this->database->expects(self::once())->method('doQuery')->with($callback);
|
||||
$this->database->expects(self::once())->method('runQuery')->with($callback);
|
||||
|
||||
$this->account->create($account);
|
||||
}
|
||||
@@ -222,7 +222,7 @@ class AccountTest extends UnitaryTestCase
|
||||
}
|
||||
);
|
||||
|
||||
$this->database->expects(self::once())->method('doQuery')->with($callback);
|
||||
$this->database->expects(self::once())->method('runQuery')->with($callback);
|
||||
|
||||
$this->account->editPassword($account->getId(), $account);
|
||||
}
|
||||
@@ -248,7 +248,7 @@ class AccountTest extends UnitaryTestCase
|
||||
}
|
||||
);
|
||||
|
||||
$this->database->expects(self::once())->method('doQuery')->with($callback);
|
||||
$this->database->expects(self::once())->method('runQuery')->with($callback);
|
||||
|
||||
$this->account->updatePassword($id, $encryptedPassword);
|
||||
}
|
||||
@@ -288,7 +288,7 @@ class AccountTest extends UnitaryTestCase
|
||||
}
|
||||
);
|
||||
|
||||
$this->database->expects(self::once())->method('doQuery')->with($callback);
|
||||
$this->database->expects(self::once())->method('runQuery')->with($callback);
|
||||
|
||||
$this->account->restoreModified($account->getId(), $account);
|
||||
}
|
||||
@@ -308,7 +308,7 @@ class AccountTest extends UnitaryTestCase
|
||||
}
|
||||
);
|
||||
|
||||
$this->database->expects(self::once())->method('doQuery')->with($callback);
|
||||
$this->database->expects(self::once())->method('runQuery')->with($callback);
|
||||
|
||||
$this->account->delete($id);
|
||||
}
|
||||
@@ -331,7 +331,7 @@ class AccountTest extends UnitaryTestCase
|
||||
}
|
||||
);
|
||||
|
||||
$this->database->expects(self::once())->method('doQuery')->with($callback);
|
||||
$this->database->expects(self::once())->method('runQuery')->with($callback);
|
||||
|
||||
$this->account->delete($id);
|
||||
}
|
||||
@@ -368,7 +368,7 @@ class AccountTest extends UnitaryTestCase
|
||||
}
|
||||
);
|
||||
|
||||
$this->database->expects(self::once())->method('doQuery')->with($callback);
|
||||
$this->database->expects(self::once())->method('runQuery')->with($callback);
|
||||
|
||||
$this->account->update($account->getId(), $account, true, true);
|
||||
}
|
||||
@@ -405,7 +405,7 @@ class AccountTest extends UnitaryTestCase
|
||||
}
|
||||
);
|
||||
|
||||
$this->database->expects(self::once())->method('doQuery')->with($callback);
|
||||
$this->database->expects(self::once())->method('runQuery')->with($callback);
|
||||
|
||||
$this->account->update($account->getId(), $account, true, false);
|
||||
}
|
||||
@@ -442,7 +442,7 @@ class AccountTest extends UnitaryTestCase
|
||||
}
|
||||
);
|
||||
|
||||
$this->database->expects(self::once())->method('doQuery')->with($callback);
|
||||
$this->database->expects(self::once())->method('runQuery')->with($callback);
|
||||
|
||||
$this->account->update($account->getId(), $account, false, true);
|
||||
}
|
||||
@@ -471,7 +471,7 @@ class AccountTest extends UnitaryTestCase
|
||||
);
|
||||
|
||||
$this->database->expects(self::once())
|
||||
->method('doQuery')
|
||||
->method('runQuery')
|
||||
->with($callback);
|
||||
|
||||
$this->account->updateBulk($account->getId(), $account, true, true);
|
||||
@@ -501,7 +501,7 @@ class AccountTest extends UnitaryTestCase
|
||||
);
|
||||
|
||||
$this->database->expects(self::once())
|
||||
->method('doQuery')
|
||||
->method('runQuery')
|
||||
->with($callback);
|
||||
|
||||
$this->account->updateBulk($account->getId(), $account, false, true);
|
||||
@@ -533,7 +533,7 @@ class AccountTest extends UnitaryTestCase
|
||||
);
|
||||
|
||||
$this->database->expects(self::once())
|
||||
->method('doQuery')
|
||||
->method('runQuery')
|
||||
->with($callback);
|
||||
|
||||
$this->account->updateBulk($account->getId(), $account, true, false);
|
||||
@@ -544,7 +544,7 @@ class AccountTest extends UnitaryTestCase
|
||||
*/
|
||||
public function testUpdateBulkNoFieldsToUpdate(): void
|
||||
{
|
||||
$this->database->expects(self::never())->method('doQuery');
|
||||
$this->database->expects(self::never())->method('runQuery');
|
||||
|
||||
$this->account->updateBulk(0, new AccountModel(), false, false);
|
||||
}
|
||||
@@ -564,7 +564,7 @@ class AccountTest extends UnitaryTestCase
|
||||
}
|
||||
);
|
||||
|
||||
$this->database->expects(self::once())->method('doSelect')->with($callback);
|
||||
$this->database->expects(self::once())->method('runQuery')->with($callback);
|
||||
|
||||
$this->account->getById($id);
|
||||
}
|
||||
@@ -584,7 +584,7 @@ class AccountTest extends UnitaryTestCase
|
||||
}
|
||||
);
|
||||
|
||||
$this->database->expects(self::once())->method('doSelect')->with($callback);
|
||||
$this->database->expects(self::once())->method('runQuery')->with($callback);
|
||||
|
||||
$this->account->getByIdEnriched($id);
|
||||
}
|
||||
@@ -598,7 +598,7 @@ class AccountTest extends UnitaryTestCase
|
||||
}
|
||||
);
|
||||
|
||||
$this->database->expects(self::once())->method('doSelect')->with($callback);
|
||||
$this->database->expects(self::once())->method('runQuery')->with($callback);
|
||||
|
||||
$this->account->getAll();
|
||||
}
|
||||
@@ -624,7 +624,7 @@ class AccountTest extends UnitaryTestCase
|
||||
}
|
||||
);
|
||||
|
||||
$this->database->expects(self::once())->method('doQuery')->with($callback);
|
||||
$this->database->expects(self::once())->method('runQuery')->with($callback);
|
||||
|
||||
$this->account->deleteByIdBatch($ids);
|
||||
}
|
||||
@@ -635,7 +635,7 @@ class AccountTest extends UnitaryTestCase
|
||||
*/
|
||||
public function testDeleteByIdBatchWithNoIds(): void
|
||||
{
|
||||
$this->database->expects(self::never())->method('doQuery');
|
||||
$this->database->expects(self::never())->method('runQuery');
|
||||
|
||||
$this->account->deleteByIdBatch([]);
|
||||
}
|
||||
@@ -660,7 +660,7 @@ class AccountTest extends UnitaryTestCase
|
||||
}
|
||||
);
|
||||
|
||||
$this->database->expects(self::once())->method('doSelect')->with($callback, true);
|
||||
$this->database->expects(self::once())->method('runQuery')->with($callback, true);
|
||||
|
||||
$this->account->search($item);
|
||||
}
|
||||
@@ -675,7 +675,7 @@ class AccountTest extends UnitaryTestCase
|
||||
}
|
||||
);
|
||||
|
||||
$this->database->expects(self::once())->method('doSelect')->with($callback, true);
|
||||
$this->database->expects(self::once())->method('runQuery')->with($callback, true);
|
||||
|
||||
$this->account->search(new ItemSearchData());
|
||||
}
|
||||
@@ -699,7 +699,7 @@ class AccountTest extends UnitaryTestCase
|
||||
}
|
||||
);
|
||||
|
||||
$this->database->expects(self::once())->method('doQuery')->with($callback);
|
||||
$this->database->expects(self::once())->method('runQuery')->with($callback);
|
||||
|
||||
$this->account->incrementViewCounter($id);
|
||||
}
|
||||
@@ -723,7 +723,7 @@ class AccountTest extends UnitaryTestCase
|
||||
}
|
||||
);
|
||||
|
||||
$this->database->expects(self::once())->method('doQuery')->with($callback);
|
||||
$this->database->expects(self::once())->method('runQuery')->with($callback);
|
||||
|
||||
$this->account->incrementViewCounter($id);
|
||||
}
|
||||
@@ -743,7 +743,7 @@ class AccountTest extends UnitaryTestCase
|
||||
}
|
||||
);
|
||||
|
||||
$this->database->expects(self::once())->method('doSelect')->with($callback);
|
||||
$this->database->expects(self::once())->method('runQuery')->with($callback);
|
||||
|
||||
$this->account->getDataForLink($id);
|
||||
}
|
||||
@@ -765,7 +765,7 @@ class AccountTest extends UnitaryTestCase
|
||||
|
||||
$this->accountFilterUser->expects(self::once())->method('buildFilter');
|
||||
|
||||
$this->database->expects(self::once())->method('doSelect')->with($callback);
|
||||
$this->database->expects(self::once())->method('runQuery')->with($callback);
|
||||
|
||||
$this->account->getForUser($id);
|
||||
}
|
||||
@@ -784,7 +784,7 @@ class AccountTest extends UnitaryTestCase
|
||||
|
||||
$this->accountFilterUser->expects(self::once())->method('buildFilter');
|
||||
|
||||
$this->database->expects(self::once())->method('doSelect')->with($callback);
|
||||
$this->database->expects(self::once())->method('runQuery')->with($callback);
|
||||
|
||||
$this->account->getForUser();
|
||||
}
|
||||
@@ -806,7 +806,7 @@ class AccountTest extends UnitaryTestCase
|
||||
|
||||
$this->accountFilterUser->expects(self::once())->method('buildFilter');
|
||||
|
||||
$this->database->expects(self::once())->method('doSelect')->with($callback);
|
||||
$this->database->expects(self::once())->method('runQuery')->with($callback);
|
||||
|
||||
$this->account->getLinked($id);
|
||||
}
|
||||
@@ -820,7 +820,7 @@ class AccountTest extends UnitaryTestCase
|
||||
}
|
||||
);
|
||||
|
||||
$this->database->expects(self::once())->method('doSelect')->with($callback);
|
||||
$this->database->expects(self::once())->method('runQuery')->with($callback);
|
||||
|
||||
$this->account->getAccountsPassData();
|
||||
}
|
||||
|
||||
@@ -62,7 +62,7 @@ class AccountToFavoriteTest extends UnitaryTestCase
|
||||
);
|
||||
|
||||
$this->database->expects(self::once())
|
||||
->method('doSelect')
|
||||
->method('runQuery')
|
||||
->with($callback)
|
||||
->willReturn(new QueryResult());
|
||||
|
||||
@@ -74,8 +74,6 @@ class AccountToFavoriteTest extends UnitaryTestCase
|
||||
$accountId = self::$faker->randomNumber();
|
||||
$userId = self::$faker->randomNumber();
|
||||
|
||||
$queryResult = new QueryResult();
|
||||
|
||||
$callback = new Callback(
|
||||
static function (QueryData $arg) use ($accountId, $userId) {
|
||||
$query = $arg->getQuery();
|
||||
@@ -89,9 +87,9 @@ class AccountToFavoriteTest extends UnitaryTestCase
|
||||
|
||||
$this->database
|
||||
->expects(self::once())
|
||||
->method('doQuery')
|
||||
->method('runQuery')
|
||||
->with($callback)
|
||||
->willReturn($queryResult->setAffectedNumRows(1));
|
||||
->willReturn(new QueryResult(null, 1));
|
||||
|
||||
$this->assertTrue($this->accountToFavorite->delete($accountId, $userId));
|
||||
}
|
||||
@@ -105,8 +103,7 @@ class AccountToFavoriteTest extends UnitaryTestCase
|
||||
$accountId = self::$faker->randomNumber();
|
||||
$userId = self::$faker->randomNumber();
|
||||
|
||||
$expected = new QueryResult();
|
||||
$expected->setLastId(1);
|
||||
$expected = new QueryResult(null, 0, self::$faker->randomNumber());
|
||||
|
||||
$callback = new Callback(
|
||||
static function (QueryData $arg) use ($accountId, $userId) {
|
||||
@@ -120,7 +117,7 @@ class AccountToFavoriteTest extends UnitaryTestCase
|
||||
);
|
||||
|
||||
$this->database->expects(self::once())
|
||||
->method('doQuery')
|
||||
->method('runQuery')
|
||||
->with($callback)
|
||||
->willReturn($expected);
|
||||
|
||||
|
||||
@@ -65,7 +65,7 @@ class AccountToTagTest extends UnitaryTestCase
|
||||
|
||||
$this->database
|
||||
->expects(self::once())
|
||||
->method('doSelect')
|
||||
->method('runQuery')
|
||||
->with($callback)
|
||||
->willReturn(new QueryResult());
|
||||
|
||||
@@ -80,8 +80,6 @@ class AccountToTagTest extends UnitaryTestCase
|
||||
{
|
||||
$accountId = self::$faker->randomNumber();
|
||||
|
||||
$queryResult = new QueryResult();
|
||||
|
||||
$callback = new Callback(
|
||||
static function (QueryData $arg) use ($accountId) {
|
||||
$query = $arg->getQuery();
|
||||
@@ -94,9 +92,9 @@ class AccountToTagTest extends UnitaryTestCase
|
||||
|
||||
$this->database
|
||||
->expects(self::once())
|
||||
->method('doQuery')
|
||||
->method('runQuery')
|
||||
->with($callback)
|
||||
->willReturn($queryResult->setAffectedNumRows(1));
|
||||
->willReturn(new QueryResult(null, 1));
|
||||
|
||||
$this->assertTrue($this->accountToTag->deleteByAccountId($accountId));
|
||||
}
|
||||
@@ -130,7 +128,7 @@ class AccountToTagTest extends UnitaryTestCase
|
||||
|
||||
$this->database
|
||||
->expects(self::exactly(count($tags)))
|
||||
->method('doQuery')
|
||||
->method('runQuery')
|
||||
->with(...self::withConsecutive(...$callbacks));
|
||||
|
||||
$this->accountToTag->add($id, $tags);
|
||||
|
||||
@@ -55,8 +55,6 @@ class AccountToUserGroupTest extends UnitaryTestCase
|
||||
{
|
||||
$accountId = self::$faker->randomNumber();
|
||||
|
||||
$queryResult = new QueryResult();
|
||||
|
||||
$callback = new Callback(
|
||||
static function (QueryData $arg) use ($accountId) {
|
||||
$query = $arg->getQuery();
|
||||
@@ -69,9 +67,9 @@ class AccountToUserGroupTest extends UnitaryTestCase
|
||||
|
||||
$this->database
|
||||
->expects(self::once())
|
||||
->method('doQuery')
|
||||
->method('runQuery')
|
||||
->with($callback)
|
||||
->willReturn($queryResult->setAffectedNumRows(1));
|
||||
->willReturn(new QueryResult(null, 1));
|
||||
|
||||
$this->assertTrue($this->accountToUserGroup->deleteByAccountId($accountId));
|
||||
}
|
||||
@@ -92,7 +90,7 @@ class AccountToUserGroupTest extends UnitaryTestCase
|
||||
|
||||
$this->database
|
||||
->expects(self::once())
|
||||
->method('doSelect')
|
||||
->method('runQuery')
|
||||
->with($callback)
|
||||
->willReturn(new QueryResult());
|
||||
|
||||
@@ -107,8 +105,6 @@ class AccountToUserGroupTest extends UnitaryTestCase
|
||||
{
|
||||
$userGroupId = self::$faker->randomNumber();
|
||||
|
||||
$queryResult = new QueryResult();
|
||||
|
||||
$callback = new Callback(
|
||||
static function (QueryData $arg) use ($userGroupId) {
|
||||
$query = $arg->getQuery();
|
||||
@@ -121,9 +117,9 @@ class AccountToUserGroupTest extends UnitaryTestCase
|
||||
|
||||
$this->database
|
||||
->expects(self::once())
|
||||
->method('doQuery')
|
||||
->method('runQuery')
|
||||
->with($callback)
|
||||
->willReturn($queryResult->setAffectedNumRows(1));
|
||||
->willReturn(new QueryResult(null, 1));
|
||||
|
||||
$this->assertTrue($this->accountToUserGroup->deleteByUserGroupId($userGroupId));
|
||||
}
|
||||
@@ -142,7 +138,7 @@ class AccountToUserGroupTest extends UnitaryTestCase
|
||||
|
||||
$this->database
|
||||
->expects(self::once())
|
||||
->method('doQuery')
|
||||
->method('runQuery')
|
||||
->with($callback);
|
||||
|
||||
$this->accountToUserGroup->addByType(
|
||||
@@ -160,8 +156,6 @@ class AccountToUserGroupTest extends UnitaryTestCase
|
||||
{
|
||||
$accountId = self::$faker->randomNumber();
|
||||
|
||||
$queryResult = new QueryResult();
|
||||
|
||||
$callback = new Callback(
|
||||
static function (QueryData $arg) use ($accountId) {
|
||||
$query = $arg->getQuery();
|
||||
@@ -174,9 +168,9 @@ class AccountToUserGroupTest extends UnitaryTestCase
|
||||
|
||||
$this->database
|
||||
->expects(self::once())
|
||||
->method('doQuery')
|
||||
->method('runQuery')
|
||||
->with($callback)
|
||||
->willReturn($queryResult->setAffectedNumRows(1));
|
||||
->willReturn(new QueryResult(null, 1));
|
||||
|
||||
$this->assertTrue($this->accountToUserGroup->deleteByAccountId($accountId));
|
||||
}
|
||||
@@ -197,7 +191,7 @@ class AccountToUserGroupTest extends UnitaryTestCase
|
||||
|
||||
$this->database
|
||||
->expects(self::once())
|
||||
->method('doSelect')
|
||||
->method('runQuery')
|
||||
->with($callback)
|
||||
->willReturn(new QueryResult());
|
||||
|
||||
|
||||
@@ -55,8 +55,6 @@ class AccountToUserTest extends UnitaryTestCase
|
||||
{
|
||||
$accountId = self::$faker->randomNumber();
|
||||
|
||||
$queryResult = new QueryResult();
|
||||
|
||||
$callback = new Callback(
|
||||
static function (QueryData $arg) use ($accountId) {
|
||||
$query = $arg->getQuery();
|
||||
@@ -69,9 +67,9 @@ class AccountToUserTest extends UnitaryTestCase
|
||||
|
||||
$this->database
|
||||
->expects(self::once())
|
||||
->method('doQuery')
|
||||
->method('runQuery')
|
||||
->with($callback)
|
||||
->willReturn($queryResult->setAffectedNumRows(1));
|
||||
->willReturn(new QueryResult(null, 1));
|
||||
|
||||
$this->assertTrue($this->accountToUser->deleteByAccountId($accountId));
|
||||
}
|
||||
@@ -92,7 +90,7 @@ class AccountToUserTest extends UnitaryTestCase
|
||||
|
||||
$this->database
|
||||
->expects(self::once())
|
||||
->method('doSelect')
|
||||
->method('runQuery')
|
||||
->with($callback)
|
||||
->willReturn(new QueryResult());
|
||||
|
||||
@@ -107,8 +105,6 @@ class AccountToUserTest extends UnitaryTestCase
|
||||
{
|
||||
$accountId = self::$faker->randomNumber();
|
||||
|
||||
$queryResult = new QueryResult();
|
||||
|
||||
$callback = new Callback(
|
||||
static function (QueryData $arg) use ($accountId) {
|
||||
$query = $arg->getQuery();
|
||||
@@ -121,9 +117,9 @@ class AccountToUserTest extends UnitaryTestCase
|
||||
|
||||
$this->database
|
||||
->expects(self::once())
|
||||
->method('doQuery')
|
||||
->method('runQuery')
|
||||
->with($callback)
|
||||
->willReturn($queryResult->setAffectedNumRows(1));
|
||||
->willReturn(new QueryResult(null, 1));
|
||||
|
||||
$this->assertTrue($this->accountToUser->deleteByAccountId($accountId));
|
||||
}
|
||||
@@ -142,7 +138,7 @@ class AccountToUserTest extends UnitaryTestCase
|
||||
|
||||
$this->database
|
||||
->expects(self::once())
|
||||
->method('doQuery')
|
||||
->method('runQuery')
|
||||
->with($callback);
|
||||
|
||||
$this->accountToUser->addByType(
|
||||
@@ -160,8 +156,6 @@ class AccountToUserTest extends UnitaryTestCase
|
||||
{
|
||||
$accountId = self::$faker->randomNumber();
|
||||
|
||||
$queryResult = new QueryResult();
|
||||
|
||||
$callback = new Callback(
|
||||
static function (QueryData $arg) use ($accountId) {
|
||||
$query = $arg->getQuery();
|
||||
@@ -174,9 +168,9 @@ class AccountToUserTest extends UnitaryTestCase
|
||||
|
||||
$this->database
|
||||
->expects(self::once())
|
||||
->method('doQuery')
|
||||
->method('runQuery')
|
||||
->with($callback)
|
||||
->willReturn($queryResult->setAffectedNumRows(1));
|
||||
->willReturn(new QueryResult(null, 1));
|
||||
|
||||
$this->assertTrue($this->accountToUser->deleteByAccountId($accountId));
|
||||
}
|
||||
|
||||
@@ -58,23 +58,19 @@ class PublicLinkTest extends UnitaryTestCase
|
||||
*/
|
||||
public function testDelete(): void
|
||||
{
|
||||
$id = 1;
|
||||
$expected = new QueryResult();
|
||||
$expected->setAffectedNumRows(1);
|
||||
|
||||
$callback = new Callback(
|
||||
static function (QueryData $arg) use ($id) {
|
||||
return $arg->getQuery()->getBindValues()['id'] === $id
|
||||
static function (QueryData $arg) {
|
||||
return $arg->getQuery()->getBindValues()['id'] === 100
|
||||
&& !empty($arg->getQuery()->getStatement());
|
||||
}
|
||||
);
|
||||
|
||||
$this->database->expects(self::once())
|
||||
->method('doQuery')
|
||||
->method('runQuery')
|
||||
->with($callback)
|
||||
->willReturn($expected);
|
||||
->willReturn(new QueryResult(null, 1));
|
||||
|
||||
$this->publicLink->delete($id);
|
||||
$this->publicLink->delete(100);
|
||||
}
|
||||
|
||||
public function testSearch(): void
|
||||
@@ -96,7 +92,7 @@ class PublicLinkTest extends UnitaryTestCase
|
||||
|
||||
$this->database
|
||||
->expects(self::once())
|
||||
->method('doSelect')
|
||||
->method('runQuery')
|
||||
->with($callback)
|
||||
->willReturn(new QueryResult());
|
||||
|
||||
@@ -116,7 +112,7 @@ class PublicLinkTest extends UnitaryTestCase
|
||||
);
|
||||
|
||||
$this->database->expects(self::once())
|
||||
->method('doSelect')
|
||||
->method('runQuery')
|
||||
->with($callback)
|
||||
->willReturn(new QueryResult());
|
||||
|
||||
@@ -136,7 +132,7 @@ class PublicLinkTest extends UnitaryTestCase
|
||||
);
|
||||
|
||||
$this->database->expects(self::once())
|
||||
->method('doSelect')
|
||||
->method('runQuery')
|
||||
->with($callback)
|
||||
->willReturn(new QueryResult());
|
||||
|
||||
@@ -151,8 +147,6 @@ class PublicLinkTest extends UnitaryTestCase
|
||||
{
|
||||
$publicLinkData = $this->buildPublicLinkData();
|
||||
|
||||
$queryResult = new QueryResult();
|
||||
|
||||
$callback = new Callback(
|
||||
static function (QueryData $arg) use ($publicLinkData) {
|
||||
$query = $arg->getQuery();
|
||||
@@ -165,9 +159,9 @@ class PublicLinkTest extends UnitaryTestCase
|
||||
);
|
||||
|
||||
$this->database->expects(self::once())
|
||||
->method('doQuery')
|
||||
->method('runQuery')
|
||||
->with($callback)
|
||||
->willReturn($queryResult->setAffectedNumRows(1));
|
||||
->willReturn(new QueryResult(null, 1));
|
||||
|
||||
$this->assertTrue($this->publicLink->addLinkView($publicLinkData));
|
||||
}
|
||||
@@ -229,7 +223,7 @@ class PublicLinkTest extends UnitaryTestCase
|
||||
);
|
||||
|
||||
$this->database->expects(self::exactly(2))
|
||||
->method('doQuery')
|
||||
->method('runQuery')
|
||||
->with(...self::withConsecutive([$callbackCheckDuplicate], [$callbackCreate]))
|
||||
->willReturn(new QueryResult());
|
||||
|
||||
@@ -255,7 +249,7 @@ class PublicLinkTest extends UnitaryTestCase
|
||||
);
|
||||
|
||||
$this->database->expects(self::once())
|
||||
->method('doQuery')
|
||||
->method('runQuery')
|
||||
->with($callback)
|
||||
->willReturn(new QueryResult([1]));
|
||||
|
||||
@@ -276,7 +270,7 @@ class PublicLinkTest extends UnitaryTestCase
|
||||
|
||||
$this->database
|
||||
->expects(self::once())
|
||||
->method('doSelect')
|
||||
->method('runQuery')
|
||||
->with($callback)
|
||||
->willReturn(new QueryResult());
|
||||
|
||||
@@ -307,7 +301,7 @@ class PublicLinkTest extends UnitaryTestCase
|
||||
);
|
||||
|
||||
$this->database->expects(self::once())
|
||||
->method('doQuery')
|
||||
->method('runQuery')
|
||||
->with($callback)
|
||||
->willReturn(new QueryResult());
|
||||
|
||||
@@ -335,7 +329,7 @@ class PublicLinkTest extends UnitaryTestCase
|
||||
);
|
||||
|
||||
$this->database->expects(self::once())
|
||||
->method('doQuery')
|
||||
->method('runQuery')
|
||||
->with($callback)
|
||||
->willReturn(new QueryResult());
|
||||
|
||||
@@ -349,7 +343,7 @@ class PublicLinkTest extends UnitaryTestCase
|
||||
public function testDeleteByIdBatchWithNoIds(): void
|
||||
{
|
||||
$this->database->expects(self::never())
|
||||
->method('doQuery');
|
||||
->method('runQuery');
|
||||
|
||||
$this->assertEquals(0, $this->publicLink->deleteByIdBatch([]));
|
||||
}
|
||||
@@ -367,7 +361,7 @@ class PublicLinkTest extends UnitaryTestCase
|
||||
);
|
||||
|
||||
$this->database->expects(self::once())
|
||||
->method('doSelect')
|
||||
->method('runQuery')
|
||||
->with($callback)
|
||||
->willReturn(new QueryResult());
|
||||
|
||||
@@ -401,7 +395,7 @@ class PublicLinkTest extends UnitaryTestCase
|
||||
);
|
||||
|
||||
$this->database->expects(self::once())
|
||||
->method('doQuery')
|
||||
->method('runQuery')
|
||||
->with($callback)
|
||||
->willReturn(new QueryResult());
|
||||
|
||||
@@ -422,7 +416,7 @@ class PublicLinkTest extends UnitaryTestCase
|
||||
|
||||
$this->database
|
||||
->expects(self::once())
|
||||
->method('doSelect')
|
||||
->method('runQuery')
|
||||
->with($callback)
|
||||
->willReturn(new QueryResult());
|
||||
|
||||
|
||||
@@ -81,7 +81,7 @@ class AuthTokenTest extends UnitaryTestCase
|
||||
|
||||
$this->database
|
||||
->expects(self::once())
|
||||
->method('doSelect')
|
||||
->method('runQuery')
|
||||
->with($callback, true);
|
||||
|
||||
$this->authToken->search($item);
|
||||
@@ -105,7 +105,7 @@ class AuthTokenTest extends UnitaryTestCase
|
||||
|
||||
$this->database
|
||||
->expects(self::once())
|
||||
->method('doSelect')
|
||||
->method('runQuery')
|
||||
->with($callback, true);
|
||||
|
||||
$this->authToken->search(new ItemSearchData());
|
||||
@@ -136,7 +136,7 @@ class AuthTokenTest extends UnitaryTestCase
|
||||
|
||||
$this->database
|
||||
->expects(self::once())
|
||||
->method('doQuery')
|
||||
->method('runQuery')
|
||||
->with($callback);
|
||||
|
||||
$this->authToken->deleteByIdBatch($ids);
|
||||
@@ -150,7 +150,7 @@ class AuthTokenTest extends UnitaryTestCase
|
||||
{
|
||||
$this->database
|
||||
->expects(self::never())
|
||||
->method('doQuery');
|
||||
->method('runQuery');
|
||||
|
||||
$this->authToken->deleteByIdBatch([]);
|
||||
}
|
||||
@@ -174,7 +174,7 @@ class AuthTokenTest extends UnitaryTestCase
|
||||
|
||||
$this->database
|
||||
->expects(self::once())
|
||||
->method('doSelect')
|
||||
->method('runQuery')
|
||||
->with($callback);
|
||||
|
||||
$this->authToken->getTokenByUserId($id);
|
||||
@@ -199,7 +199,7 @@ class AuthTokenTest extends UnitaryTestCase
|
||||
|
||||
$this->database
|
||||
->expects(self::once())
|
||||
->method('doSelect')
|
||||
->method('runQuery')
|
||||
->with($callback);
|
||||
|
||||
$this->authToken->getById($id);
|
||||
@@ -249,7 +249,7 @@ class AuthTokenTest extends UnitaryTestCase
|
||||
|
||||
$this->database
|
||||
->expects(self::exactly(2))
|
||||
->method('doQuery')
|
||||
->method('runQuery')
|
||||
->with(...self::withConsecutive([$callbackDuplicate], [$callbackUpdate]))
|
||||
->willReturn(new QueryResult([]), new QueryResult([1]));
|
||||
|
||||
@@ -282,7 +282,7 @@ class AuthTokenTest extends UnitaryTestCase
|
||||
|
||||
$this->database
|
||||
->expects(self::once())
|
||||
->method('doQuery')
|
||||
->method('runQuery')
|
||||
->with($callback)
|
||||
->willReturn(new QueryResult([1]));
|
||||
|
||||
@@ -317,13 +317,11 @@ class AuthTokenTest extends UnitaryTestCase
|
||||
}
|
||||
);
|
||||
|
||||
$queryResult = new QueryResult([1]);
|
||||
|
||||
$this->database
|
||||
->expects(self::once())
|
||||
->method('doQuery')
|
||||
->method('runQuery')
|
||||
->with($callback)
|
||||
->willReturn($queryResult->setAffectedNumRows(10));
|
||||
->willReturn(new QueryResult(null, 10));
|
||||
|
||||
$out = $this->authToken->refreshVaultByUserId($userId, $vault, $hash);
|
||||
|
||||
@@ -348,7 +346,7 @@ class AuthTokenTest extends UnitaryTestCase
|
||||
}
|
||||
);
|
||||
|
||||
$this->database->expects(self::once())->method('doQuery')->with($callback);
|
||||
$this->database->expects(self::once())->method('runQuery')->with($callback);
|
||||
|
||||
$this->authToken->delete($id);
|
||||
}
|
||||
@@ -366,7 +364,7 @@ class AuthTokenTest extends UnitaryTestCase
|
||||
|
||||
$this->database
|
||||
->expects(self::once())
|
||||
->method('doSelect')
|
||||
->method('runQuery')
|
||||
->with($callback);
|
||||
|
||||
$this->authToken->getAll();
|
||||
@@ -397,7 +395,7 @@ class AuthTokenTest extends UnitaryTestCase
|
||||
|
||||
$this->database
|
||||
->expects(self::once())
|
||||
->method('doQuery')
|
||||
->method('runQuery')
|
||||
->with($callback)
|
||||
->willReturn(new QueryResult([1]));
|
||||
|
||||
@@ -425,7 +423,7 @@ class AuthTokenTest extends UnitaryTestCase
|
||||
|
||||
$this->database
|
||||
->expects(self::once())
|
||||
->method('doSelect')
|
||||
->method('runQuery')
|
||||
->with($callback);
|
||||
|
||||
$this->authToken->getTokenByToken($actionId, $token);
|
||||
@@ -473,7 +471,7 @@ class AuthTokenTest extends UnitaryTestCase
|
||||
|
||||
$this->database
|
||||
->expects(self::exactly(2))
|
||||
->method('doQuery')
|
||||
->method('runQuery')
|
||||
->with(...self::withConsecutive([$callbackDuplicate], [$callbackUpdate]))
|
||||
->willReturn(new QueryResult([]), new QueryResult([1]));
|
||||
|
||||
@@ -505,7 +503,7 @@ class AuthTokenTest extends UnitaryTestCase
|
||||
|
||||
$this->database
|
||||
->expects(self::once())
|
||||
->method('doQuery')
|
||||
->method('runQuery')
|
||||
->with($callback)
|
||||
->willReturn(new QueryResult([1]));
|
||||
|
||||
|
||||
@@ -95,7 +95,7 @@ class CategoryTest extends UnitaryTestCase
|
||||
|
||||
$this->database
|
||||
->expects(self::exactly(2))
|
||||
->method('doQuery')
|
||||
->method('runQuery')
|
||||
->with(...self::withConsecutive([$callbackDuplicate], [$callbackUpdate]))
|
||||
->willReturn(new QueryResult([]), new QueryResult([1]));
|
||||
|
||||
@@ -126,7 +126,7 @@ class CategoryTest extends UnitaryTestCase
|
||||
|
||||
$this->database
|
||||
->expects(self::once())
|
||||
->method('doQuery')
|
||||
->method('runQuery')
|
||||
->with($callbackDuplicate)
|
||||
->willReturn(new QueryResult([1]));
|
||||
|
||||
@@ -154,7 +154,7 @@ class CategoryTest extends UnitaryTestCase
|
||||
}
|
||||
);
|
||||
|
||||
$this->database->expects(self::once())->method('doQuery')->with($callback);
|
||||
$this->database->expects(self::once())->method('runQuery')->with($callback);
|
||||
|
||||
$this->category->delete($id);
|
||||
}
|
||||
@@ -184,7 +184,7 @@ class CategoryTest extends UnitaryTestCase
|
||||
|
||||
$this->database
|
||||
->expects(self::once())
|
||||
->method('doQuery')
|
||||
->method('runQuery')
|
||||
->with($callback);
|
||||
|
||||
$this->category->deleteByIdBatch($ids);
|
||||
@@ -198,7 +198,7 @@ class CategoryTest extends UnitaryTestCase
|
||||
{
|
||||
$this->database
|
||||
->expects(self::never())
|
||||
->method('doQuery');
|
||||
->method('runQuery');
|
||||
|
||||
$this->category->deleteByIdBatch([]);
|
||||
}
|
||||
@@ -222,7 +222,7 @@ class CategoryTest extends UnitaryTestCase
|
||||
|
||||
$this->database
|
||||
->expects(self::once())
|
||||
->method('doSelect')
|
||||
->method('runQuery')
|
||||
->with($callback);
|
||||
|
||||
$this->category->getById($id);
|
||||
@@ -252,7 +252,7 @@ class CategoryTest extends UnitaryTestCase
|
||||
|
||||
$this->database
|
||||
->expects(self::once())
|
||||
->method('doSelect')
|
||||
->method('runQuery')
|
||||
->with($callback, true);
|
||||
|
||||
$this->category->search($item);
|
||||
@@ -275,7 +275,7 @@ class CategoryTest extends UnitaryTestCase
|
||||
|
||||
$this->database
|
||||
->expects(self::once())
|
||||
->method('doSelect')
|
||||
->method('runQuery')
|
||||
->with($callback, true);
|
||||
|
||||
$this->category->search(new ItemSearchData());
|
||||
@@ -294,7 +294,7 @@ class CategoryTest extends UnitaryTestCase
|
||||
|
||||
$this->database
|
||||
->expects(self::once())
|
||||
->method('doSelect')
|
||||
->method('runQuery')
|
||||
->with($callback);
|
||||
|
||||
$this->category->getAll();
|
||||
@@ -340,7 +340,7 @@ class CategoryTest extends UnitaryTestCase
|
||||
|
||||
$this->database
|
||||
->expects(self::exactly(2))
|
||||
->method('doQuery')
|
||||
->method('runQuery')
|
||||
->with(...self::withConsecutive([$callbackDuplicate], [$callbackUpdate]))
|
||||
->willReturn(new QueryResult([]), new QueryResult([1]));
|
||||
|
||||
@@ -371,7 +371,7 @@ class CategoryTest extends UnitaryTestCase
|
||||
|
||||
$this->database
|
||||
->expects(self::once())
|
||||
->method('doQuery')
|
||||
->method('runQuery')
|
||||
->with($callbackDuplicate)
|
||||
->willReturn(new QueryResult([1]));
|
||||
|
||||
@@ -401,7 +401,7 @@ class CategoryTest extends UnitaryTestCase
|
||||
|
||||
$this->database
|
||||
->expects(self::once())
|
||||
->method('doSelect')
|
||||
->method('runQuery')
|
||||
->with($callback);
|
||||
|
||||
$this->category->getByName($name);
|
||||
|
||||
@@ -99,7 +99,7 @@ class ClientTest extends UnitaryTestCase
|
||||
|
||||
$this->database
|
||||
->expects(self::exactly(2))
|
||||
->method('doQuery')
|
||||
->method('runQuery')
|
||||
->with(...self::withConsecutive([$callbackDuplicate], [$callbackCreate]))
|
||||
->willReturn(new QueryResult([]), new QueryResult([1]));
|
||||
|
||||
@@ -129,7 +129,7 @@ class ClientTest extends UnitaryTestCase
|
||||
|
||||
$this->database
|
||||
->expects(self::once())
|
||||
->method('doQuery')
|
||||
->method('runQuery')
|
||||
->with($callbackDuplicate)
|
||||
->willReturn(new QueryResult([1]));
|
||||
|
||||
@@ -157,7 +157,7 @@ class ClientTest extends UnitaryTestCase
|
||||
}
|
||||
);
|
||||
|
||||
$this->database->expects(self::once())->method('doQuery')->with($callback);
|
||||
$this->database->expects(self::once())->method('runQuery')->with($callback);
|
||||
|
||||
$this->client->delete($id);
|
||||
}
|
||||
@@ -187,7 +187,7 @@ class ClientTest extends UnitaryTestCase
|
||||
|
||||
$this->database
|
||||
->expects(self::once())
|
||||
->method('doQuery')
|
||||
->method('runQuery')
|
||||
->with($callback);
|
||||
|
||||
$this->client->deleteByIdBatch($ids);
|
||||
@@ -201,7 +201,7 @@ class ClientTest extends UnitaryTestCase
|
||||
{
|
||||
$this->database
|
||||
->expects(self::never())
|
||||
->method('doQuery');
|
||||
->method('runQuery');
|
||||
|
||||
$this->client->deleteByIdBatch([]);
|
||||
}
|
||||
@@ -225,7 +225,7 @@ class ClientTest extends UnitaryTestCase
|
||||
|
||||
$this->database
|
||||
->expects(self::once())
|
||||
->method('doSelect')
|
||||
->method('runQuery')
|
||||
->with($callback);
|
||||
|
||||
$this->client->getById($id);
|
||||
@@ -255,7 +255,7 @@ class ClientTest extends UnitaryTestCase
|
||||
|
||||
$this->database
|
||||
->expects(self::once())
|
||||
->method('doSelect')
|
||||
->method('runQuery')
|
||||
->with($callback, true);
|
||||
|
||||
$this->client->search($item);
|
||||
@@ -278,7 +278,7 @@ class ClientTest extends UnitaryTestCase
|
||||
|
||||
$this->database
|
||||
->expects(self::once())
|
||||
->method('doSelect')
|
||||
->method('runQuery')
|
||||
->with($callback, true);
|
||||
|
||||
$this->client->search(new ItemSearchData());
|
||||
@@ -297,7 +297,7 @@ class ClientTest extends UnitaryTestCase
|
||||
|
||||
$this->database
|
||||
->expects(self::once())
|
||||
->method('doSelect')
|
||||
->method('runQuery')
|
||||
->with($callback);
|
||||
|
||||
$this->client->getAll();
|
||||
@@ -319,7 +319,7 @@ class ClientTest extends UnitaryTestCase
|
||||
|
||||
$this->database
|
||||
->expects(self::once())
|
||||
->method('doSelect')
|
||||
->method('runQuery')
|
||||
->with($callback);
|
||||
|
||||
$select = (new QueryFactory('mysql', QueryFactory::COMMON))->newSelect();
|
||||
@@ -373,7 +373,7 @@ class ClientTest extends UnitaryTestCase
|
||||
|
||||
$this->database
|
||||
->expects(self::exactly(2))
|
||||
->method('doQuery')
|
||||
->method('runQuery')
|
||||
->with(...self::withConsecutive([$callbackDuplicate], [$callbackUpdate]))
|
||||
->willReturn(new QueryResult([]), new QueryResult([1]));
|
||||
|
||||
@@ -405,7 +405,7 @@ class ClientTest extends UnitaryTestCase
|
||||
|
||||
$this->database
|
||||
->expects(self::once())
|
||||
->method('doQuery')
|
||||
->method('runQuery')
|
||||
->with($callbackDuplicate)
|
||||
->willReturn(new QueryResult([1]));
|
||||
|
||||
@@ -435,7 +435,7 @@ class ClientTest extends UnitaryTestCase
|
||||
|
||||
$this->database
|
||||
->expects(self::once())
|
||||
->method('doSelect')
|
||||
->method('runQuery')
|
||||
->with($callback);
|
||||
|
||||
$this->client->getByName($name);
|
||||
|
||||
@@ -69,7 +69,7 @@ class ConfigTest extends UnitaryTestCase
|
||||
|
||||
$this->database
|
||||
->expects(self::once())
|
||||
->method('doSelect')
|
||||
->method('runQuery')
|
||||
->with($callback);
|
||||
|
||||
$this->configRepository->getByParam($param);
|
||||
@@ -100,7 +100,7 @@ class ConfigTest extends UnitaryTestCase
|
||||
|
||||
$this->database
|
||||
->expects(self::exactly(1))
|
||||
->method('doQuery')
|
||||
->method('runQuery')
|
||||
->with($callback)
|
||||
->willReturn($queryResult);
|
||||
|
||||
@@ -128,7 +128,7 @@ class ConfigTest extends UnitaryTestCase
|
||||
|
||||
$this->database
|
||||
->expects(self::once())
|
||||
->method('doSelect')
|
||||
->method('runQuery')
|
||||
->with($callback)
|
||||
->willReturn(new QueryResult([1]));
|
||||
|
||||
@@ -160,7 +160,7 @@ class ConfigTest extends UnitaryTestCase
|
||||
|
||||
$this->database
|
||||
->expects(self::exactly(1))
|
||||
->method('doQuery')
|
||||
->method('runQuery')
|
||||
->with($callback)
|
||||
->willReturn($queryResult);
|
||||
|
||||
|
||||
@@ -77,7 +77,7 @@ class CustomFieldDataTest extends UnitaryTestCase
|
||||
|
||||
$this->database
|
||||
->expects(self::once())
|
||||
->method('doQuery')
|
||||
->method('runQuery')
|
||||
->with($callback);
|
||||
|
||||
$this->customFieldData->deleteBatch($itemIds, $moduleId);
|
||||
@@ -93,7 +93,7 @@ class CustomFieldDataTest extends UnitaryTestCase
|
||||
|
||||
$this->database
|
||||
->expects(self::never())
|
||||
->method('doQuery');
|
||||
->method('runQuery');
|
||||
|
||||
$result = $this->customFieldData->deleteBatch([], $moduleId);
|
||||
|
||||
@@ -126,7 +126,7 @@ class CustomFieldDataTest extends UnitaryTestCase
|
||||
|
||||
$this->database
|
||||
->expects(self::once())
|
||||
->method('doQuery')
|
||||
->method('runQuery')
|
||||
->with($callback)
|
||||
->willReturn(new QueryResult([1]));
|
||||
|
||||
@@ -159,7 +159,7 @@ class CustomFieldDataTest extends UnitaryTestCase
|
||||
|
||||
$this->database
|
||||
->expects(self::once())
|
||||
->method('doQuery')
|
||||
->method('runQuery')
|
||||
->with($callback)
|
||||
->willReturn(new QueryResult([]));
|
||||
|
||||
@@ -179,7 +179,7 @@ class CustomFieldDataTest extends UnitaryTestCase
|
||||
|
||||
$this->database
|
||||
->expects(self::once())
|
||||
->method('doSelect')
|
||||
->method('runQuery')
|
||||
->with($callback);
|
||||
|
||||
$this->customFieldData->getAll();
|
||||
@@ -211,7 +211,7 @@ class CustomFieldDataTest extends UnitaryTestCase
|
||||
|
||||
$this->database
|
||||
->expects(self::once())
|
||||
->method('doQuery')
|
||||
->method('runQuery')
|
||||
->with($callback)
|
||||
->willReturn(new QueryResult([]));
|
||||
|
||||
@@ -244,7 +244,7 @@ class CustomFieldDataTest extends UnitaryTestCase
|
||||
|
||||
$this->database
|
||||
->expects(self::once())
|
||||
->method('doQuery')
|
||||
->method('runQuery')
|
||||
->with($callback)
|
||||
->willReturn(new QueryResult([]));
|
||||
|
||||
@@ -274,7 +274,7 @@ class CustomFieldDataTest extends UnitaryTestCase
|
||||
|
||||
$this->database
|
||||
->expects(self::once())
|
||||
->method('doSelect')
|
||||
->method('runQuery')
|
||||
->with($callback);
|
||||
|
||||
$this->customFieldData->getForModuleAndItemId($moduleId, $itemId);
|
||||
@@ -293,7 +293,7 @@ class CustomFieldDataTest extends UnitaryTestCase
|
||||
|
||||
$this->database
|
||||
->expects(self::once())
|
||||
->method('doSelect')
|
||||
->method('runQuery')
|
||||
->with($callback);
|
||||
|
||||
$this->customFieldData->getAllEncrypted();
|
||||
|
||||
@@ -67,7 +67,7 @@ class CustomFieldDefinitionTest extends UnitaryTestCase
|
||||
|
||||
$this->database
|
||||
->expects(self::once())
|
||||
->method('doSelect')
|
||||
->method('runQuery')
|
||||
->with($callback);
|
||||
|
||||
$this->customFieldDefinition->getAll();
|
||||
@@ -101,7 +101,7 @@ class CustomFieldDefinitionTest extends UnitaryTestCase
|
||||
|
||||
$this->database
|
||||
->expects(self::once())
|
||||
->method('doQuery')
|
||||
->method('runQuery')
|
||||
->with($callback)
|
||||
->willReturn(new QueryResult([]));
|
||||
|
||||
@@ -136,7 +136,7 @@ class CustomFieldDefinitionTest extends UnitaryTestCase
|
||||
|
||||
$this->database
|
||||
->expects(self::once())
|
||||
->method('doQuery')
|
||||
->method('runQuery')
|
||||
->with($callback)
|
||||
->willReturn(new QueryResult([]));
|
||||
|
||||
@@ -162,7 +162,7 @@ class CustomFieldDefinitionTest extends UnitaryTestCase
|
||||
|
||||
$this->database
|
||||
->expects(self::once())
|
||||
->method('doSelect')
|
||||
->method('runQuery')
|
||||
->with($callback)
|
||||
->willReturn(new QueryResult([]));
|
||||
|
||||
@@ -191,7 +191,7 @@ class CustomFieldDefinitionTest extends UnitaryTestCase
|
||||
|
||||
$this->database
|
||||
->expects(self::once())
|
||||
->method('doQuery')
|
||||
->method('runQuery')
|
||||
->with($callback);
|
||||
|
||||
$this->customFieldDefinition->deleteByIdBatch($ids);
|
||||
@@ -205,7 +205,7 @@ class CustomFieldDefinitionTest extends UnitaryTestCase
|
||||
{
|
||||
$this->database
|
||||
->expects(self::never())
|
||||
->method('doQuery');
|
||||
->method('runQuery');
|
||||
|
||||
$result = $this->customFieldDefinition->deleteByIdBatch([]);
|
||||
|
||||
@@ -237,7 +237,7 @@ class CustomFieldDefinitionTest extends UnitaryTestCase
|
||||
|
||||
$this->database
|
||||
->expects(self::once())
|
||||
->method('doSelect')
|
||||
->method('runQuery')
|
||||
->with($callback, true);
|
||||
|
||||
$this->customFieldDefinition->search($item);
|
||||
@@ -263,7 +263,7 @@ class CustomFieldDefinitionTest extends UnitaryTestCase
|
||||
|
||||
$this->database
|
||||
->expects(self::once())
|
||||
->method('doSelect')
|
||||
->method('runQuery')
|
||||
->with($callback, true);
|
||||
|
||||
$this->customFieldDefinition->search(new ItemSearchData());
|
||||
@@ -287,7 +287,7 @@ class CustomFieldDefinitionTest extends UnitaryTestCase
|
||||
}
|
||||
);
|
||||
|
||||
$this->database->expects(self::once())->method('doQuery')->with($callback);
|
||||
$this->database->expects(self::once())->method('runQuery')->with($callback);
|
||||
|
||||
$this->customFieldDefinition->delete($id);
|
||||
}
|
||||
|
||||
@@ -59,7 +59,7 @@ class CustomFieldTypeTest extends UnitaryTestCase
|
||||
|
||||
$this->database
|
||||
->expects(self::once())
|
||||
->method('doSelect')
|
||||
->method('runQuery')
|
||||
->with($callback);
|
||||
|
||||
$this->customFieldType->getAll();
|
||||
|
||||
706
tests/SPT/Infrastructure/Database/DatabaseTest.php
Normal file
706
tests/SPT/Infrastructure/Database/DatabaseTest.php
Normal file
@@ -0,0 +1,706 @@
|
||||
<?php
|
||||
/*
|
||||
* sysPass
|
||||
*
|
||||
* @author nuxsmin
|
||||
* @link https://syspass.org
|
||||
* @copyright 2012-2024, Rubén Domínguez nuxsmin@$syspass.org
|
||||
*
|
||||
* This file is part of sysPass.
|
||||
*
|
||||
* sysPass is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* sysPass is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with sysPass. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
namespace SPT\Infrastructure\Database;
|
||||
|
||||
use Aura\SqlQuery\Common\SelectInterface;
|
||||
use Aura\SqlQuery\QueryInterface;
|
||||
use PDO;
|
||||
use PDOStatement;
|
||||
use PHPUnit\Framework\Attributes\DataProvider;
|
||||
use PHPUnit\Framework\Attributes\Group;
|
||||
use PHPUnit\Framework\MockObject\Exception;
|
||||
use PHPUnit\Framework\MockObject\MockObject;
|
||||
use PHPUnit\Framework\MockObject\Rule\InvokedCount;
|
||||
use RuntimeException;
|
||||
use SP\Domain\Common\Models\Simple;
|
||||
use SP\Domain\Core\Exceptions\ConstraintException;
|
||||
use SP\Domain\Core\Exceptions\QueryException;
|
||||
use SP\Infrastructure\Database\Database;
|
||||
use SP\Infrastructure\Database\DbStorageDriver;
|
||||
use SP\Infrastructure\Database\DbStorageHandler;
|
||||
use SP\Infrastructure\Database\QueryDataInterface;
|
||||
use SPT\UnitaryTestCase;
|
||||
|
||||
/**
|
||||
* Class DatabaseTest
|
||||
*/
|
||||
#[Group('unitary')]
|
||||
class DatabaseTest extends UnitaryTestCase
|
||||
{
|
||||
|
||||
private MockObject|DbStorageHandler $dbStorageHandler;
|
||||
private Database $database;
|
||||
|
||||
public static function bufferedDataProvider(): array
|
||||
{
|
||||
return [
|
||||
[true],
|
||||
[false]
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws Exception
|
||||
*/
|
||||
public function testBeginTransaction()
|
||||
{
|
||||
$pdo = $this->createMock(PDO::class);
|
||||
|
||||
$this->dbStorageHandler
|
||||
->expects($this->once())
|
||||
->method('getConnection')
|
||||
->willReturn($pdo);
|
||||
|
||||
$pdo->expects($this->once())
|
||||
->method('inTransaction')
|
||||
->willReturn(false);
|
||||
|
||||
$pdo->expects($this->once())
|
||||
->method('beginTransaction')
|
||||
->willReturn(true);
|
||||
|
||||
self::assertTrue($this->database->beginTransaction());
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws Exception
|
||||
*/
|
||||
public function testBeginTransactionWithExistingTransaction()
|
||||
{
|
||||
$pdo = $this->createMock(PDO::class);
|
||||
|
||||
$this->dbStorageHandler
|
||||
->expects($this->once())
|
||||
->method('getConnection')
|
||||
->willReturn($pdo);
|
||||
|
||||
$pdo->expects($this->once())
|
||||
->method('inTransaction')
|
||||
->willReturn(true);
|
||||
|
||||
$pdo->expects($this->never())
|
||||
->method('beginTransaction');
|
||||
|
||||
self::assertTrue($this->database->beginTransaction());
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws Exception
|
||||
* @throws ConstraintException
|
||||
* @throws QueryException
|
||||
*/
|
||||
public function testRunQueryWithMappedClass()
|
||||
{
|
||||
list($pdoStatement, $query) = $this->checkPrepare();
|
||||
|
||||
$pdoStatement->expects($this->once())
|
||||
->method('fetchAll')
|
||||
->with(PDO::FETCH_CLASS | PDO::FETCH_PROPS_LATE, Simple::class);
|
||||
|
||||
$queryData = $this->createMock(QueryDataInterface::class);
|
||||
|
||||
$queryData->expects($this->once(1))
|
||||
->method('getQuery')
|
||||
->willReturn($query);
|
||||
|
||||
$queryData->expects($this->once(1))
|
||||
->method('getMapClassName')
|
||||
->willReturn(Simple::class);
|
||||
|
||||
$this->database->runQuery($queryData);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $queryType
|
||||
* @param bool $useValues
|
||||
* @param int $times
|
||||
* @param array $prepareOptions
|
||||
* @return array
|
||||
* @throws Exception
|
||||
*/
|
||||
private function checkPrepare(
|
||||
string $queryType = SelectInterface::class,
|
||||
bool $useValues = true,
|
||||
int $times = 1,
|
||||
array $prepareOptions = []
|
||||
): array {
|
||||
$pdo = $this->createMock(PDO::class);
|
||||
$pdoStatement = $this->createMock(PDOStatement::class);
|
||||
$query = $this->createMock($queryType);
|
||||
|
||||
$query->expects($this->atLeast($times))
|
||||
->method('getStatement')
|
||||
->willReturn('test_query');
|
||||
|
||||
if ($useValues) {
|
||||
$query->expects($this->exactly($times))
|
||||
->method('getBindValues')
|
||||
->willReturn(['a' => 'test', 'b' => 100, 'c' => false]);
|
||||
|
||||
$counter = new InvokedCount(3 * $times);
|
||||
$pdoStatement->expects($counter)
|
||||
->method('bindValue')
|
||||
->with(
|
||||
self::callback(static function (string $arg) use ($counter) {
|
||||
return match ($counter->numberOfInvocations()) {
|
||||
1, 4 => $arg === 'a',
|
||||
2, 5 => $arg === 'b',
|
||||
3, 6 => $arg === 'c',
|
||||
};
|
||||
}),
|
||||
self::callback(static function (mixed $arg) use ($counter) {
|
||||
return match ($counter->numberOfInvocations()) {
|
||||
1, 4 => $arg === 'test',
|
||||
2, 5 => $arg === 100,
|
||||
3, 6 => $arg === false,
|
||||
};
|
||||
}),
|
||||
self::callback(static function (int $arg) use ($counter) {
|
||||
return match ($counter->numberOfInvocations()) {
|
||||
1, 4 => $arg === PDO::PARAM_STR,
|
||||
2, 5 => $arg === PDO::PARAM_INT,
|
||||
3, 6 => $arg === PDO::PARAM_BOOL,
|
||||
};
|
||||
}),
|
||||
);
|
||||
} else {
|
||||
$query->expects($this->exactly($times))
|
||||
->method('getBindValues')
|
||||
->willReturn([]);
|
||||
|
||||
$pdoStatement->expects($this->never())
|
||||
->method('bindValue');
|
||||
}
|
||||
|
||||
$pdo->expects($this->exactly($times))
|
||||
->method('prepare')
|
||||
->with('test_query', $prepareOptions)
|
||||
->willReturn($pdoStatement);
|
||||
|
||||
$pdoStatement->expects($this->exactly($times))
|
||||
->method('execute');
|
||||
|
||||
$this->dbStorageHandler
|
||||
->expects($this->exactly($times))
|
||||
->method('getConnection')
|
||||
->willReturn($pdo);
|
||||
|
||||
$pdo->expects($this->exactly($times))
|
||||
->method('lastInsertId')
|
||||
->willReturn('123');
|
||||
|
||||
return array($pdoStatement, $query);
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws Exception
|
||||
* @throws ConstraintException
|
||||
* @throws QueryException
|
||||
*/
|
||||
public function testRunQueryWithNoMappedClass()
|
||||
{
|
||||
list($pdoStatement, $query) = $this->checkPrepare();
|
||||
|
||||
$pdoStatement->expects($this->once())
|
||||
->method('fetchAll')
|
||||
->with(PDO::FETCH_DEFAULT);
|
||||
|
||||
$queryData = $this->createMock(QueryDataInterface::class);
|
||||
|
||||
$queryData->expects($this->once())
|
||||
->method('getQuery')
|
||||
->willReturn($query);
|
||||
|
||||
$queryData->expects($this->once())
|
||||
->method('getMapClassName');
|
||||
|
||||
$this->database->runQuery($queryData);
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws Exception
|
||||
* @throws ConstraintException
|
||||
* @throws QueryException
|
||||
*/
|
||||
public function testRunQueryWithMappedClassAndFullCount()
|
||||
{
|
||||
/** @var QueryInterface|MockObject $query */
|
||||
/** @var PDO|MockObject $pdoStatement */
|
||||
list($pdoStatement, $query) = $this->checkPrepare(times: 2);
|
||||
|
||||
$pdoStatement->expects($this->once())
|
||||
->method('fetchAll')
|
||||
->with(PDO::FETCH_CLASS | PDO::FETCH_PROPS_LATE, Simple::class);
|
||||
|
||||
$queryData = $this->createMock(QueryDataInterface::class);
|
||||
|
||||
$queryData->expects($this->once())
|
||||
->method('getQuery')
|
||||
->willReturn($query);
|
||||
|
||||
$queryData->expects($this->once())
|
||||
->method('getMapClassName')
|
||||
->willReturn(Simple::class);
|
||||
|
||||
$queryData->expects($this->once())
|
||||
->method('getQueryCount')
|
||||
->willReturn($query);
|
||||
|
||||
$pdoStatement->expects($this->once())
|
||||
->method('fetchColumn')
|
||||
->willReturn(10);
|
||||
|
||||
$this->database->runQuery($queryData, true);
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws Exception
|
||||
* @throws ConstraintException
|
||||
* @throws QueryException
|
||||
*/
|
||||
public function testRunQueryWithNoSelect()
|
||||
{
|
||||
list($pdoStatement, $query) = $this->checkPrepare(QueryInterface::class);
|
||||
|
||||
$queryData = $this->createMock(QueryDataInterface::class);
|
||||
|
||||
$queryData->expects($this->once())
|
||||
->method('getQuery')
|
||||
->willReturn($query);
|
||||
|
||||
$queryData->expects($this->never())
|
||||
->method('getMapClassName');
|
||||
|
||||
$pdoStatement->expects($this->never())
|
||||
->method('fetchAll');
|
||||
|
||||
$pdoStatement->expects($this->once())
|
||||
->method('rowCount')
|
||||
->willReturn(10);
|
||||
|
||||
$out = $this->database->runQuery($queryData);
|
||||
|
||||
$this->assertEquals(10, $out->getAffectedNumRows());
|
||||
$this->assertEquals('123', $out->getLastId());
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws Exception
|
||||
* @throws ConstraintException
|
||||
* @throws QueryException
|
||||
*/
|
||||
public function testRunQueryWithNoValues()
|
||||
{
|
||||
list($pdoStatement, $query) = $this->checkPrepare(QueryInterface::class, false);
|
||||
|
||||
$queryData = $this->createMock(QueryDataInterface::class);
|
||||
|
||||
$queryData->expects($this->once())
|
||||
->method('getQuery')
|
||||
->willReturn($query);
|
||||
|
||||
$queryData->expects($this->never())
|
||||
->method('getMapClassName');
|
||||
|
||||
$pdoStatement->expects($this->never())
|
||||
->method('fetchAll');
|
||||
|
||||
$pdoStatement->expects($this->once())
|
||||
->method('rowCount')
|
||||
->willReturn(10);
|
||||
|
||||
$out = $this->database->runQuery($queryData);
|
||||
|
||||
$this->assertEquals(10, $out->getAffectedNumRows());
|
||||
$this->assertEquals('123', $out->getLastId());
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws Exception
|
||||
*/
|
||||
public function testEndTransaction()
|
||||
{
|
||||
$pdo = $this->createMock(PDO::class);
|
||||
|
||||
$this->dbStorageHandler
|
||||
->expects($this->once())
|
||||
->method('getConnection')
|
||||
->willReturn($pdo);
|
||||
|
||||
$pdo->expects($this->once())
|
||||
->method('inTransaction')
|
||||
->willReturn(true);
|
||||
|
||||
$pdo->expects($this->once())
|
||||
->method('commit')
|
||||
->willReturn(true);
|
||||
|
||||
self::assertTrue($this->database->endTransaction());
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws Exception
|
||||
*/
|
||||
public function testEndTransactionWithNoExistingTransaction()
|
||||
{
|
||||
$pdo = $this->createMock(PDO::class);
|
||||
|
||||
$this->dbStorageHandler
|
||||
->expects($this->once())
|
||||
->method('getConnection')
|
||||
->willReturn($pdo);
|
||||
|
||||
$pdo->expects($this->once())
|
||||
->method('inTransaction')
|
||||
->willReturn(false);
|
||||
|
||||
$pdo->expects($this->never())
|
||||
->method('commit');
|
||||
|
||||
self::assertFalse($this->database->endTransaction());
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws Exception
|
||||
* @throws ConstraintException
|
||||
* @throws QueryException
|
||||
*/
|
||||
#[DataProvider('bufferedDataProvider')]
|
||||
public function testDoFetchWithOptions(bool $buffered)
|
||||
{
|
||||
$this->dbStorageHandler
|
||||
->expects($this->once())
|
||||
->method('getDriver')
|
||||
->willReturn(DbStorageDriver::mysql);
|
||||
|
||||
/** @var PDOStatement|MockObject $pdoStatement */
|
||||
/** @var QueryInterface|MockObject $query */
|
||||
list($pdoStatement, $query) = $this->checkPrepare(
|
||||
QueryInterface::class,
|
||||
false,
|
||||
1,
|
||||
[PDO::MYSQL_ATTR_USE_BUFFERED_QUERY => $buffered]
|
||||
);
|
||||
|
||||
$queryData = $this->createMock(QueryDataInterface::class);
|
||||
|
||||
$queryData->expects($this->once())
|
||||
->method('getQuery')
|
||||
->willReturn($query);
|
||||
|
||||
$pdoStatement->expects($this->exactly(2))
|
||||
->method('fetch')
|
||||
->with(PDO::FETCH_DEFAULT)
|
||||
->willReturn(['a', 1, false], false);
|
||||
|
||||
$out = $this->database->doFetchWithOptions(queryData: $queryData, buffered: $buffered);
|
||||
|
||||
foreach ($out as $row) {
|
||||
$this->assertEquals($row, ['a', 1, false]);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws Exception
|
||||
*/
|
||||
public function testRollbackTransaction()
|
||||
{
|
||||
$pdo = $this->createMock(PDO::class);
|
||||
|
||||
$this->dbStorageHandler
|
||||
->expects($this->once())
|
||||
->method('getConnection')
|
||||
->willReturn($pdo);
|
||||
|
||||
$pdo->expects($this->once())
|
||||
->method('inTransaction')
|
||||
->willReturn(true);
|
||||
|
||||
$pdo->expects($this->once())
|
||||
->method('rollBack')
|
||||
->willReturn(true);
|
||||
|
||||
self::assertTrue($this->database->rollbackTransaction());
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws Exception
|
||||
*/
|
||||
public function testRollbackTransactionWithNoTransaction()
|
||||
{
|
||||
$pdo = $this->createMock(PDO::class);
|
||||
|
||||
$this->dbStorageHandler
|
||||
->expects($this->once())
|
||||
->method('getConnection')
|
||||
->willReturn($pdo);
|
||||
|
||||
$pdo->expects($this->once())
|
||||
->method('inTransaction')
|
||||
->willReturn(false);
|
||||
|
||||
$pdo->expects($this->never())
|
||||
->method('rollBack');
|
||||
|
||||
self::assertFalse($this->database->rollbackTransaction());
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws Exception
|
||||
*/
|
||||
public function testRollbackTransactionWithNoRollback()
|
||||
{
|
||||
$pdo = $this->createMock(PDO::class);
|
||||
|
||||
$this->dbStorageHandler
|
||||
->expects($this->once())
|
||||
->method('getConnection')
|
||||
->willReturn($pdo);
|
||||
|
||||
$pdo->expects($this->once())
|
||||
->method('inTransaction')
|
||||
->willReturn(true);
|
||||
|
||||
$pdo->expects($this->once())
|
||||
->method('rollBack')
|
||||
->willReturn(false);
|
||||
|
||||
self::assertFalse($this->database->rollbackTransaction());
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws Exception
|
||||
* @throws QueryException
|
||||
*/
|
||||
public function testRunQueryRaw()
|
||||
{
|
||||
$pdo = $this->createMock(PDO::class);
|
||||
|
||||
$this->dbStorageHandler
|
||||
->expects($this->once())
|
||||
->method('getConnection')
|
||||
->willReturn($pdo);
|
||||
|
||||
$pdo->expects($this->once())
|
||||
->method('exec')
|
||||
->with('a_query')
|
||||
->willReturn(1);
|
||||
|
||||
$this->database->runQueryRaw('a_query');
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws Exception
|
||||
* @throws QueryException
|
||||
*/
|
||||
public function testRunQueryRawWithException()
|
||||
{
|
||||
$pdo = $this->createMock(PDO::class);
|
||||
|
||||
$this->dbStorageHandler
|
||||
->expects($this->once())
|
||||
->method('getConnection')
|
||||
->willReturn($pdo);
|
||||
|
||||
$pdo->expects($this->once())
|
||||
->method('exec')
|
||||
->with('a_query')
|
||||
->willReturn(false);
|
||||
|
||||
$this->expectException(QueryException::class);
|
||||
$this->expectExceptionMessage('Error executing the query');
|
||||
|
||||
$this->database->runQueryRaw('a_query');
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws ConstraintException
|
||||
* @throws Exception
|
||||
* @throws QueryException
|
||||
*/
|
||||
public function testRunQueryWithEmptyQueryException()
|
||||
{
|
||||
$query = $this->createStub(QueryInterface::class);
|
||||
$queryData = $this->createStub(QueryDataInterface::class);
|
||||
$queryData->method('getOnErrorMessage')
|
||||
->willReturn('an_error');
|
||||
|
||||
$query->method('getStatement')
|
||||
->willReturn('');
|
||||
|
||||
$queryData->method('getQuery')
|
||||
->willReturn($query);
|
||||
|
||||
$this->expectException(QueryException::class);
|
||||
$this->expectExceptionMessage('an_error');
|
||||
|
||||
$this->database->runQuery($queryData);
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws ConstraintException
|
||||
* @throws Exception
|
||||
* @throws QueryException
|
||||
*/
|
||||
public function testRunQueryWithConnectionException()
|
||||
{
|
||||
$query = $this->createStub(QueryInterface::class);
|
||||
$queryData = $this->createStub(QueryDataInterface::class);
|
||||
$queryData->method('getOnErrorMessage')
|
||||
->willReturn('an_error');
|
||||
|
||||
$query->method('getStatement')
|
||||
->willReturn('test_query');
|
||||
|
||||
$queryData->method('getQuery')
|
||||
->willReturn($query);
|
||||
|
||||
$this->dbStorageHandler
|
||||
->method('getConnection')
|
||||
->willThrowException(new RuntimeException('test'));
|
||||
|
||||
$this->expectException(QueryException::class);
|
||||
$this->expectExceptionMessage('test');
|
||||
|
||||
$this->database->runQuery($queryData);
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws ConstraintException
|
||||
* @throws Exception
|
||||
* @throws QueryException
|
||||
*/
|
||||
public function testRunQueryWithPrepareException()
|
||||
{
|
||||
$pdo = $this->createStub(PDO::class);
|
||||
$query = $this->createStub(QueryInterface::class);
|
||||
$queryData = $this->createStub(QueryDataInterface::class);
|
||||
|
||||
$queryData->method('getOnErrorMessage')
|
||||
->willReturn('an_error');
|
||||
|
||||
$query->method('getStatement')
|
||||
->willReturn('test_query');
|
||||
|
||||
$queryData->method('getQuery')
|
||||
->willReturn($query);
|
||||
|
||||
$this->dbStorageHandler
|
||||
->method('getConnection')
|
||||
->willReturn($pdo);
|
||||
|
||||
$pdo->method('prepare')
|
||||
->willThrowException(new RuntimeException('test'));
|
||||
|
||||
$this->expectException(QueryException::class);
|
||||
$this->expectExceptionMessage('test');
|
||||
|
||||
$this->database->runQuery($queryData);
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws ConstraintException
|
||||
* @throws Exception
|
||||
* @throws QueryException
|
||||
*/
|
||||
public function testRunQueryWithExecuteException()
|
||||
{
|
||||
$pdo = $this->createStub(PDO::class);
|
||||
$pdoStatement = $this->createStub(PDOStatement::class);
|
||||
$query = $this->createStub(QueryInterface::class);
|
||||
$queryData = $this->createStub(QueryDataInterface::class);
|
||||
|
||||
$queryData->method('getOnErrorMessage')
|
||||
->willReturn('an_error');
|
||||
|
||||
$query->method('getStatement')
|
||||
->willReturn('test_query');
|
||||
|
||||
$queryData->method('getQuery')
|
||||
->willReturn($query);
|
||||
|
||||
$this->dbStorageHandler
|
||||
->method('getConnection')
|
||||
->willReturn($pdo);
|
||||
|
||||
$pdo->method('prepare')
|
||||
->willReturn($pdoStatement);
|
||||
|
||||
$pdoStatement->method('execute')
|
||||
->willThrowException(new RuntimeException('test'));
|
||||
|
||||
$this->expectException(QueryException::class);
|
||||
$this->expectExceptionMessage('test');
|
||||
|
||||
$this->database->runQuery($queryData);
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws ConstraintException
|
||||
* @throws Exception
|
||||
* @throws QueryException
|
||||
*/
|
||||
public function testRunQueryWithConstraintException()
|
||||
{
|
||||
$pdo = $this->createStub(PDO::class);
|
||||
$pdoStatement = $this->createStub(PDOStatement::class);
|
||||
$query = $this->createStub(QueryInterface::class);
|
||||
$queryData = $this->createStub(QueryDataInterface::class);
|
||||
|
||||
$queryData->method('getOnErrorMessage')
|
||||
->willReturn('an_error');
|
||||
|
||||
$query->method('getStatement')
|
||||
->willReturn('test_query');
|
||||
|
||||
$queryData->method('getQuery')
|
||||
->willReturn($query);
|
||||
|
||||
$this->dbStorageHandler
|
||||
->method('getConnection')
|
||||
->willReturn($pdo);
|
||||
|
||||
$pdo->method('prepare')
|
||||
->willReturn($pdoStatement);
|
||||
|
||||
$pdoStatement->method('execute')
|
||||
->willThrowException(new RuntimeException('test', 23000));
|
||||
|
||||
$this->expectException(ConstraintException::class);
|
||||
$this->expectExceptionMessage('Integrity constraint');
|
||||
$this->expectExceptionCode(23000);
|
||||
|
||||
$this->database->runQuery($queryData);
|
||||
}
|
||||
|
||||
protected function setUp(): void
|
||||
{
|
||||
parent::setUp();
|
||||
|
||||
$this->dbStorageHandler = $this->createMock(DbStorageHandler::class);
|
||||
|
||||
$this->database = new Database($this->dbStorageHandler, $this->application->getEventDispatcher());
|
||||
}
|
||||
}
|
||||
@@ -77,7 +77,7 @@ class ItemPresetTest extends UnitaryTestCase
|
||||
|
||||
$this->database
|
||||
->expects(self::once())
|
||||
->method('doSelect')
|
||||
->method('runQuery')
|
||||
->with($callback, false);
|
||||
|
||||
$this->itemPreset->getByFilter('test', 100, 200, 300);
|
||||
@@ -101,7 +101,7 @@ class ItemPresetTest extends UnitaryTestCase
|
||||
}
|
||||
);
|
||||
|
||||
$this->database->expects(self::once())->method('doQuery')->with($callback);
|
||||
$this->database->expects(self::once())->method('runQuery')->with($callback);
|
||||
|
||||
$this->itemPreset->delete($id);
|
||||
}
|
||||
@@ -119,7 +119,7 @@ class ItemPresetTest extends UnitaryTestCase
|
||||
|
||||
$this->database
|
||||
->expects(self::once())
|
||||
->method('doSelect')
|
||||
->method('runQuery')
|
||||
->with($callback);
|
||||
|
||||
$this->itemPreset->getAll();
|
||||
@@ -153,7 +153,7 @@ class ItemPresetTest extends UnitaryTestCase
|
||||
|
||||
$this->database
|
||||
->expects(self::exactly(1))
|
||||
->method('doQuery')
|
||||
->method('runQuery')
|
||||
->with($callbackCreate)
|
||||
->willReturn(new QueryResult([]));
|
||||
|
||||
@@ -187,13 +187,11 @@ class ItemPresetTest extends UnitaryTestCase
|
||||
}
|
||||
);
|
||||
|
||||
$queryResult = new QueryResult([]);
|
||||
|
||||
$this->database
|
||||
->expects(self::exactly(1))
|
||||
->method('doQuery')
|
||||
->method('runQuery')
|
||||
->with($callbackCreate)
|
||||
->willReturn($queryResult->setAffectedNumRows(1));
|
||||
->willReturn(new QueryResult(null, 1));
|
||||
|
||||
$out = $this->itemPreset->update($itemPreset);
|
||||
|
||||
@@ -227,7 +225,7 @@ class ItemPresetTest extends UnitaryTestCase
|
||||
|
||||
$this->database
|
||||
->expects(self::once())
|
||||
->method('doSelect')
|
||||
->method('runQuery')
|
||||
->with($callback, true);
|
||||
|
||||
$this->itemPreset->search($item);
|
||||
@@ -250,7 +248,7 @@ class ItemPresetTest extends UnitaryTestCase
|
||||
|
||||
$this->database
|
||||
->expects(self::once())
|
||||
->method('doSelect')
|
||||
->method('runQuery')
|
||||
->with($callback, true);
|
||||
|
||||
$this->itemPreset->search(new ItemSearchData());
|
||||
@@ -281,7 +279,7 @@ class ItemPresetTest extends UnitaryTestCase
|
||||
|
||||
$this->database
|
||||
->expects(self::once())
|
||||
->method('doQuery')
|
||||
->method('runQuery')
|
||||
->with($callback);
|
||||
|
||||
$this->itemPreset->deleteByIdBatch($ids);
|
||||
@@ -295,7 +293,7 @@ class ItemPresetTest extends UnitaryTestCase
|
||||
{
|
||||
$this->database
|
||||
->expects(self::never())
|
||||
->method('doQuery');
|
||||
->method('runQuery');
|
||||
|
||||
$this->itemPreset->deleteByIdBatch([]);
|
||||
}
|
||||
@@ -319,7 +317,7 @@ class ItemPresetTest extends UnitaryTestCase
|
||||
|
||||
$this->database
|
||||
->expects(self::once())
|
||||
->method('doSelect')
|
||||
->method('runQuery')
|
||||
->with($callback);
|
||||
|
||||
$this->itemPreset->getById($id);
|
||||
|
||||
@@ -74,7 +74,7 @@ class NotificationTest extends UnitaryTestCase
|
||||
|
||||
$this->database
|
||||
->expects(self::once())
|
||||
->method('doSelect')
|
||||
->method('runQuery')
|
||||
->with($callback);
|
||||
|
||||
$this->notification->getByIdBatch($ids);
|
||||
@@ -97,7 +97,7 @@ class NotificationTest extends UnitaryTestCase
|
||||
|
||||
$this->database
|
||||
->expects(self::once())
|
||||
->method('doSelect')
|
||||
->method('runQuery')
|
||||
->with($callback);
|
||||
|
||||
$this->notification->getAllActiveForAdmin(100);
|
||||
@@ -120,7 +120,7 @@ class NotificationTest extends UnitaryTestCase
|
||||
|
||||
$this->database
|
||||
->expects(self::once())
|
||||
->method('doSelect')
|
||||
->method('runQuery')
|
||||
->with($callback);
|
||||
|
||||
$this->notification->getAllForUserId(100);
|
||||
@@ -144,7 +144,7 @@ class NotificationTest extends UnitaryTestCase
|
||||
}
|
||||
);
|
||||
|
||||
$this->database->expects(self::once())->method('doQuery')->with($callback);
|
||||
$this->database->expects(self::once())->method('runQuery')->with($callback);
|
||||
|
||||
$this->notification->delete($id);
|
||||
}
|
||||
@@ -177,13 +177,11 @@ class NotificationTest extends UnitaryTestCase
|
||||
}
|
||||
);
|
||||
|
||||
$queryResult = new QueryResult([]);
|
||||
|
||||
$this->database
|
||||
->expects(self::exactly(1))
|
||||
->method('doQuery')
|
||||
->method('runQuery')
|
||||
->with($callbackCreate)
|
||||
->willReturn($queryResult->setAffectedNumRows(1));
|
||||
->willReturn(new QueryResult(null, 1));
|
||||
|
||||
$out = $this->notification->update($notification);
|
||||
|
||||
@@ -209,13 +207,11 @@ class NotificationTest extends UnitaryTestCase
|
||||
}
|
||||
);
|
||||
|
||||
$queryResult = new QueryResult([]);
|
||||
|
||||
$this->database
|
||||
->expects(self::exactly(1))
|
||||
->method('doQuery')
|
||||
->method('runQuery')
|
||||
->with($callbackCreate)
|
||||
->willReturn($queryResult->setAffectedNumRows(1));
|
||||
->willReturn(new QueryResult(null, 1));
|
||||
|
||||
$out = $this->notification->setCheckedById(100);
|
||||
|
||||
@@ -239,7 +235,7 @@ class NotificationTest extends UnitaryTestCase
|
||||
|
||||
$this->database
|
||||
->expects(self::once())
|
||||
->method('doSelect')
|
||||
->method('runQuery')
|
||||
->with($callback);
|
||||
|
||||
$this->notification->getAllForUserId(100);
|
||||
@@ -270,7 +266,7 @@ class NotificationTest extends UnitaryTestCase
|
||||
|
||||
$this->database
|
||||
->expects(self::once())
|
||||
->method('doQuery')
|
||||
->method('runQuery')
|
||||
->with($callback);
|
||||
|
||||
$this->notification->deleteAdminBatch($ids);
|
||||
@@ -304,7 +300,7 @@ class NotificationTest extends UnitaryTestCase
|
||||
|
||||
$this->database
|
||||
->expects(self::exactly(1))
|
||||
->method('doQuery')
|
||||
->method('runQuery')
|
||||
->with($callbackCreate)
|
||||
->willReturn(new QueryResult([]));
|
||||
|
||||
@@ -329,7 +325,7 @@ class NotificationTest extends UnitaryTestCase
|
||||
}
|
||||
);
|
||||
|
||||
$this->database->expects(self::once())->method('doQuery')->with($callback);
|
||||
$this->database->expects(self::once())->method('runQuery')->with($callback);
|
||||
|
||||
$this->notification->deleteAdmin($id);
|
||||
}
|
||||
@@ -351,7 +347,7 @@ class NotificationTest extends UnitaryTestCase
|
||||
|
||||
$this->database
|
||||
->expects(self::once())
|
||||
->method('doSelect')
|
||||
->method('runQuery')
|
||||
->with($callback);
|
||||
|
||||
$this->notification->getById(100);
|
||||
@@ -382,7 +378,7 @@ class NotificationTest extends UnitaryTestCase
|
||||
|
||||
$this->database
|
||||
->expects(self::once())
|
||||
->method('doQuery')
|
||||
->method('runQuery')
|
||||
->with($callback);
|
||||
|
||||
$this->notification->deleteByIdBatch($ids);
|
||||
@@ -410,7 +406,7 @@ class NotificationTest extends UnitaryTestCase
|
||||
|
||||
$this->database
|
||||
->expects(self::once())
|
||||
->method('doSelect')
|
||||
->method('runQuery')
|
||||
->with($callback, true);
|
||||
|
||||
$this->notification->searchForUserId($item, 100);
|
||||
@@ -438,7 +434,7 @@ class NotificationTest extends UnitaryTestCase
|
||||
|
||||
$this->database
|
||||
->expects(self::once())
|
||||
->method('doSelect')
|
||||
->method('runQuery')
|
||||
->with($callback, true);
|
||||
|
||||
$this->notification->searchForAdmin($item, 100);
|
||||
@@ -458,7 +454,7 @@ class NotificationTest extends UnitaryTestCase
|
||||
|
||||
$this->database
|
||||
->expects(self::once())
|
||||
->method('doSelect')
|
||||
->method('runQuery')
|
||||
->with($callback);
|
||||
|
||||
$this->notification->getAll();
|
||||
@@ -482,7 +478,7 @@ class NotificationTest extends UnitaryTestCase
|
||||
|
||||
$this->database
|
||||
->expects(self::once())
|
||||
->method('doSelect')
|
||||
->method('runQuery')
|
||||
->with($callback);
|
||||
|
||||
$this->notification->getForUserIdByDate('test', 100);
|
||||
|
||||
@@ -65,7 +65,7 @@ class PluginDataTest extends UnitaryTestCase
|
||||
|
||||
$this->database
|
||||
->expects(self::once())
|
||||
->method('doSelect')
|
||||
->method('runQuery')
|
||||
->with($callback);
|
||||
|
||||
$this->pluginData->getAll();
|
||||
@@ -90,7 +90,7 @@ class PluginDataTest extends UnitaryTestCase
|
||||
}
|
||||
);
|
||||
|
||||
$this->database->expects(self::once())->method('doQuery')->with($callback);
|
||||
$this->database->expects(self::once())->method('runQuery')->with($callback);
|
||||
|
||||
$this->pluginData->deleteByItemId('test_name', 200);
|
||||
}
|
||||
@@ -113,7 +113,7 @@ class PluginDataTest extends UnitaryTestCase
|
||||
}
|
||||
);
|
||||
|
||||
$this->database->expects(self::once())->method('doQuery')->with($callback);
|
||||
$this->database->expects(self::once())->method('runQuery')->with($callback);
|
||||
|
||||
$this->pluginData->delete('test_name');
|
||||
}
|
||||
@@ -143,7 +143,7 @@ class PluginDataTest extends UnitaryTestCase
|
||||
|
||||
$this->database
|
||||
->expects(self::exactly(1))
|
||||
->method('doQuery')
|
||||
->method('runQuery')
|
||||
->with($callbackCreate)
|
||||
->willReturn(new QueryResult([]));
|
||||
|
||||
@@ -173,13 +173,11 @@ class PluginDataTest extends UnitaryTestCase
|
||||
}
|
||||
);
|
||||
|
||||
$queryResult = new QueryResult([]);
|
||||
|
||||
$this->database
|
||||
->expects(self::exactly(1))
|
||||
->method('doQuery')
|
||||
->method('runQuery')
|
||||
->with($callbackCreate)
|
||||
->willReturn($queryResult->setAffectedNumRows(1));
|
||||
->willReturn(new QueryResult(null, 1));
|
||||
|
||||
$out = $this->pluginData->update($pluginData);
|
||||
|
||||
@@ -207,7 +205,7 @@ class PluginDataTest extends UnitaryTestCase
|
||||
|
||||
$this->database
|
||||
->expects(self::once())
|
||||
->method('doSelect')
|
||||
->method('runQuery')
|
||||
->with($callback);
|
||||
|
||||
$this->pluginData->getByNameBatch($names);
|
||||
@@ -217,7 +215,7 @@ class PluginDataTest extends UnitaryTestCase
|
||||
{
|
||||
$this->database
|
||||
->expects(self::never())
|
||||
->method('doSelect');
|
||||
->method('runQuery');
|
||||
|
||||
$this->pluginData->getByNameBatch([]);
|
||||
}
|
||||
@@ -247,7 +245,7 @@ class PluginDataTest extends UnitaryTestCase
|
||||
|
||||
$this->database
|
||||
->expects(self::once())
|
||||
->method('doQuery')
|
||||
->method('runQuery')
|
||||
->with($callback);
|
||||
|
||||
$this->pluginData->deleteByNameBatch($names);
|
||||
@@ -261,7 +259,7 @@ class PluginDataTest extends UnitaryTestCase
|
||||
{
|
||||
$this->database
|
||||
->expects(self::never())
|
||||
->method('doQuery');
|
||||
->method('runQuery');
|
||||
|
||||
$this->pluginData->deleteByNameBatch([]);
|
||||
}
|
||||
@@ -284,7 +282,7 @@ class PluginDataTest extends UnitaryTestCase
|
||||
|
||||
$this->database
|
||||
->expects(self::once())
|
||||
->method('doSelect')
|
||||
->method('runQuery')
|
||||
->with($callback);
|
||||
|
||||
$this->pluginData->getByItemId('test_name', 100);
|
||||
@@ -307,7 +305,7 @@ class PluginDataTest extends UnitaryTestCase
|
||||
|
||||
$this->database
|
||||
->expects(self::once())
|
||||
->method('doSelect')
|
||||
->method('runQuery')
|
||||
->with($callback);
|
||||
|
||||
$this->pluginData->getByName('test_name');
|
||||
|
||||
@@ -73,13 +73,11 @@ class PluginTest extends UnitaryTestCase
|
||||
}
|
||||
);
|
||||
|
||||
$queryResult = new QueryResult([]);
|
||||
|
||||
$this->database
|
||||
->expects(self::exactly(1))
|
||||
->method('doQuery')
|
||||
->method('runQuery')
|
||||
->with($callbackCreate)
|
||||
->willReturn($queryResult->setAffectedNumRows(1));
|
||||
->willReturn(new QueryResult(null, 1));
|
||||
|
||||
$out = $this->plugin->toggleAvailableByName('test_name', true);
|
||||
|
||||
@@ -105,13 +103,11 @@ class PluginTest extends UnitaryTestCase
|
||||
}
|
||||
);
|
||||
|
||||
$queryResult = new QueryResult([]);
|
||||
|
||||
$this->database
|
||||
->expects(self::exactly(1))
|
||||
->method('doQuery')
|
||||
->method('runQuery')
|
||||
->with($callbackCreate)
|
||||
->willReturn($queryResult->setAffectedNumRows(1));
|
||||
->willReturn(new QueryResult(null, 1));
|
||||
|
||||
$out = $this->plugin->toggleEnabledByName('test_name', true);
|
||||
|
||||
@@ -142,13 +138,11 @@ class PluginTest extends UnitaryTestCase
|
||||
}
|
||||
);
|
||||
|
||||
$queryResult = new QueryResult([]);
|
||||
|
||||
$this->database
|
||||
->expects(self::exactly(1))
|
||||
->method('doQuery')
|
||||
->method('runQuery')
|
||||
->with($callbackCreate)
|
||||
->willReturn($queryResult->setAffectedNumRows(1));
|
||||
->willReturn(new QueryResult(null, 1));
|
||||
|
||||
$out = $this->plugin->update($plugin);
|
||||
|
||||
@@ -174,13 +168,11 @@ class PluginTest extends UnitaryTestCase
|
||||
}
|
||||
);
|
||||
|
||||
$queryResult = new QueryResult([]);
|
||||
|
||||
$this->database
|
||||
->expects(self::exactly(1))
|
||||
->method('doQuery')
|
||||
->method('runQuery')
|
||||
->with($callbackCreate)
|
||||
->willReturn($queryResult->setAffectedNumRows(1));
|
||||
->willReturn(new QueryResult(null, 1));
|
||||
|
||||
$out = $this->plugin->toggleEnabled(100, true);
|
||||
|
||||
@@ -203,7 +195,7 @@ class PluginTest extends UnitaryTestCase
|
||||
|
||||
$this->database
|
||||
->expects(self::once())
|
||||
->method('doSelect')
|
||||
->method('runQuery')
|
||||
->with($callback);
|
||||
|
||||
$this->plugin->getEnabled();
|
||||
@@ -235,7 +227,7 @@ class PluginTest extends UnitaryTestCase
|
||||
|
||||
$this->database
|
||||
->expects(self::once())
|
||||
->method('doQuery')
|
||||
->method('runQuery')
|
||||
->with($callback);
|
||||
|
||||
$this->plugin->deleteByIdBatch($ids);
|
||||
@@ -261,13 +253,11 @@ class PluginTest extends UnitaryTestCase
|
||||
}
|
||||
);
|
||||
|
||||
$queryResult = new QueryResult([]);
|
||||
|
||||
$this->database
|
||||
->expects(self::exactly(1))
|
||||
->method('doQuery')
|
||||
->method('runQuery')
|
||||
->with($callbackCreate)
|
||||
->willReturn($queryResult->setAffectedNumRows(1));
|
||||
->willReturn(new QueryResult(null, 1));
|
||||
|
||||
$out = $this->plugin->toggleAvailable(100, true);
|
||||
|
||||
@@ -294,7 +284,7 @@ class PluginTest extends UnitaryTestCase
|
||||
|
||||
$this->database
|
||||
->expects(self::once())
|
||||
->method('doSelect')
|
||||
->method('runQuery')
|
||||
->with($callback, true);
|
||||
|
||||
$this->plugin->search($item);
|
||||
@@ -319,7 +309,7 @@ class PluginTest extends UnitaryTestCase
|
||||
|
||||
$this->database
|
||||
->expects(self::once())
|
||||
->method('doSelect')
|
||||
->method('runQuery')
|
||||
->with($callback, true);
|
||||
|
||||
$this->plugin->search($item);
|
||||
@@ -339,7 +329,7 @@ class PluginTest extends UnitaryTestCase
|
||||
|
||||
$this->database
|
||||
->expects(self::once())
|
||||
->method('doSelect')
|
||||
->method('runQuery')
|
||||
->with($callback);
|
||||
|
||||
$this->plugin->getAll();
|
||||
@@ -364,13 +354,11 @@ class PluginTest extends UnitaryTestCase
|
||||
}
|
||||
);
|
||||
|
||||
$queryResult = new QueryResult([]);
|
||||
|
||||
$this->database
|
||||
->expects(self::exactly(1))
|
||||
->method('doQuery')
|
||||
->method('runQuery')
|
||||
->with($callbackCreate)
|
||||
->willReturn($queryResult->setAffectedNumRows(1));
|
||||
->willReturn(new QueryResult(null, 1));
|
||||
|
||||
$out = $this->plugin->resetById(100);
|
||||
|
||||
@@ -402,7 +390,7 @@ class PluginTest extends UnitaryTestCase
|
||||
|
||||
$this->database
|
||||
->expects(self::exactly(1))
|
||||
->method('doQuery')
|
||||
->method('runQuery')
|
||||
->with($callbackCreate)
|
||||
->willReturn(new QueryResult([]));
|
||||
|
||||
@@ -426,7 +414,7 @@ class PluginTest extends UnitaryTestCase
|
||||
|
||||
$this->database
|
||||
->expects(self::once())
|
||||
->method('doSelect')
|
||||
->method('runQuery')
|
||||
->with($callback);
|
||||
|
||||
$this->plugin->getByName('test_name');
|
||||
@@ -453,7 +441,7 @@ class PluginTest extends UnitaryTestCase
|
||||
|
||||
$this->database
|
||||
->expects(self::once())
|
||||
->method('doSelect')
|
||||
->method('runQuery')
|
||||
->with($callback);
|
||||
|
||||
$this->plugin->getByIdBatch($ids);
|
||||
@@ -476,7 +464,7 @@ class PluginTest extends UnitaryTestCase
|
||||
|
||||
$this->database
|
||||
->expects(self::once())
|
||||
->method('doSelect')
|
||||
->method('runQuery')
|
||||
->with($callback);
|
||||
|
||||
$this->plugin->getById(100);
|
||||
@@ -500,7 +488,7 @@ class PluginTest extends UnitaryTestCase
|
||||
}
|
||||
);
|
||||
|
||||
$this->database->expects(self::once())->method('doQuery')->with($callback);
|
||||
$this->database->expects(self::once())->method('runQuery')->with($callback);
|
||||
|
||||
$this->plugin->delete($id);
|
||||
}
|
||||
|
||||
@@ -68,7 +68,7 @@ class EventlogTest extends UnitaryTestCase
|
||||
}
|
||||
);
|
||||
|
||||
$this->database->expects(self::once())->method('doQuery')->with($callback);
|
||||
$this->database->expects(self::once())->method('runQuery')->with($callback);
|
||||
|
||||
$this->eventlog->clear();
|
||||
}
|
||||
@@ -100,7 +100,7 @@ class EventlogTest extends UnitaryTestCase
|
||||
|
||||
$this->database
|
||||
->expects(self::exactly(1))
|
||||
->method('doQuery')
|
||||
->method('runQuery')
|
||||
->with($callbackCreate)
|
||||
->willReturn(new QueryResult([]));
|
||||
|
||||
@@ -129,7 +129,7 @@ class EventlogTest extends UnitaryTestCase
|
||||
|
||||
$this->database
|
||||
->expects(self::once())
|
||||
->method('doSelect')
|
||||
->method('runQuery')
|
||||
->with($callback, true);
|
||||
|
||||
$this->eventlog->search($item);
|
||||
@@ -154,7 +154,7 @@ class EventlogTest extends UnitaryTestCase
|
||||
|
||||
$this->database
|
||||
->expects(self::once())
|
||||
->method('doSelect')
|
||||
->method('runQuery')
|
||||
->with($callback, true);
|
||||
|
||||
$this->eventlog->search($item);
|
||||
|
||||
@@ -69,7 +69,7 @@ class TrackTest extends UnitaryTestCase
|
||||
}
|
||||
);
|
||||
|
||||
$this->database->expects(self::once())->method('doQuery')->with($callback);
|
||||
$this->database->expects(self::once())->method('runQuery')->with($callback);
|
||||
|
||||
$this->track->clear();
|
||||
}
|
||||
@@ -92,13 +92,11 @@ class TrackTest extends UnitaryTestCase
|
||||
}
|
||||
);
|
||||
|
||||
$queryResult = new QueryResult([]);
|
||||
|
||||
$this->database
|
||||
->expects(self::exactly(1))
|
||||
->method('doQuery')
|
||||
->method('runQuery')
|
||||
->with($callbackCreate)
|
||||
->willReturn($queryResult->setAffectedNumRows(1));
|
||||
->willReturn(new QueryResult(null, 1));
|
||||
|
||||
$out = $this->track->unlock(100);
|
||||
|
||||
@@ -127,7 +125,7 @@ class TrackTest extends UnitaryTestCase
|
||||
|
||||
$this->database
|
||||
->expects(self::once())
|
||||
->method('doSelect')
|
||||
->method('runQuery')
|
||||
->with($callback);
|
||||
|
||||
$this->track->getTracksForClientFromTime($track);
|
||||
@@ -154,7 +152,7 @@ class TrackTest extends UnitaryTestCase
|
||||
|
||||
$this->database
|
||||
->expects(self::once())
|
||||
->method('doSelect')
|
||||
->method('runQuery')
|
||||
->with($callback, true);
|
||||
|
||||
$this->track->search($item, 1000);
|
||||
@@ -179,7 +177,7 @@ class TrackTest extends UnitaryTestCase
|
||||
|
||||
$this->database
|
||||
->expects(self::once())
|
||||
->method('doSelect')
|
||||
->method('runQuery')
|
||||
->with($callback, true);
|
||||
|
||||
$this->track->search($item, 1000);
|
||||
@@ -211,7 +209,7 @@ class TrackTest extends UnitaryTestCase
|
||||
|
||||
$this->database
|
||||
->expects(self::exactly(1))
|
||||
->method('doQuery')
|
||||
->method('runQuery')
|
||||
->with($callbackCreate)
|
||||
->willReturn(new QueryResult([]));
|
||||
|
||||
|
||||
@@ -70,7 +70,7 @@ class TagTest extends UnitaryTestCase
|
||||
|
||||
$this->database
|
||||
->expects(self::once())
|
||||
->method('doSelect')
|
||||
->method('runQuery')
|
||||
->with($callback);
|
||||
|
||||
$this->tag->getAll();
|
||||
@@ -96,7 +96,7 @@ class TagTest extends UnitaryTestCase
|
||||
|
||||
$this->database
|
||||
->expects(self::once())
|
||||
->method('doSelect')
|
||||
->method('runQuery')
|
||||
->with($callback, true);
|
||||
|
||||
$this->tag->search($item);
|
||||
@@ -119,7 +119,7 @@ class TagTest extends UnitaryTestCase
|
||||
|
||||
$this->database
|
||||
->expects(self::once())
|
||||
->method('doSelect')
|
||||
->method('runQuery')
|
||||
->with($callback, true);
|
||||
|
||||
$this->tag->search(new ItemSearchData());
|
||||
@@ -144,7 +144,7 @@ class TagTest extends UnitaryTestCase
|
||||
|
||||
$this->database
|
||||
->expects(self::once())
|
||||
->method('doSelect')
|
||||
->method('runQuery')
|
||||
->with($callback);
|
||||
|
||||
$this->tag->getById($id);
|
||||
@@ -175,7 +175,7 @@ class TagTest extends UnitaryTestCase
|
||||
|
||||
$this->database
|
||||
->expects(self::once())
|
||||
->method('doQuery')
|
||||
->method('runQuery')
|
||||
->with($callback);
|
||||
|
||||
$this->tag->deleteByIdBatch($ids);
|
||||
@@ -189,7 +189,7 @@ class TagTest extends UnitaryTestCase
|
||||
{
|
||||
$this->database
|
||||
->expects(self::never())
|
||||
->method('doQuery');
|
||||
->method('runQuery');
|
||||
|
||||
$this->tag->deleteByIdBatch([]);
|
||||
}
|
||||
@@ -214,7 +214,7 @@ class TagTest extends UnitaryTestCase
|
||||
|
||||
$this->database
|
||||
->expects(self::once())
|
||||
->method('doSelect')
|
||||
->method('runQuery')
|
||||
->with($callback);
|
||||
|
||||
$this->tag->getByName($name);
|
||||
@@ -238,7 +238,7 @@ class TagTest extends UnitaryTestCase
|
||||
}
|
||||
);
|
||||
|
||||
$this->database->expects(self::once())->method('doQuery')->with($callback);
|
||||
$this->database->expects(self::once())->method('runQuery')->with($callback);
|
||||
|
||||
$this->tag->delete($id);
|
||||
}
|
||||
@@ -280,7 +280,7 @@ class TagTest extends UnitaryTestCase
|
||||
|
||||
$this->database
|
||||
->expects(self::exactly(2))
|
||||
->method('doQuery')
|
||||
->method('runQuery')
|
||||
->with(...self::withConsecutive([$callbackDuplicate], [$callbackCreate]))
|
||||
->willReturn(new QueryResult([]), new QueryResult([1]));
|
||||
|
||||
@@ -310,7 +310,7 @@ class TagTest extends UnitaryTestCase
|
||||
|
||||
$this->database
|
||||
->expects(self::once())
|
||||
->method('doQuery')
|
||||
->method('runQuery')
|
||||
->with($callbackDuplicate)
|
||||
->willReturn(new QueryResult([1]));
|
||||
|
||||
@@ -359,7 +359,7 @@ class TagTest extends UnitaryTestCase
|
||||
|
||||
$this->database
|
||||
->expects(self::exactly(2))
|
||||
->method('doQuery')
|
||||
->method('runQuery')
|
||||
->with(...self::withConsecutive([$callbackDuplicate], [$callbackUpdate]))
|
||||
->willReturn(new QueryResult([]), new QueryResult([1]));
|
||||
|
||||
@@ -391,7 +391,7 @@ class TagTest extends UnitaryTestCase
|
||||
|
||||
$this->database
|
||||
->expects(self::once())
|
||||
->method('doQuery')
|
||||
->method('runQuery')
|
||||
->with($callbackDuplicate)
|
||||
->willReturn(new QueryResult([1]));
|
||||
|
||||
|
||||
@@ -92,7 +92,7 @@ class UserGroupTest extends UnitaryTestCase
|
||||
|
||||
$this->database
|
||||
->expects(self::exactly(2))
|
||||
->method('doQuery')
|
||||
->method('runQuery')
|
||||
->with(...self::withConsecutive([$callbackDuplicate], [$callbackCreate]))
|
||||
->willReturn(new QueryResult([]), new QueryResult([1]));
|
||||
|
||||
@@ -122,7 +122,7 @@ class UserGroupTest extends UnitaryTestCase
|
||||
|
||||
$this->database
|
||||
->expects(self::once())
|
||||
->method('doQuery')
|
||||
->method('runQuery')
|
||||
->with($callbackDuplicate)
|
||||
->willReturn(new QueryResult([1]));
|
||||
|
||||
@@ -171,7 +171,7 @@ class UserGroupTest extends UnitaryTestCase
|
||||
|
||||
$this->database
|
||||
->expects(self::exactly(2))
|
||||
->method('doQuery')
|
||||
->method('runQuery')
|
||||
->with(...self::withConsecutive([$callbackDuplicate], [$callbackUpdate]))
|
||||
->willReturn(new QueryResult([]), new QueryResult([1]));
|
||||
|
||||
@@ -202,7 +202,7 @@ class UserGroupTest extends UnitaryTestCase
|
||||
|
||||
$this->database
|
||||
->expects(self::once())
|
||||
->method('doQuery')
|
||||
->method('runQuery')
|
||||
->with($callbackDuplicate)
|
||||
->willReturn(new QueryResult([1]));
|
||||
|
||||
@@ -220,7 +220,7 @@ class UserGroupTest extends UnitaryTestCase
|
||||
{
|
||||
$this->database
|
||||
->expects($this->once())
|
||||
->method('doSelect')
|
||||
->method('runQuery')
|
||||
->with(
|
||||
self::callback(static function (QueryData $queryData) {
|
||||
$params = $queryData->getQuery()->getBindValues();
|
||||
@@ -251,7 +251,7 @@ class UserGroupTest extends UnitaryTestCase
|
||||
}
|
||||
);
|
||||
|
||||
$this->database->expects(self::once())->method('doQuery')->with($callback);
|
||||
$this->database->expects(self::once())->method('runQuery')->with($callback);
|
||||
|
||||
$this->userGroup->delete($id);
|
||||
}
|
||||
@@ -277,7 +277,7 @@ class UserGroupTest extends UnitaryTestCase
|
||||
|
||||
$this->database
|
||||
->expects(self::once())
|
||||
->method('doSelect')
|
||||
->method('runQuery')
|
||||
->with($callback, true);
|
||||
|
||||
$this->userGroup->search($item);
|
||||
@@ -301,7 +301,7 @@ class UserGroupTest extends UnitaryTestCase
|
||||
|
||||
$this->database
|
||||
->expects(self::once())
|
||||
->method('doSelect')
|
||||
->method('runQuery')
|
||||
->with($callback, true);
|
||||
|
||||
$this->userGroup->search($item);
|
||||
@@ -311,7 +311,7 @@ class UserGroupTest extends UnitaryTestCase
|
||||
{
|
||||
$this->database
|
||||
->expects($this->once())
|
||||
->method('doSelect')
|
||||
->method('runQuery')
|
||||
->with(
|
||||
self::callback(static function (QueryData $queryData) {
|
||||
$params = $queryData->getQuery()->getBindValues();
|
||||
@@ -338,7 +338,7 @@ class UserGroupTest extends UnitaryTestCase
|
||||
|
||||
$this->database
|
||||
->expects(self::once())
|
||||
->method('doSelect')
|
||||
->method('runQuery')
|
||||
->with($callback);
|
||||
|
||||
$this->userGroup->getAll();
|
||||
@@ -348,7 +348,7 @@ class UserGroupTest extends UnitaryTestCase
|
||||
{
|
||||
$this->database
|
||||
->expects($this->once())
|
||||
->method('doSelect')
|
||||
->method('runQuery')
|
||||
->with(
|
||||
self::callback(static function (QueryData $queryData) {
|
||||
$params = $queryData->getQuery()->getBindValues();
|
||||
@@ -365,7 +365,7 @@ class UserGroupTest extends UnitaryTestCase
|
||||
{
|
||||
$this->database
|
||||
->expects($this->once())
|
||||
->method('doSelect')
|
||||
->method('runQuery')
|
||||
->with(
|
||||
self::callback(static function (QueryData $queryData) {
|
||||
$params = $queryData->getQuery()->getBindValues();
|
||||
@@ -404,7 +404,7 @@ class UserGroupTest extends UnitaryTestCase
|
||||
|
||||
$this->database
|
||||
->expects(self::once())
|
||||
->method('doQuery')
|
||||
->method('runQuery')
|
||||
->with($callback);
|
||||
|
||||
$this->userGroup->deleteByIdBatch($ids);
|
||||
@@ -418,7 +418,7 @@ class UserGroupTest extends UnitaryTestCase
|
||||
{
|
||||
$this->database
|
||||
->expects(self::never())
|
||||
->method('doQuery');
|
||||
->method('runQuery');
|
||||
|
||||
$this->userGroup->deleteByIdBatch([]);
|
||||
}
|
||||
|
||||
@@ -57,7 +57,7 @@ class UserPassRecoverTest extends UnitaryTestCase
|
||||
|
||||
$this->database
|
||||
->expects($this->once())
|
||||
->method('doSelect')
|
||||
->method('runQuery')
|
||||
->with(
|
||||
self::callback(static function (QueryData $queryData) use ($time) {
|
||||
$params = $queryData->getQuery()->getBindValues();
|
||||
@@ -79,7 +79,7 @@ class UserPassRecoverTest extends UnitaryTestCase
|
||||
|
||||
$this->database
|
||||
->expects($this->once())
|
||||
->method('doSelect')
|
||||
->method('runQuery')
|
||||
->with(
|
||||
self::callback(static function (QueryData $queryData) use ($hash, $time) {
|
||||
$params = $queryData->getQuery()->getBindValues();
|
||||
@@ -117,7 +117,7 @@ class UserPassRecoverTest extends UnitaryTestCase
|
||||
|
||||
$this->database
|
||||
->expects(self::once())
|
||||
->method('doQuery')
|
||||
->method('runQuery')
|
||||
->with($callbackCreate)
|
||||
->willReturn(new QueryResult([1]));
|
||||
|
||||
@@ -146,13 +146,11 @@ class UserPassRecoverTest extends UnitaryTestCase
|
||||
}
|
||||
);
|
||||
|
||||
$queryResult = new QueryResult();
|
||||
|
||||
$this->database
|
||||
->expects(self::once())
|
||||
->method('doQuery')
|
||||
->method('runQuery')
|
||||
->with($callbackUpdate)
|
||||
->willReturn($queryResult->setAffectedNumRows(1));
|
||||
->willReturn(new QueryResult(null, 1));
|
||||
|
||||
$out = $this->userPassRecover->toggleUsedByHash($hash, $time);
|
||||
|
||||
|
||||
@@ -75,7 +75,7 @@ class UserProfileTest extends UnitaryTestCase
|
||||
|
||||
$this->database
|
||||
->expects(self::once())
|
||||
->method('doSelect')
|
||||
->method('runQuery')
|
||||
->with($callback, true);
|
||||
|
||||
$this->userProfile->search($item);
|
||||
@@ -99,7 +99,7 @@ class UserProfileTest extends UnitaryTestCase
|
||||
|
||||
$this->database
|
||||
->expects(self::once())
|
||||
->method('doSelect')
|
||||
->method('runQuery')
|
||||
->with($callback, true);
|
||||
|
||||
$this->userProfile->search($item);
|
||||
@@ -130,7 +130,7 @@ class UserProfileTest extends UnitaryTestCase
|
||||
|
||||
$this->database
|
||||
->expects(self::once())
|
||||
->method('doQuery')
|
||||
->method('runQuery')
|
||||
->with($callback);
|
||||
|
||||
$this->userProfile->deleteByIdBatch($ids);
|
||||
@@ -144,7 +144,7 @@ class UserProfileTest extends UnitaryTestCase
|
||||
{
|
||||
$this->database
|
||||
->expects(self::never())
|
||||
->method('doQuery');
|
||||
->method('runQuery');
|
||||
|
||||
$this->userProfile->deleteByIdBatch([]);
|
||||
}
|
||||
@@ -162,7 +162,7 @@ class UserProfileTest extends UnitaryTestCase
|
||||
|
||||
$this->database
|
||||
->expects(self::once())
|
||||
->method('doSelect')
|
||||
->method('runQuery')
|
||||
->with($callback);
|
||||
|
||||
$this->userProfile->getAll();
|
||||
@@ -186,7 +186,7 @@ class UserProfileTest extends UnitaryTestCase
|
||||
}
|
||||
);
|
||||
|
||||
$this->database->expects(self::once())->method('doQuery')->with($callback);
|
||||
$this->database->expects(self::once())->method('runQuery')->with($callback);
|
||||
|
||||
$this->userProfile->delete($id);
|
||||
}
|
||||
@@ -227,7 +227,7 @@ class UserProfileTest extends UnitaryTestCase
|
||||
|
||||
$this->database
|
||||
->expects(self::exactly(2))
|
||||
->method('doQuery')
|
||||
->method('runQuery')
|
||||
->with(...self::withConsecutive([$callbackDuplicate], [$callbackCreate]))
|
||||
->willReturn(new QueryResult([]), new QueryResult([1]));
|
||||
|
||||
@@ -257,7 +257,7 @@ class UserProfileTest extends UnitaryTestCase
|
||||
|
||||
$this->database
|
||||
->expects(self::once())
|
||||
->method('doQuery')
|
||||
->method('runQuery')
|
||||
->with($callbackDuplicate)
|
||||
->willReturn(new QueryResult([1]));
|
||||
|
||||
@@ -305,7 +305,7 @@ class UserProfileTest extends UnitaryTestCase
|
||||
|
||||
$this->database
|
||||
->expects(self::exactly(2))
|
||||
->method('doQuery')
|
||||
->method('runQuery')
|
||||
->with(...self::withConsecutive([$callbackDuplicate], [$callbackUpdate]))
|
||||
->willReturn(new QueryResult([]), new QueryResult([1]));
|
||||
|
||||
@@ -336,7 +336,7 @@ class UserProfileTest extends UnitaryTestCase
|
||||
|
||||
$this->database
|
||||
->expects(self::once())
|
||||
->method('doQuery')
|
||||
->method('runQuery')
|
||||
->with($callbackDuplicate)
|
||||
->willReturn(new QueryResult([1]));
|
||||
|
||||
@@ -350,7 +350,7 @@ class UserProfileTest extends UnitaryTestCase
|
||||
{
|
||||
$this->database
|
||||
->expects($this->once())
|
||||
->method('doSelect')
|
||||
->method('runQuery')
|
||||
->with(
|
||||
self::callback(static function (QueryData $queryData) {
|
||||
$params = $queryData->getQuery()->getBindValues();
|
||||
|
||||
@@ -65,7 +65,7 @@ class UserTest extends UnitaryTestCase
|
||||
{
|
||||
$this->database
|
||||
->expects($this->once())
|
||||
->method('doSelect')
|
||||
->method('runQuery')
|
||||
->with(
|
||||
self::callback(static function (QueryData $queryData) {
|
||||
$params = $queryData->getQuery()->getBindValues();
|
||||
@@ -113,7 +113,7 @@ class UserTest extends UnitaryTestCase
|
||||
|
||||
$this->database
|
||||
->expects(self::exactly(2))
|
||||
->method('doQuery')
|
||||
->method('runQuery')
|
||||
->with(...self::withConsecutive([$callbackDuplicate], [$callbackCreate]))
|
||||
->willReturn(new QueryResult([]), new QueryResult([1]));
|
||||
|
||||
@@ -143,7 +143,7 @@ class UserTest extends UnitaryTestCase
|
||||
|
||||
$this->database
|
||||
->expects(self::once())
|
||||
->method('doQuery')
|
||||
->method('runQuery')
|
||||
->with($callbackDuplicate)
|
||||
->willReturn(new QueryResult([1]));
|
||||
|
||||
@@ -157,7 +157,7 @@ class UserTest extends UnitaryTestCase
|
||||
{
|
||||
$this->database
|
||||
->expects($this->once())
|
||||
->method('doSelect')
|
||||
->method('runQuery')
|
||||
->with(
|
||||
self::callback(static function (QueryData $queryData) {
|
||||
$params = $queryData->getQuery()->getBindValues();
|
||||
@@ -192,12 +192,11 @@ class UserTest extends UnitaryTestCase
|
||||
}
|
||||
);
|
||||
|
||||
$queryResult = new QueryResult([]);
|
||||
$this->database
|
||||
->expects(self::once())
|
||||
->method('doQuery')
|
||||
->method('runQuery')
|
||||
->with($callbackUpdate)
|
||||
->willReturn($queryResult->setAffectedNumRows(1));
|
||||
->willReturn(new QueryResult(null, 1));
|
||||
|
||||
$out = $this->user->updateOnLogin($user);
|
||||
|
||||
@@ -224,12 +223,11 @@ class UserTest extends UnitaryTestCase
|
||||
}
|
||||
);
|
||||
|
||||
$queryResult = new QueryResult([]);
|
||||
$this->database
|
||||
->expects(self::once())
|
||||
->method('doQuery')
|
||||
->method('runQuery')
|
||||
->with($callbackUpdate)
|
||||
->willReturn($queryResult->setAffectedNumRows(1));
|
||||
->willReturn(new QueryResult(null, 1));
|
||||
|
||||
$out = $this->user->updateMasterPassById(100, 'super_secret', 'a_key');
|
||||
|
||||
@@ -254,7 +252,7 @@ class UserTest extends UnitaryTestCase
|
||||
}
|
||||
);
|
||||
|
||||
$this->database->expects(self::once())->method('doQuery')->with($callback);
|
||||
$this->database->expects(self::once())->method('runQuery')->with($callback);
|
||||
|
||||
$this->user->delete($id);
|
||||
}
|
||||
@@ -267,7 +265,7 @@ class UserTest extends UnitaryTestCase
|
||||
{
|
||||
$this->database
|
||||
->expects($this->once())
|
||||
->method('doSelect')
|
||||
->method('runQuery')
|
||||
->with(
|
||||
self::callback(static function (QueryData $queryData) {
|
||||
$params = $queryData->getQuery()->getBindValues();
|
||||
@@ -306,7 +304,7 @@ class UserTest extends UnitaryTestCase
|
||||
|
||||
$this->database
|
||||
->expects(self::once())
|
||||
->method('doQuery')
|
||||
->method('runQuery')
|
||||
->with($callback);
|
||||
|
||||
$this->user->deleteByIdBatch($ids);
|
||||
@@ -320,7 +318,7 @@ class UserTest extends UnitaryTestCase
|
||||
{
|
||||
$this->database
|
||||
->expects(self::never())
|
||||
->method('doQuery');
|
||||
->method('runQuery');
|
||||
|
||||
$this->user->deleteByIdBatch([]);
|
||||
}
|
||||
@@ -338,7 +336,7 @@ class UserTest extends UnitaryTestCase
|
||||
|
||||
$this->database
|
||||
->expects(self::once())
|
||||
->method('doSelect')
|
||||
->method('runQuery')
|
||||
->with($callback);
|
||||
|
||||
$this->user->getAll();
|
||||
@@ -362,12 +360,11 @@ class UserTest extends UnitaryTestCase
|
||||
}
|
||||
);
|
||||
|
||||
$queryResult = new QueryResult([]);
|
||||
$this->database
|
||||
->expects(self::once())
|
||||
->method('doQuery')
|
||||
->method('runQuery')
|
||||
->with($callbackUpdate)
|
||||
->willReturn($queryResult->setAffectedNumRows(1));
|
||||
->willReturn(new QueryResult(null, 1));
|
||||
|
||||
$out = $this->user->updateLastLoginById(100);
|
||||
|
||||
@@ -382,7 +379,7 @@ class UserTest extends UnitaryTestCase
|
||||
{
|
||||
$this->database
|
||||
->expects($this->once())
|
||||
->method('doSelect')
|
||||
->method('runQuery')
|
||||
->with(
|
||||
self::callback(static function (QueryData $queryData) {
|
||||
$params = $queryData->getQuery()->getBindValues();
|
||||
@@ -434,7 +431,7 @@ class UserTest extends UnitaryTestCase
|
||||
|
||||
$this->database
|
||||
->expects(self::exactly(2))
|
||||
->method('doQuery')
|
||||
->method('runQuery')
|
||||
->with(...self::withConsecutive([$callbackDuplicate], [$callbackUpdate]))
|
||||
->willReturn(new QueryResult([]), new QueryResult([1]));
|
||||
|
||||
@@ -465,7 +462,7 @@ class UserTest extends UnitaryTestCase
|
||||
|
||||
$this->database
|
||||
->expects(self::once())
|
||||
->method('doQuery')
|
||||
->method('runQuery')
|
||||
->with($callbackDuplicate)
|
||||
->willReturn(new QueryResult([1]));
|
||||
|
||||
@@ -479,7 +476,7 @@ class UserTest extends UnitaryTestCase
|
||||
{
|
||||
$this->database
|
||||
->expects($this->once())
|
||||
->method('doSelect')
|
||||
->method('runQuery')
|
||||
->with(
|
||||
self::callback(static function (QueryData $queryData) {
|
||||
$params = $queryData->getQuery()->getBindValues();
|
||||
@@ -498,7 +495,7 @@ class UserTest extends UnitaryTestCase
|
||||
{
|
||||
$this->database
|
||||
->expects($this->once())
|
||||
->method('doSelect')
|
||||
->method('runQuery')
|
||||
->with(
|
||||
self::callback(static function (QueryData $queryData) {
|
||||
$params = $queryData->getQuery()->getBindValues();
|
||||
@@ -523,7 +520,7 @@ class UserTest extends UnitaryTestCase
|
||||
{
|
||||
$this->database
|
||||
->expects($this->once())
|
||||
->method('doSelect')
|
||||
->method('runQuery')
|
||||
->with(
|
||||
self::callback(static function (QueryData $queryData) {
|
||||
$params = $queryData->getQuery()->getBindValues();
|
||||
@@ -562,7 +559,7 @@ class UserTest extends UnitaryTestCase
|
||||
|
||||
$this->database
|
||||
->expects(self::once())
|
||||
->method('doSelect')
|
||||
->method('runQuery')
|
||||
->with($callback, true);
|
||||
|
||||
$this->user->search($item);
|
||||
@@ -590,7 +587,7 @@ class UserTest extends UnitaryTestCase
|
||||
|
||||
$this->database
|
||||
->expects(self::once())
|
||||
->method('doSelect')
|
||||
->method('runQuery')
|
||||
->with($callback, true);
|
||||
|
||||
$this->user->search($item);
|
||||
@@ -626,7 +623,7 @@ class UserTest extends UnitaryTestCase
|
||||
|
||||
$this->database
|
||||
->expects(self::once())
|
||||
->method('doSelect')
|
||||
->method('runQuery')
|
||||
->with($callback, true);
|
||||
|
||||
$this->user->search($item);
|
||||
@@ -654,13 +651,11 @@ class UserTest extends UnitaryTestCase
|
||||
}
|
||||
);
|
||||
|
||||
$queryResult = new QueryResult();
|
||||
|
||||
$this->database
|
||||
->expects(self::once())
|
||||
->method('doQuery')
|
||||
->method('runQuery')
|
||||
->with($callbackUpdate)
|
||||
->willReturn($queryResult->setAffectedNumRows(1));
|
||||
->willReturn(new QueryResult(null, 1));
|
||||
|
||||
$this->user->updatePreferencesById(100, $userPreferences);
|
||||
}
|
||||
@@ -688,13 +683,11 @@ class UserTest extends UnitaryTestCase
|
||||
}
|
||||
);
|
||||
|
||||
$queryResult = new QueryResult();
|
||||
|
||||
$this->database
|
||||
->expects(self::once())
|
||||
->method('doQuery')
|
||||
->method('runQuery')
|
||||
->with($callbackUpdate)
|
||||
->willReturn($queryResult->setAffectedNumRows(1));
|
||||
->willReturn(new QueryResult(null, 1));
|
||||
|
||||
$this->user->updatePassById($user);
|
||||
}
|
||||
|
||||
@@ -54,7 +54,7 @@ class UserToUserGroupTest extends UnitaryTestCase
|
||||
{
|
||||
$this->database
|
||||
->expects($this->once())
|
||||
->method('doSelect')
|
||||
->method('runQuery')
|
||||
->with(
|
||||
self::callback(static function (QueryData $queryData) {
|
||||
$params = $queryData->getQuery()->getBindValues();
|
||||
@@ -72,7 +72,7 @@ class UserToUserGroupTest extends UnitaryTestCase
|
||||
{
|
||||
$this->database
|
||||
->expects($this->once())
|
||||
->method('doSelect')
|
||||
->method('runQuery')
|
||||
->with(
|
||||
self::callback(static function (QueryData $queryData) {
|
||||
$params = $queryData->getQuery()->getBindValues();
|
||||
@@ -111,7 +111,7 @@ class UserToUserGroupTest extends UnitaryTestCase
|
||||
|
||||
$this->database
|
||||
->expects(self::once())
|
||||
->method('doQuery')
|
||||
->method('runQuery')
|
||||
->with($callbackCreate)
|
||||
->willReturn(new QueryResult([]), new QueryResult([1]));
|
||||
|
||||
@@ -126,7 +126,7 @@ class UserToUserGroupTest extends UnitaryTestCase
|
||||
{
|
||||
$this->database
|
||||
->expects(self::never())
|
||||
->method('doQuery');
|
||||
->method('runQuery');
|
||||
|
||||
$this->userToUserGroup->add(100, []);
|
||||
}
|
||||
@@ -151,7 +151,7 @@ class UserToUserGroupTest extends UnitaryTestCase
|
||||
}
|
||||
);
|
||||
|
||||
$this->database->expects(self::once())->method('doQuery')->with($callback);
|
||||
$this->database->expects(self::once())->method('runQuery')->with($callback);
|
||||
|
||||
$this->userToUserGroup->delete($id);
|
||||
}
|
||||
@@ -160,7 +160,7 @@ class UserToUserGroupTest extends UnitaryTestCase
|
||||
{
|
||||
$this->database
|
||||
->expects($this->once())
|
||||
->method('doSelect')
|
||||
->method('runQuery')
|
||||
->with(
|
||||
self::callback(static function (QueryData $queryData) {
|
||||
$params = $queryData->getQuery()->getBindValues();
|
||||
@@ -179,7 +179,7 @@ class UserToUserGroupTest extends UnitaryTestCase
|
||||
{
|
||||
$this->database
|
||||
->expects($this->once())
|
||||
->method('doSelect')
|
||||
->method('runQuery')
|
||||
->with(
|
||||
self::callback(static function (QueryData $queryData) {
|
||||
$params = $queryData->getQuery()->getBindValues();
|
||||
@@ -242,7 +242,7 @@ class UserToUserGroupTest extends UnitaryTestCase
|
||||
|
||||
$this->database
|
||||
->expects(self::exactly(2))
|
||||
->method('doQuery')
|
||||
->method('runQuery')
|
||||
->with(...self::withConsecutive([$callbackDelete], [$callbackCreate]))
|
||||
->willReturn($queryResult);
|
||||
|
||||
@@ -258,7 +258,7 @@ class UserToUserGroupTest extends UnitaryTestCase
|
||||
{
|
||||
$this->database
|
||||
->expects(self::never())
|
||||
->method('doQuery');
|
||||
->method('runQuery');
|
||||
|
||||
$this->userToUserGroup->update(100, []);
|
||||
}
|
||||
|
||||
@@ -49,7 +49,7 @@ use SP\Domain\Core\Exceptions\ConstraintException;
|
||||
use SP\Domain\Core\Exceptions\QueryException;
|
||||
use SP\Domain\Core\Exceptions\SPException;
|
||||
use SP\Infrastructure\Database\DatabaseConnectionData;
|
||||
use SP\Infrastructure\Database\DbStorageInterface;
|
||||
use SP\Infrastructure\Database\DbStorageHandler;
|
||||
use SP\Infrastructure\Database\MysqlHandler;
|
||||
use SPT\DatabaseTrait;
|
||||
use stdClass;
|
||||
@@ -164,7 +164,7 @@ abstract class ApiTestCase extends TestCase
|
||||
|
||||
return new ApiRequest(json_encode($data, JSON_THROW_ON_ERROR));
|
||||
},
|
||||
DbStorageInterface::class => create(MysqlHandler::class)
|
||||
DbStorageHandler::class => create(MysqlHandler::class)
|
||||
->constructor($databaseConnectionData),
|
||||
ConfigDataInterface::class => static function (ConfigFileService $config) use (
|
||||
$databaseConnectionData
|
||||
|
||||
@@ -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.
|
||||
*
|
||||
@@ -31,7 +31,7 @@ use Exception;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use Psr\Container\ContainerInterface;
|
||||
use SP\Domain\Core\Context\ContextInterface;
|
||||
use SP\Infrastructure\Database\DbStorageInterface;
|
||||
use SP\Infrastructure\Database\DbStorageHandler;
|
||||
use Symfony\Component\Console\Tester\CommandTester;
|
||||
|
||||
use function SPT\getDbHandler;
|
||||
@@ -98,6 +98,6 @@ abstract class CliTestCase extends TestCase
|
||||
|
||||
protected function setupDatabase(): void
|
||||
{
|
||||
self::$dic->set(DbStorageInterface::class, getDbHandler());
|
||||
self::$dic->set(DbStorageHandler::class, getDbHandler());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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.
|
||||
*
|
||||
@@ -34,7 +34,7 @@ use SP\Domain\Core\Context\ContextInterface;
|
||||
use SP\Domain\Core\Exceptions\FileNotFoundException;
|
||||
use SP\Domain\User\Services\UserLoginResponse;
|
||||
use SP\Infrastructure\Database\DatabaseConnectionData;
|
||||
use SP\Infrastructure\Database\DbStorageInterface;
|
||||
use SP\Infrastructure\Database\DbStorageHandler;
|
||||
use SP\Infrastructure\Database\MysqlHandler;
|
||||
use SP\Util\FileUtil;
|
||||
|
||||
@@ -140,7 +140,7 @@ function setupContext(): Container
|
||||
$context->setUserProfile(new ProfileData());
|
||||
|
||||
// Inicializar los datos de conexión a la BBDD
|
||||
$dic->set(DbStorageInterface::class, getDbHandler());
|
||||
$dic->set(DbStorageHandler::class, getDbHandler());
|
||||
|
||||
return $dic;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user