‪TYPO3CMS  9.5
LogLevelTest.php
Go to the documentation of this file.
1 <?php
3 
4 /*
5  * This file is part of the TYPO3 CMS project.
6  *
7  * It is free software; you can redistribute it and/or modify it under
8  * the terms of the GNU General Public License, either version 2
9  * of the License, or any later version.
10  *
11  * For the full copyright and license information, please read the
12  * LICENSE.txt file that was distributed with this source code.
13  *
14  * The TYPO3 project - inspiring people to share!
15  */
16 
17 use TYPO3\TestingFramework\Core\Unit\UnitTestCase;
18 
22 class ‪LogLevelTest extends UnitTestCase
23 {
28  {
29  $validLevels = [0, 1, 2, 3, 4, 5, 6, 7];
30  foreach ($validLevels as $validLevel) {
31  $this->assertTrue(\‪TYPO3\CMS\Core\Log\‪LogLevel::isValidLevel($validLevel));
32  }
33  }
34 
39  {
40  $invalidLevels = [-1, 8, 1.5, 'string', [], new \stdClass(), false, null];
41  foreach ($invalidLevels as $invalidLevel) {
42  $this->assertFalse(\‪TYPO3\CMS\Core\Log\‪LogLevel::isValidLevel($invalidLevel));
43  }
44  }
45 
50  {
51  return [
52  'negative integer' => [-1],
53  'higher level than expected' => [8],
54  'float' => [1.5],
55  'string' => ['string'],
56  'array' => [[]],
57  'object' => [new \stdClass()],
58  'boolean FALSE' => [false],
59  'NULL' => [null]
60  ];
61  }
62 
68  {
69  $this->expectException(\Psr\Log\InvalidArgumentException::class);
70  $this->expectExceptionCode(1321637121);
71 
73  }
74 
79  {
80  $this->assertEquals(7, \‪TYPO3\CMS\Core\Log\‪LogLevel::normalizeLevel('debug'));
81  }
82 
87  {
88  $levelString = 'invalid';
89  $this->assertEquals($levelString, \‪TYPO3\CMS\Core\Log\‪LogLevel::normalizeLevel($levelString));
90  }
91 }
‪TYPO3\CMS\Core\Tests\Unit\Log\LogLevelTest\isValidLevelDoesNotValidateInvalidLevels
‪isValidLevelDoesNotValidateInvalidLevels()
Definition: LogLevelTest.php:38
‪TYPO3
‪TYPO3\CMS\Core\Tests\Unit\Log
‪TYPO3\CMS\Core\Log\LogLevel\normalizeLevel
‪static int string normalizeLevel($level)
Definition: LogLevel.php:154
‪TYPO3\CMS\Core\Tests\Unit\Log\LogLevelTest\normalizeLevelConvertsValidLevelFromStringToInteger
‪normalizeLevelConvertsValidLevelFromStringToInteger()
Definition: LogLevelTest.php:78
‪TYPO3\CMS\Core\Tests\Unit\Log\LogLevelTest
Definition: LogLevelTest.php:23
‪TYPO3\CMS\Core\Log\LogLevel\isValidLevel
‪static bool isValidLevel($level)
Definition: LogLevel.php:130
‪TYPO3\CMS\Core\Tests\Unit\Log\LogLevelTest\isValidLevelThrowsExceptionOnInvalidLevelIfAskedToDoSoDataProvider
‪isValidLevelThrowsExceptionOnInvalidLevelIfAskedToDoSoDataProvider()
Definition: LogLevelTest.php:49
‪TYPO3\CMS\Core\Tests\Unit\Log\LogLevelTest\normalizeLevelDoesNotConvertInvalidLevel
‪normalizeLevelDoesNotConvertInvalidLevel()
Definition: LogLevelTest.php:86
‪TYPO3\CMS\Core\Tests\Unit\Log\LogLevelTest\isValidLevelThrowsExceptionOnInvalidLevelIfAskedToDoSo
‪isValidLevelThrowsExceptionOnInvalidLevelIfAskedToDoSo($inputValue)
Definition: LogLevelTest.php:67
‪TYPO3\CMS\Core\Log\LogLevel\validateLevel
‪static validateLevel($level)
Definition: LogLevel.php:141
‪TYPO3\CMS\Core\Tests\Unit\Log\LogLevelTest\isValidLevelValidatesValidLevels
‪isValidLevelValidatesValidLevels()
Definition: LogLevelTest.php:27