From bab14e1489c88b8420e798950fa4f9042d6e970e Mon Sep 17 00:00:00 2001 From: Pierre Goiffon Date: Thu, 5 May 2022 15:43:59 +0200 Subject: [PATCH] =?UTF-8?q?N=C2=B04224=20remove=20workarounds=20for=20DEPR?= =?UTF-8?q?ECATED=20notices=20generated=20by=20mock=20We=20shouldn't=20hav?= =?UTF-8?q?e=20the=20problem=20anymore=20with=20PHPUnit=208.5=20!?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- test/core/Log/ExceptionLogTest.php | 7 ------- test/core/Log/LogAPITest.php | 7 ------- test/coreExtensions/UserLocalTest.php | 27 --------------------------- 3 files changed, 41 deletions(-) diff --git a/test/core/Log/ExceptionLogTest.php b/test/core/Log/ExceptionLogTest.php index 004596665..2cb7d8a79 100644 --- a/test/core/Log/ExceptionLogTest.php +++ b/test/core/Log/ExceptionLogTest.php @@ -17,7 +17,6 @@ namespace Combodo\iTop\Test\UnitTest\Core\Log; use Combodo\iTop\Test\UnitTest\ItopDataTestCase; use ExceptionLog; -use MetaModel; require_once(__DIR__.'/ExceptionLogTest/Exceptions.php'); @@ -33,12 +32,6 @@ class ExceptionLogTest extends ItopDataTestCase { require_once(__DIR__.'/ExceptionLogTest/Exceptions.php'); parent::setUp(); - - // We are using PHPUnit\Framework\MockObject\Generator::generateMock that is throwing notice ! - // Changing config so that those won't be caught by \DeprecatedCallsLog::DeprecatedNoticesErrorHandler - // disabling devenv is easier than changing log config O:) - $oConfig = MetaModel::GetConfig(); - $oConfig->Set('developer_mode.enabled', false); } /** diff --git a/test/core/Log/LogAPITest.php b/test/core/Log/LogAPITest.php index 60fac6323..70705ced1 100644 --- a/test/core/Log/LogAPITest.php +++ b/test/core/Log/LogAPITest.php @@ -15,7 +15,6 @@ namespace Combodo\iTop\Test\UnitTest\Core\Log; use Combodo\iTop\Test\UnitTest\ItopDataTestCase; -use MetaModel; /** * @runTestsInSeparateProcesses @@ -31,12 +30,6 @@ class LogAPITest extends ItopDataTestCase { parent::setUp(); - // We are using PHPUnit\Framework\MockObject\Generator::generateMock that is throwing notice ! - // Changing config so that those won't be caught by \DeprecatedCallsLog::DeprecatedNoticesErrorHandler - // disabling devenv is easier than changing log config O:) - $oConfig = MetaModel::GetConfig(); - $oConfig->Set('developer_mode.enabled', false); - $this->mockFileLog = $this->createMock('FileLog'); $this->oMetaModelConfig = $this->createMock('Config'); } diff --git a/test/coreExtensions/UserLocalTest.php b/test/coreExtensions/UserLocalTest.php index 89ce3404b..65864b137 100644 --- a/test/coreExtensions/UserLocalTest.php +++ b/test/coreExtensions/UserLocalTest.php @@ -34,10 +34,6 @@ class UserLocalTest extends ItopDataTestCase */ public function testValidatePassword($sPassword, $aValidatorNames, $aConfigValueMap, $bExpectedCheckStatus, $expectedCheckIssues = null, $sUserLanguage = null) { - // We are calling methods that generates DEPRECATED warnings :( Like PHPUnit\Framework\MockObject\Generator::generateMock - // Since N°3002 this would make the test fail, so this is a workaround ! - // changing ways to do mock will be done in N°4224 - set_error_handler(array(__CLASS__, 'VoidErrorHandlerForDeprecated')); $configMock = $this->createMock(\Config::class); $configMock ->method('GetModuleSetting') @@ -74,28 +70,6 @@ class UserLocalTest extends ItopDataTestCase } } - /** - * Fake error handler to silently discard DEPRECATED warnings - * - * @param int $iErrNo - * @param string $sErrStr - * @param string $sErrFile - * @param int $iErrLine - * - * @return boolean - */ - public static function VoidErrorHandlerForDeprecated($iErrno, $sErrStr, $sErrFile, $iErrLine) - { - if ( - (\E_USER_DEPRECATED !== $iErrno) - && (\E_DEPRECATED !== $iErrno) - ) { - return false; - } - - return true; // Ignore the error - } - public function ProviderValidatePassword() { return array( @@ -262,7 +236,6 @@ class UserLocalTest extends ItopDataTestCase ); } - /** * @dataProvider ProviderPasswordRenewal *