TYPO3 CMS  TYPO3_7-6
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 
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 
67  {
69  }
70 
75  {
76  $this->assertEquals(7, \TYPO3\CMS\Core\Log\LogLevel::normalizeLevel('debug'));
77  }
78 
83  {
84  $levelString = 'invalid';
85  $this->assertEquals($levelString, \TYPO3\CMS\Core\Log\LogLevel::normalizeLevel($levelString));
86  }
87 }
static validateLevel($level)
Definition: LogLevel.php:143
static normalizeLevel($level)
Definition: LogLevel.php:156
static isValidLevel($level)
Definition: LogLevel.php:131
isValidLevelThrowsExceptionOnInvalidLevelIfAskedToDoSo($inputValue)