TYPO3 CMS  TYPO3_8-7
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 
20 class LogLevelTest extends \TYPO3\TestingFramework\Core\Unit\UnitTestCase
21 {
26  {
27  $validLevels = [0, 1, 2, 3, 4, 5, 6, 7];
28  foreach ($validLevels as $validLevel) {
29  $this->assertTrue(\TYPO3\CMS\Core\Log\LogLevel::isValidLevel($validLevel));
30  }
31  }
32 
37  {
38  $invalidLevels = [-1, 8, 1.5, 'string', [], new \stdClass(), false, null];
39  foreach ($invalidLevels as $invalidLevel) {
40  $this->assertFalse(\TYPO3\CMS\Core\Log\LogLevel::isValidLevel($invalidLevel));
41  }
42  }
43 
48  {
49  return [
50  'negative integer' => [-1],
51  'higher level than expected' => [8],
52  'float' => [1.5],
53  'string' => ['string'],
54  'array' => [[]],
55  'object' => [new \stdClass()],
56  'boolean FALSE' => [false],
57  'NULL' => [null]
58  ];
59  }
60 
66  {
67  $this->expectException(\Psr\Log\InvalidArgumentException::class);
68  $this->expectExceptionCode(1321637121);
69 
71  }
72 
77  {
78  $this->assertEquals(7, \TYPO3\CMS\Core\Log\LogLevel::normalizeLevel('debug'));
79  }
80 
85  {
86  $levelString = 'invalid';
87  $this->assertEquals($levelString, \TYPO3\CMS\Core\Log\LogLevel::normalizeLevel($levelString));
88  }
89 }
static validateLevel($level)
Definition: LogLevel.php:142
static normalizeLevel($level)
Definition: LogLevel.php:155
static isValidLevel($level)
Definition: LogLevel.php:131
isValidLevelThrowsExceptionOnInvalidLevelIfAskedToDoSo($inputValue)