[TESTS] Add test annotations to core classes

This commit is contained in:
Hugo Sales 2021-08-08 00:37:02 +00:00
parent 21a5bbe639
commit 2851b899b8
Signed by: someonewithpc
GPG Key ID: 7D0C7EAFC9D835A0
5 changed files with 28 additions and 13 deletions

View File

@ -25,7 +25,6 @@ use App\Core\DB\DB;
use function App\Core\I18n\_m; use function App\Core\I18n\_m;
use App\Entity\Attachment; use App\Entity\Attachment;
use App\Util\Common; use App\Util\Common;
use App\Util\Exception\ClientException;
use App\Util\Exception\DuplicateFoundException; use App\Util\Exception\DuplicateFoundException;
use App\Util\Exception\NoSuchFileException; use App\Util\Exception\NoSuchFileException;
use App\Util\Exception\NotFoundException; use App\Util\Exception\NotFoundException;
@ -161,7 +160,9 @@ class GSFile
autoLastModified: true autoLastModified: true
); );
if (Common::config('site', 'x_static_delivery')) { if (Common::config('site', 'x_static_delivery')) {
// @codeCoverageIgnoreStart
$response->trustXSendfileTypeHeader(); $response->trustXSendfileTypeHeader();
// @codeCoverageIgnoreEnd
} }
return $response; return $response;
} else { } else {
@ -184,8 +185,10 @@ class GSFile
case 1: case 1:
return $res[0]; return $res[0];
default: default:
// @codeCoverageIgnoreStart
Log::error('Media query returned more than one result for identifier: \"' . $id . '\"'); Log::error('Media query returned more than one result for identifier: \"' . $id . '\"');
throw new ClientException(_m('Internal server error')); throw new ServerException(_m('Internal server error'));
// @codeCoverageIgnoreEnd
} }
} }

View File

@ -43,6 +43,12 @@ abstract class Log
self::$logger = $l; self::$logger = $l;
} }
/**
* Log a critical error when a really unexpected exception occured. This indicates a bug in the software
*
* @throws ServerException
* @codeCoverageIgnore
*/
public static function unexpected_exception(\Exception $e) public static function unexpected_exception(\Exception $e)
{ {
$backtrace = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS, 2); $backtrace = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS, 2);

View File

@ -48,6 +48,7 @@ abstract class Queue
* @param string $queue * @param string $queue
* @param bool $high * @param bool $high
* @param array $stamps * @param array $stamps
* @codeCoverageIgnore
*/ */
public static function enqueue($message, string $queue, bool $high = false, array $stamps = []) public static function enqueue($message, string $queue, bool $high = false, array $stamps = [])
{ {

View File

@ -35,6 +35,9 @@ abstract class FormFields
]; ];
} }
/**
* @codeCoverageIgnore
*/
public static function password(array $options = []): array public static function password(array $options = []): array
{ {
['password', PasswordType::class, [ ['password', PasswordType::class, [

View File

@ -146,18 +146,20 @@ class Nickname
throw new NicknameReservedException(); throw new NicknameReservedException();
} elseif ($check_already_used) { } elseif ($check_already_used) {
switch ($which) { switch ($which) {
case self::CHECK_LOCAL_USER: case self::CHECK_LOCAL_USER:
$lu = LocalUser::findByNicknameOrEmail($nickname, email: ''); $lu = LocalUser::findByNicknameOrEmail($nickname, email: '');
if ($lu !== null) { if ($lu !== null) {
throw new NicknameTakenException($lu->getActor()); throw new NicknameTakenException($lu->getActor());
}
break;
// @codeCoverageIgnoreStart
case self::CHECK_LOCAL_GROUP:
throw new \NotImplementedException();
break;
default:
throw new \InvalidArgumentException();
// @codeCoverageIgnoreEnd
} }
break;
case self::CHECK_LOCAL_GROUP:
throw new \NotImplementedException();
break;
default:
throw new \InvalidArgumentException();
}
} }
} }