‪TYPO3CMS  10.4
LogLevelTest.php
Go to the documentation of this file.
1 <?php
2 
3 /*
4  * This file is part of the TYPO3 CMS project.
5  *
6  * It is free software; you can redistribute it and/or modify it under
7  * the terms of the GNU General Public License, either version 2
8  * of the License, or any later version.
9  *
10  * For the full copyright and license information, please read the
11  * LICENSE.txt file that was distributed with this source code.
12  *
13  * The TYPO3 project - inspiring people to share!
14  */
15 
17 
18 use Psr\Log\InvalidArgumentException;
20 use TYPO3\TestingFramework\Core\Unit\UnitTestCase;
21 
25 class ‪LogLevelTest extends UnitTestCase
26 {
31  {
32  $validLevels = [0, 1, 2, 3, 4, 5, 6, 7];
33  foreach ($validLevels as $validLevel) {
34  self::assertTrue(‪LogLevel::isValidLevel($validLevel));
35  }
36  }
37 
42  {
43  $invalidLevels = [-1, 8];
44  foreach ($invalidLevels as $invalidLevel) {
45  self::assertFalse(‪LogLevel::isValidLevel($invalidLevel));
46  }
47  }
48 
53  {
54  return [
55  'negative integer' => [-1],
56  'higher level than expected' => [8],
57  ];
58  }
59 
65  {
66  $this->expectException(InvalidArgumentException::class);
67  $this->expectExceptionCode(1321637121);
68 
69  ‪LogLevel::validateLevel($inputValue);
70  }
71 
76  {
77  self::assertEquals(7, ‪LogLevel::normalizeLevel('debug'));
78  }
79 }
‪TYPO3\CMS\Core\Tests\Unit\Log\LogLevelTest\isValidLevelDoesNotValidateInvalidLevels
‪isValidLevelDoesNotValidateInvalidLevels()
Definition: LogLevelTest.php:41
‪TYPO3\CMS\Core\Log\LogLevel\validateLevel
‪static validateLevel(int $level)
Definition: LogLevel.php:81
‪TYPO3\CMS\Core\Tests\Unit\Log
‪TYPO3\CMS\Core\Tests\Unit\Log\LogLevelTest\normalizeLevelConvertsValidLevelFromStringToInteger
‪normalizeLevelConvertsValidLevelFromStringToInteger()
Definition: LogLevelTest.php:75
‪TYPO3\CMS\Core\Tests\Unit\Log\LogLevelTest
Definition: LogLevelTest.php:26
‪TYPO3\CMS\Core\Tests\Unit\Log\LogLevelTest\isValidLevelThrowsExceptionOnInvalidLevelIfAskedToDoSoDataProvider
‪isValidLevelThrowsExceptionOnInvalidLevelIfAskedToDoSoDataProvider()
Definition: LogLevelTest.php:52
‪TYPO3\CMS\Core\Tests\Unit\Log\LogLevelTest\isValidLevelThrowsExceptionOnInvalidLevelIfAskedToDoSo
‪isValidLevelThrowsExceptionOnInvalidLevelIfAskedToDoSo($inputValue)
Definition: LogLevelTest.php:64
‪TYPO3\CMS\Core\Log\LogLevel\normalizeLevel
‪static int normalizeLevel($level)
Definition: LogLevel.php:94
‪TYPO3\CMS\Core\Tests\Unit\Log\LogLevelTest\isValidLevelValidatesValidLevels
‪isValidLevelValidatesValidLevels()
Definition: LogLevelTest.php:30
‪TYPO3\CMS\Core\Log\LogLevel
Definition: LogLevel.php:24
‪TYPO3\CMS\Core\Log\LogLevel\isValidLevel
‪static bool isValidLevel(int $level)
Definition: LogLevel.php:70