1
|
|
|
<?php |
2
|
|
|
namespace Dennis\Seeder\Tests\Unit\Provider; |
3
|
|
|
|
4
|
|
|
/*************************************************************** |
5
|
|
|
* Copyright notice |
6
|
|
|
* |
7
|
|
|
* (c) 2016 Dennis Römmich <[email protected]> |
8
|
|
|
* |
9
|
|
|
* All rights reserved |
10
|
|
|
* |
11
|
|
|
* This script is part of the TYPO3 project. The TYPO3 project is |
12
|
|
|
* free software; you can redistribute it and/or modify |
13
|
|
|
* it under the terms of the GNU General Public License as published by |
14
|
|
|
* the Free Software Foundation; either version 2 of the License, or |
15
|
|
|
* (at your option) any later version. |
16
|
|
|
* |
17
|
|
|
* The GNU General Public License can be found at |
18
|
|
|
* http://www.gnu.org/copyleft/gpl.html. |
19
|
|
|
* |
20
|
|
|
* This script is distributed in the hope that it will be useful, |
21
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
22
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
23
|
|
|
* GNU General Public License for more details. |
24
|
|
|
* |
25
|
|
|
* This copyright notice MUST APPEAR in all copies of the script! |
26
|
|
|
***************************************************************/ |
27
|
|
|
use Dennis\Seeder\Tests\Unit\AccessibleTraitForTest; |
28
|
|
|
use Dennis\Seeder\Traits\Language; |
29
|
|
|
use Dennis\Seeder\Provider\TableConfiguration; |
30
|
|
|
use TYPO3\CMS\Core\Tests\UnitTestCase; |
31
|
|
|
|
32
|
|
|
/** |
33
|
|
|
* Test case for class \Dennis\Seeder\Tests\Provider\TableConfigurationTest |
34
|
|
|
* |
35
|
|
|
* @author Dennis Römmich <[email protected]> |
36
|
|
|
*/ |
37
|
|
|
class TableConfigurationTest extends UnitTestCase |
|
|
|
|
38
|
|
|
{ |
39
|
|
|
use Language, AccessibleTraitForTest; |
40
|
|
|
|
41
|
|
|
/** |
42
|
|
|
* subject |
43
|
|
|
* |
44
|
|
|
* @var TableConfiguration $subject |
45
|
|
|
*/ |
46
|
|
|
protected $subject; |
47
|
|
|
|
48
|
|
|
/** |
49
|
|
|
* TABLE |
50
|
|
|
*/ |
51
|
|
|
const TABLE = 'pages'; |
52
|
|
|
|
53
|
|
|
/** |
54
|
|
|
* setUp |
55
|
|
|
* |
56
|
|
|
* @return void |
57
|
|
|
*/ |
58
|
|
|
public function setUp() |
|
|
|
|
59
|
|
|
{ |
60
|
|
|
$GLOBALS['LANG'] = new \TYPO3\CMS\Lang\LanguageService(); |
61
|
|
|
$GLOBALS['LANG']->init('de'); |
62
|
|
|
|
63
|
|
|
$GLOBALS['TCA'] = [ |
64
|
|
|
'pages' => [ |
65
|
|
|
'ctrl' => [ |
66
|
|
|
'title' => 'LLL:EXT:lang/locallang_tca.xlf:pages' |
67
|
|
|
], |
68
|
|
|
'columns' => [ |
69
|
|
|
'title' => [ |
70
|
|
|
'config' => [ |
71
|
|
|
'type' => 'array', |
72
|
|
|
'size' => '50', |
73
|
|
|
'max' => '255', |
74
|
|
|
'eval' => 'trim,required', |
75
|
|
|
], |
76
|
|
|
], |
77
|
|
|
'doctype' => [ |
78
|
|
|
'exclude' => 1, |
79
|
|
|
'label' => 'LLL:EXT:lang/locallang_general.xlf:LGL.type', |
80
|
|
|
'config' => [ |
81
|
|
|
'type' => 'select', |
82
|
|
|
'renderType' => 'selectSingle', |
83
|
|
|
'default' => '1' |
84
|
|
|
], |
85
|
|
|
], |
86
|
|
|
], |
87
|
|
|
], |
88
|
|
|
'fe_users' => [], |
89
|
|
|
]; |
90
|
|
|
|
91
|
|
|
$this->subject = new TableConfiguration('pages'); |
92
|
|
|
} |
93
|
|
|
|
94
|
|
|
/** |
95
|
|
|
* tableConfigurationContainsArray |
96
|
|
|
* |
97
|
|
|
* @test |
98
|
|
|
*/ |
99
|
|
|
public function tableConfigurationContainsArray() |
100
|
|
|
{ |
101
|
|
|
$tableConfiguration = $this->accessProtectedProperty($this->subject, 'tableConfiguration'); |
102
|
|
|
$this->assertTrue(is_array($tableConfiguration)); |
103
|
|
|
} |
104
|
|
|
|
105
|
|
|
/** |
106
|
|
|
* tablePropertyContainsString |
107
|
|
|
* |
108
|
|
|
* @test |
109
|
|
|
*/ |
110
|
|
|
public function tablePropertyContainsString() |
111
|
|
|
{ |
112
|
|
|
$table = $this->accessProtectedProperty($this->subject, 'name'); |
113
|
|
|
$this->assertSame(self::TABLE, $table); |
114
|
|
|
} |
115
|
|
|
|
116
|
|
|
/** |
117
|
|
|
* getNameReturnsTableName |
118
|
|
|
* |
119
|
|
|
* @test |
120
|
|
|
*/ |
121
|
|
|
public function getNameReturnsTableName() |
122
|
|
|
{ |
123
|
|
|
$this->assertSame(self::TABLE, $this->subject->getName()); |
124
|
|
|
} |
125
|
|
|
|
126
|
|
|
/** |
127
|
|
|
* getTitleReturnsTitleOfTable |
128
|
|
|
* |
129
|
|
|
* @test |
130
|
|
|
*/ |
131
|
|
|
public function getTitleReturnsTitleOfTable() |
132
|
|
|
{ |
133
|
|
|
$this->assertSame('Page', $this->subject->getTitle()); |
134
|
|
|
} |
135
|
|
|
|
136
|
|
|
/** |
137
|
|
|
* getColumnsReturnsArray |
138
|
|
|
* |
139
|
|
|
* @test |
140
|
|
|
*/ |
141
|
|
|
public function getColumnsReturnsArray() |
142
|
|
|
{ |
143
|
|
|
$this->assertSame(['title', 'doctype'], $this->subject->getColumns()); |
144
|
|
|
} |
145
|
|
|
|
146
|
|
|
/** |
147
|
|
|
* getColumnConfigurationThrowsExceptionWhenTableNotExist |
148
|
|
|
* |
149
|
|
|
* @test |
150
|
|
|
*/ |
151
|
|
|
public function getColumnConfigurationThrowsExceptionWhenTableNotExist() |
152
|
|
|
{ |
153
|
|
|
$column = 'FooBar'; |
154
|
|
|
$this->setExpectedException( |
155
|
|
|
'InvalidArgumentException', |
156
|
|
|
'Column ' . $column . ' does not exist for table ' . self::TABLE |
157
|
|
|
); |
158
|
|
|
$this->assertSame($this->getExpectedException(), $this->subject->getColumnConfiguration($column)); |
159
|
|
|
} |
160
|
|
|
|
161
|
|
|
/** |
162
|
|
|
* getColumnConfigurationReturnsArray |
163
|
|
|
* |
164
|
|
|
* @test |
165
|
|
|
*/ |
166
|
|
|
public function getColumnConfigurationReturnsArray() |
167
|
|
|
{ |
168
|
|
|
$expected = [ |
169
|
|
|
'title' => [ |
170
|
|
|
'type' => 'array', |
171
|
|
|
'size' => '50', |
172
|
|
|
'max' => '255', |
173
|
|
|
'eval' => 'trim,required', |
174
|
|
|
], |
175
|
|
|
]; |
176
|
|
|
$this->assertSame($expected, $this->subject->getColumnConfiguration('title')); |
177
|
|
|
} |
178
|
|
|
|
179
|
|
|
/** |
180
|
|
|
* getAllTablesReturnsArray |
181
|
|
|
* |
182
|
|
|
* @test |
183
|
|
|
*/ |
184
|
|
|
public function getAllTablesReturnsArray() |
185
|
|
|
{ |
186
|
|
|
$this->assertSame(['pages' => 'pages', 'fe_users' => 'fe_users'], $this->subject->getAllTables()); |
187
|
|
|
} |
188
|
|
|
} |
189
|
|
|
|
This class, trait or interface has been deprecated. The supplier of the file has supplied an explanatory message.
The explanatory message should give you some clue as to whether and when the type will be removed from the class and what other constant to use instead.