Compare commits

...

3 Commits

Author SHA1 Message Date
denis.flaven@combodo.com
3fb5c05467 N°7001 - Being admin to generate oAuth token is too restrictive 2023-12-13 13:57:44 +01:00
Pierre Goiffon
f36f3aa05b 💡 N°6848 Fix PHPDoc 2023-10-17 11:12:38 +02:00
Pierre Goiffon
d0d90d7c69 N°6848 Fix TransactionsTest::testTransactionOpenedNotClosed failing
Was caused by 239c51bb, which adds 65bb76b9 tests improvements but only partly : we were missing in TransactionsTest::tearDown the mysqli reset from mock to original mysqli cnx

Without this reset the rollback made in ItopTestCase::tearDown is throwing an exception (query() method on the DbConnectionWrapper cnx returns false in \CMDBSource::DBQuery) on PHP 8.1 and 8.2

Co-authored-by: Romain Quetiez <romain.queriez@combodo.com>
2023-10-17 10:53:26 +02:00
3 changed files with 11 additions and 3 deletions

View File

@@ -59,9 +59,17 @@ class DbConnectionWrapper
* Use this to register a mock that will handle {@see mysqli::query()}
*
* @param \mysqli|null $oMysqli
* @since 3.0.4 3.1.1 3.2.0 Param $oMysqli becomes nullable
* @since 3.1.0-4 N°6848 backport of restoring cnx on null parameter value
*/
public static function SetDbConnectionMockForQuery(?mysqli $oMysqli): void
public static function SetDbConnectionMockForQuery(?mysqli $oMysqli = null): void
{
static::$oDbCnxMockableForQuery = $oMysqli;
if (is_null($oMysqli)) {
// Reset to standard connection
static::$oDbCnxMockableForQuery = static::$oDbCnxStandard;
}
else {
static::$oDbCnxMockableForQuery = $oMysqli;
}
}
}

View File

@@ -10,6 +10,5 @@ IssueLog::Trace('----- Request: '.utils::GetRequestUri(), LogChannels::WEB_REQUE
$sTemplates = APPROOT.'templates/pages/backoffice/oauth';
$oUpdateController = new OAuthLandingController($sTemplates, 'core');
$oUpdateController->AllowOnlyAdmin();
$oUpdateController->SetDefaultOperation('Landing');
$oUpdateController->HandleOperation();

View File

@@ -276,6 +276,7 @@ class TransactionsTest extends ItopTestCase
protected function tearDown(): void
{
try {
DbConnectionWrapper::SetDbConnectionMockForQuery(); // Else will throw error on PHP 8.1+ (see N°6848)
parent::tearDown();
}
catch (MySQLTransactionNotClosedException $e) {