[BUGFIX] ConfigurationManager use FrontendSimulator only if neccessary
[Packages/TYPO3.CMS.git] / typo3 / sysext / extbase / Tests / Unit / Utility / TypeHandlingTest.php
1 <?php
2
3 /* *
4 * This script belongs to the Extbase framework. *
5 * *
6 * It is free software; you can redistribute it and/or modify it under *
7 * the terms of the GNU Lesser General Public License as published by the *
8 * Free Software Foundation, either version 3 of the License, or (at your *
9 * option) any later version. *
10 * *
11 * This script is distributed in the hope that it will be useful, but *
12 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHAN- *
13 * TABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser *
14 * General Public License for more details. *
15 * *
16 * You should have received a copy of the GNU Lesser General Public *
17 * License along with the script. *
18 * If not, see http://www.gnu.org/licenses/lgpl.html *
19 * *
20 * The TYPO3 project - inspiring people to share! *
21 * */
22
23 /**
24 * Testcase for the Utility\TypeHandling class
25 *
26 * @license http://www.gnu.org/licenses/lgpl.html GNU Lesser General Public License, version 3 or later
27 * @deprecated since Extbase 1.4.0; will be removed in Extbase 1.6.0. Please use Tx_Extbase_Tests_Unit_Service_TypeHandlingServiceTest instead
28 */
29 class Tx_Extbase_Tests_Unit_Utility_TypeHandlingTest extends Tx_Extbase_Tests_Unit_BaseTestCase {
30
31 /**
32 * @test
33 * @expectedException InvalidArgumentException
34 * @author Karsten Dambekalns <karsten@typo3.org>
35 */
36 public function parseTypeThrowsExceptionOnInvalidType() {
37 Tx_Extbase_Utility_TypeHandling::parseType('something not a type');
38 }
39
40 /**
41 * @test
42 * @expectedException InvalidArgumentException
43 * @author Karsten Dambekalns <karsten@typo3.org>
44 */
45 public function parseTypeThrowsExceptionOnInvalidElementTypeHint() {
46 Tx_Extbase_Utility_TypeHandling::parseType('string<integer>');
47 }
48
49 /**
50 * data provider for parseTypeReturnsArrayWithInformation
51 * @author Karsten Dambekalns <karsten@typo3.org>
52 */
53 public function types() {
54 return array(
55 array('int', array('type' => 'integer', 'elementType' => NULL)),
56 array('string', array('type' => 'string', 'elementType' => NULL)),
57 array('DateTime', array('type' => 'DateTime', 'elementType' => NULL)),
58 array('Tx_Extbase_Bar', array('type' => 'Tx_Extbase_Bar', 'elementType' => NULL)),
59 array('Tx_Extbase_Bar', array('type' => 'Tx_Extbase_Bar', 'elementType' => NULL)),
60 array('array<integer>', array('type' => 'array', 'elementType' => 'integer')),
61 array('ArrayObject<string>', array('type' => 'ArrayObject', 'elementType' => 'string')),
62 array('SplObjectStorage<Tx_Extbase_Bar>', array('type' => 'SplObjectStorage', 'elementType' => 'Tx_Extbase_Bar')),
63 array('SplObjectStorage<Tx_Extbase_Bar>', array('type' => 'SplObjectStorage', 'elementType' => 'Tx_Extbase_Bar')),
64 );
65 }
66
67 /**
68 * @test
69 * @dataProvider types
70 * @author Karsten Dambekalns <karsten@typo3.org>
71 */
72 public function parseTypeReturnsArrayWithInformation($type, $expectedResult) {
73 $this->assertEquals(
74 Tx_Extbase_Utility_TypeHandling::parseType($type),
75 $expectedResult
76 );
77 }
78
79 /**
80 * data provider for normalizeTypesReturnsNormalizedType
81 * @author Karsten Dambekalns <karsten@typo3.org>
82 */
83 public function normalizeTypes() {
84 return array(
85 array('int', 'integer'),
86 array('double', 'float'),
87 array('bool', 'boolean'),
88 array('string', 'string')
89 );
90 }
91
92 /**
93 * @test
94 * @dataProvider normalizeTypes
95 * @author Karsten Dambekalns <karsten@typo3.org>
96 */
97 public function normalizeTypesReturnsNormalizedType($type, $normalized) {
98 $this->assertEquals(Tx_Extbase_Utility_TypeHandling::normalizeType($type), $normalized);
99 }
100 }
101 ?>