TYPO3 CMS  TYPO3_6-2
TypeHandlingServiceTest.php
Go to the documentation of this file.
1 <?php
3 
21 
26 
27  public function setUp() {
28  $this->typeHandlingService = new \TYPO3\CMS\Extbase\Service\TypeHandlingService();
29  }
30 
36  $this->typeHandlingService->parseType('something not a type');
37  }
38 
45  $this->typeHandlingService->parseType('string<integer>');
46  }
47 
54  public function types() {
55  return array(
56  array('int', array('type' => 'integer', 'elementType' => NULL)),
57  array('string', array('type' => 'string', 'elementType' => NULL)),
58  array('DateTime', array('type' => 'DateTime', 'elementType' => NULL)),
59  array('\DateTime', array('type' => 'DateTime', 'elementType' => NULL)),
60  array('Tx_Extbase_Bar', array('type' => 'Tx_Extbase_Bar', 'elementType' => NULL)),
61  array('\\ExtbaseTeam\\BlogExample\\Foo\\Bar', array('type' => 'ExtbaseTeam\\BlogExample\\Foo\\Bar', 'elementType' => NULL)),
62  array('array<integer>', array('type' => 'array', 'elementType' => 'integer')),
63  array('ArrayObject<string>', array('type' => 'ArrayObject', 'elementType' => 'string')),
64  array('SplObjectStorage<Tx_Extbase_Bar>', array('type' => 'SplObjectStorage', 'elementType' => 'Tx_Extbase_Bar')),
65  array('SplObjectStorage<\\ExtbaseTeam\\BlogExample\\Foo\\Bar>', array('type' => 'SplObjectStorage', 'elementType' => 'ExtbaseTeam\\BlogExample\\Foo\\Bar')),
66  array('TYPO3\\CMS\\Extbase\\Persistence\\ObjectStorage<Tx_Extbase_Bar>', array('type' => 'TYPO3\\CMS\\Extbase\\Persistence\\ObjectStorage', 'elementType' => 'Tx_Extbase_Bar')),
67  array('TYPO3\\CMS\\Extbase\\Persistence\\ObjectStorage<\\ExtbaseTeam\\BlogExample\\Foo\\Bar>', array('type' => 'TYPO3\\CMS\\Extbase\\Persistence\\ObjectStorage', 'elementType' => 'ExtbaseTeam\\BlogExample\\Foo\\Bar')),
68  array('Tx_Extbase_Persistence_ObjectStorage<Tx_Extbase_Bar>', array('type' => 'Tx_Extbase_Persistence_ObjectStorage', 'elementType' => 'Tx_Extbase_Bar')),
69  array('Tx_Extbase_Persistence_ObjectStorage<\\ExtbaseTeam\\BlogExample\\Foo\\Bar>', array('type' => 'Tx_Extbase_Persistence_ObjectStorage', 'elementType' => 'ExtbaseTeam\\BlogExample\\Foo\\Bar')),
70  );
71  }
72 
80  public function parseTypeReturnsArrayWithInformation($type, $expectedResult) {
81  $this->assertEquals($expectedResult, $this->typeHandlingService->parseType($type));
82  }
83 
90  public function normalizeTypes() {
91  return array(
92  array('int', 'integer'),
93  array('double', 'float'),
94  array('bool', 'boolean'),
95  array('string', 'string')
96  );
97  }
98 
106  public function normalizeTypesReturnsNormalizedType($type, $normalized) {
107  $this->assertEquals($this->typeHandlingService->normalizeType($type), $normalized);
108  }
109 
116  public function nonLiteralTypes() {
117  return array(
118  array('DateTime'),
119  array('\\Foo\\Bar'),
120  array('array'),
121  array('ArrayObject'),
122  array('stdClass')
123  );
124  }
125 
133  $this->assertFalse($this->typeHandlingService->isLiteral($type));
134  }
135 
142  public function literalTypes() {
143  return array(
144  array('integer'),
145  array('int'),
146  array('float'),
147  array('double'),
148  array('boolean'),
149  array('bool'),
150  array('string')
151  );
152  }
153 
160  public function isLiteralReturnsTrueForLiteralType($type) {
161  $this->assertTrue($this->typeHandlingService->isLiteral($type));
162  }
163 
170  public function simpleTypes() {
171  return array(
172  array('integer', TRUE),
173  array('int', TRUE),
174  array('float', TRUE),
175  array('double', TRUE),
176  array('boolean', TRUE),
177  array('bool', TRUE),
178  array('string', TRUE),
179  array('DateTime', FALSE),
180  );
181  }
182 
191  $this->assertSame($result, $this->typeHandlingService->isSimpleType($type));
192  }
193 }
if($list_of_literals) if(!empty($literals)) if(!empty($literals)) $result
Analyse literals to prepend the N char to them if their contents aren&#39;t numeric.