[BUGFIX] LogLevelTest dataProvider not used
[Packages/TYPO3.CMS.git] / typo3 / sysext / core / Tests / Unit / Log / LogLevelTest.php
1 <?php
2 namespace TYPO3\CMS\Core\Tests\Unit\Log;
3
4 /***************************************************************
5 * Copyright notice
6 *
7 * (c) 2011-2012 Ingo Renner (ingo@typo3.org)
8 * All rights reserved
9 *
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.
15 *
16 * The GNU General Public License can be found at
17 * http://www.gnu.org/copyleft/gpl.html.
18 *
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.
23 *
24 * This copyright notice MUST APPEAR in all copies of the script!
25 ***************************************************************/
26
27 /**
28 * Testcase for \TYPO3\CMS\Core\Log\Level.
29 *
30 * @author Ingo Renner <ingo@typo3.org>
31 * @package TYPO3
32 * @subpackage t3lib
33 */
34 class LevelTest extends \tx_phpunit_testcase {
35
36 /**
37 * @test
38 */
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));
43 }
44 }
45
46 /**
47 * @test
48 */
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));
53 }
54 }
55
56 /**
57 * Data provider or isValidLevelThrowsExceptionOnInvalidLevelIfAskedToDoSo
58 */
59 public function isValidLevelThrowsExceptionOnInvalidLevelIfAskedToDoSoDataProvider() {
60 return array(
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),
68 'NULL' => array(NULL)
69 );
70 }
71
72 /**
73 * @test
74 * @dataProvider isValidLevelThrowsExceptionOnInvalidLevelIfAskedToDoSoDataProvider
75 * @expectedException \RangeException
76 */
77 public function isValidLevelThrowsExceptionOnInvalidLevelIfAskedToDoSo($inputValue) {
78 \TYPO3\CMS\Core\Log\LogLevel::validateLevel($inputValue);
79 }
80
81 }
82
83 ?>