TYPO3  7.6
DatabaseSpecificsTest.php
Go to the documentation of this file.
1 <?php
2 namespace TYPO3\CMS\Dbal\Tests\Unit\Database;
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 
19 
24 {
28  protected $subject;
29 
33  protected function setUp()
34  {
35  $GLOBALS['TYPO3_LOADED_EXT'] = array();
36 
38  $this->subject = GeneralUtility::makeInstance(\TYPO3\CMS\Dbal\Database\Specifics\NullSpecifics::class);
39  }
40 
47  public function determineMetaTypeFromNativeType($nativeType, $expected)
48  {
49  $result = $this->subject->getMetaFieldType($nativeType);
50  $this->assertSame($expected, $result);
51  }
52 
59  public function determineNativeTypeFromMetaType($metaType, $expected)
60  {
61  $result = $this->subject->getNativeFieldType($metaType);
62  $this->assertSame($expected, $result);
63  }
64 
72  public function determineNativeFieldLength($fieldType, $maxLength, $expected)
73  {
74  $result = $this->subject->getNativeFieldLength($fieldType, $maxLength);
75  $this->assertSame($expected, $result);
76  }
77 
81  public function determineMetaTypeProvider()
82  {
83  return array(
84  array('INT', 'I8'),
85  array('INTEGER', 'I8'),
86  array('TINYINT', 'I8'),
87  array('SMALLINT', 'I8'),
88  array('MEDIUMINT', 'I8'),
89  array('BIGINT', 'I8'),
90  array('DOUBLE', 'F'),
91  array('FLOAT', 'F'),
92  array('TIME', 'T'),
93  array('TIMESTAMP', 'T'),
94  array('DATETIME', 'T'),
95  array('DATE', 'D'),
96  array('YEAR', 'D'),
97  array('IMAGE', 'B'),
98  array('BLOB', 'B'),
99  array('MEDIUMBLOB', 'B'),
100  array('LONGBLOB', 'B'),
101  array('IMAGE', 'B'),
102  array('TEXT', 'XL'),
103  array('MEDIUMTEXT', 'XL'),
104  array('LONGTEXT', 'XL'),
105  array('STRING', 'C'),
106  array('CHAR', 'C'),
107  array('VARCHAR', 'C'),
108  array('TINYBLOB', 'C'),
109  array('TINYTEXT', 'C'),
110  array('ENUM', 'C'),
111  array('SET', 'C')
112  );
113  }
114 
118  public function determineNativeTypeProvider()
119  {
120  return array(
121  array('C', 'VARCHAR'),
122  array('C2', 'VARCHAR'),
123  array('X', 'LONGTEXT'),
124  array('X2', 'LONGTEXT'),
125  array('XL', 'LONGTEXT'),
126  array('B', 'LONGBLOB'),
127  array('D', 'DATE'),
128  array('T', 'DATETIME'),
129  array('L', 'TINYINT'),
130  array('I', 'BIGINT'),
131  array('I1', 'BIGINT'),
132  array('I2', 'BIGINT'),
133  array('I4', 'BIGINT'),
134  array('I8', 'BIGINT'),
135  array('F', 'DOUBLE'),
136  array('N', 'NUMERIC'),
137  array('U', 'U')
138  );
139  }
140 
145  {
146  return array(
147  array('INT', '4', '(11)'),
148  array('VARCHAR', -1, ''),
149  array('VARCHAR', 30, '(30)')
150  );
151  }
152 }