浏览代码

Fix regression in phpunit

Laurent Destailleur 3 年之前
父节点
当前提交
c2a088c5ff
共有 2 个文件被更改,包括 2 次插入4 次删除
  1. 1 3
      htdocs/core/lib/security2.lib.php
  2. 1 1
      test/phpunit/SecurityTest.php

+ 1 - 3
htdocs/core/lib/security2.lib.php

@@ -69,8 +69,6 @@ function checkLoginPassEntity($usertotest, $passwordtotest, $entitytotest, $auth
 
 	// Validation of login/pass/entity with standard modules
 	if (empty($login)) {
-		unset($_SESSION["dol_loginmesg"]);
-
 		$test = true;
 		foreach ($authmode as $mode) {
 			if ($test && $mode && !$login) {
@@ -113,7 +111,7 @@ function checkLoginPassEntity($usertotest, $passwordtotest, $entitytotest, $auth
 					// Load translation files required by the page
 					$langs->loadLangs(array('other', 'main', 'errors'));
 
-					$_SESSION["dol_loginmesg"] = (isset($_SESSION["dol_loginmesg"]) ? $_SESSION["dol_loginmesg"].', ' : '').$langs->transnoentitiesnoconv("ErrorFailedToLoadLoginFileForMode", $mode);
+					$_SESSION["dol_loginmesg"] = (empty($_SESSION["dol_loginmesg"]) ? '' : $_SESSION["dol_loginmesg"].', ').$langs->transnoentitiesnoconv("ErrorFailedToLoadLoginFileForMode", $mode);
 				}
 			}
 		}

+ 1 - 1
test/phpunit/SecurityTest.php

@@ -604,7 +604,7 @@ class SecurityTest extends PHPUnit\Framework\TestCase
 
 		$login=checkLoginPassEntity('admin', 'admin', 1, array('forceuser'));
 		print __METHOD__." login=".$login."\n";
-		$this->assertEquals($login, '');    // Expected '' because should failed because login 'auto' does not exists
+		$this->assertEquals('', $login, 'Error');    // Expected '' because should failed because login 'auto' does not exists
 	}
 
 	/**