2 namespace TYPO3\CMS\Core\Tests\Unit\Log
;
4 /***************************************************************
7 * (c) 2011-2012 Ingo Renner (ingo@typo3.org)
10 * This script is part of the TYPO3 project. The TYPO3 project is
11 * free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License as published by
13 * the Free Software Foundation; either version 2 of the License, or
14 * (at your option) any later version.
16 * The GNU General Public License can be found at
17 * http://www.gnu.org/copyleft/gpl.html.
19 * This script is distributed in the hope that it will be useful,
20 * but WITHOUT ANY WARRANTY; without even the implied warranty of
21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 * GNU General Public License for more details.
24 * This copyright notice MUST APPEAR in all copies of the script!
25 ***************************************************************/
28 * Testcase for \TYPO3\CMS\Core\Log\Level.
30 * @author Ingo Renner <ingo@typo3.org>
34 class LevelTest
extends \tx_phpunit_testcase
{
39 public function isValidLevelValidatesValidLevels() {
40 $validLevels = array(0, 1, 2, 3, 4, 5, 6, 7);
41 foreach ($validLevels as $validLevel) {
42 $this->assertTrue(\TYPO3\CMS\Core\Log\LogLevel
::isValidLevel($validLevel));
49 public function isValidLevelDoesNotValidateInvalidLevels() {
50 $invalidLevels = array(-1, 8, 1.5, 'string', array(), new \
stdClass(), FALSE, NULL);
51 foreach ($invalidLevels as $invalidLevel) {
52 $this->assertFalse(\TYPO3\CMS\Core\Log\LogLevel
::isValidLevel($invalidLevel));
57 * Data provider or isValidLevelThrowsExceptionOnInvalidLevelIfAskedToDoSo
59 public function isValidLevelThrowsExceptionOnInvalidLevelIfAskedToDoSoDataProvider() {
61 'negative integer' => array(-1),
62 'higher level than expected' => array(8),
63 'float' => array(1.5),
64 'string' => array('string'),
65 'array' => array(array()),
66 'object' => array(new \
stdClass()),
67 'boolean FALSE' => array(FALSE),
74 * @dataProvider isValidLevelThrowsExceptionOnInvalidLevelIfAskedToDoSoDataProvider
75 * @expectedException \RangeException
77 public function isValidLevelThrowsExceptionOnInvalidLevelIfAskedToDoSo($inputValue) {
78 \TYPO3\CMS\Core\Log\LogLevel
::validateLevel($inputValue);