1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Backpack\CRUD\Tests\Unit\CrudPanel; |
4
|
|
|
|
5
|
|
|
use Backpack\CRUD\Tests\Unit\Models\User; |
6
|
|
|
|
7
|
|
|
/** |
8
|
|
|
* @covers Backpack\CRUD\app\Library\CrudPanel\Traits\Columns |
9
|
|
|
* @covers Backpack\CRUD\app\Library\CrudPanel\Traits\ColumnsProtectedMethods |
10
|
|
|
*/ |
11
|
|
|
class CrudPanelColumnsTest extends BaseDBCrudPanelTest |
12
|
|
|
{ |
13
|
|
|
private $oneColumnArray = [ |
14
|
|
|
'name' => 'column1', |
15
|
|
|
'label' => 'Column1', |
16
|
|
|
]; |
17
|
|
|
|
18
|
|
|
private $expectedOneColumnArray = [ |
19
|
|
|
'column1' => [ |
20
|
|
|
'label' => 'Column1', |
21
|
|
|
'name' => 'column1', |
22
|
|
|
'key' => 'column1', |
23
|
|
|
'type' => 'text', |
24
|
|
|
'tableColumn' => false, |
25
|
|
|
'orderable' => false, |
26
|
|
|
'searchLogic' => false, |
27
|
|
|
'priority' => 0, |
28
|
|
|
], |
29
|
|
|
]; |
30
|
|
|
|
31
|
|
|
private $otherOneColumnArray = [ |
32
|
|
|
'name' => 'column4', |
33
|
|
|
'label' => 'Column4', |
34
|
|
|
]; |
35
|
|
|
|
36
|
|
|
private $twoColumnsArray = [ |
37
|
|
|
[ |
38
|
|
|
'name' => 'column1', |
39
|
|
|
'label' => 'Column1', |
40
|
|
|
], |
41
|
|
|
[ |
42
|
|
|
'name' => 'column2', |
43
|
|
|
'label' => 'Column2', |
44
|
|
|
], |
45
|
|
|
]; |
46
|
|
|
|
47
|
|
|
private $expectedTwoColumnsArray = [ |
48
|
|
|
'column1' => [ |
49
|
|
|
'name' => 'column1', |
50
|
|
|
'key' => 'column1', |
51
|
|
|
'label' => 'Column1', |
52
|
|
|
'type' => 'text', |
53
|
|
|
'tableColumn' => false, |
54
|
|
|
'orderable' => false, |
55
|
|
|
'searchLogic' => false, |
56
|
|
|
'priority' => 0, |
57
|
|
|
|
58
|
|
|
], |
59
|
|
|
'column2' => [ |
60
|
|
|
'name' => 'column2', |
61
|
|
|
'key' => 'column2', |
62
|
|
|
'label' => 'Column2', |
63
|
|
|
'type' => 'text', |
64
|
|
|
'tableColumn' => false, |
65
|
|
|
'orderable' => false, |
66
|
|
|
'searchLogic' => false, |
67
|
|
|
'priority' => 1, |
68
|
|
|
], |
69
|
|
|
]; |
70
|
|
|
|
71
|
|
|
private $threeColumnsArray = [ |
72
|
|
|
[ |
73
|
|
|
'name' => 'column1', |
74
|
|
|
'label' => 'Column1', |
75
|
|
|
], |
76
|
|
|
[ |
77
|
|
|
'name' => 'column2', |
78
|
|
|
'label' => 'Column2', |
79
|
|
|
], |
80
|
|
|
[ |
81
|
|
|
'name' => 'column3', |
82
|
|
|
'label' => 'Column3', |
83
|
|
|
], |
84
|
|
|
]; |
85
|
|
|
|
86
|
|
|
private $expectedThreeColumnsArray = [ |
87
|
|
|
'column1' => [ |
88
|
|
|
'name' => 'column1', |
89
|
|
|
'key' => 'column1', |
90
|
|
|
'label' => 'Column1', |
91
|
|
|
'type' => 'text', |
92
|
|
|
'tableColumn' => false, |
93
|
|
|
'orderable' => false, |
94
|
|
|
'searchLogic' => false, |
95
|
|
|
'priority' => 0, |
96
|
|
|
], |
97
|
|
|
'column2' => [ |
98
|
|
|
'name' => 'column2', |
99
|
|
|
'key' => 'column2', |
100
|
|
|
'label' => 'Column2', |
101
|
|
|
'type' => 'text', |
102
|
|
|
'tableColumn' => false, |
103
|
|
|
'orderable' => false, |
104
|
|
|
'searchLogic' => false, |
105
|
|
|
'priority' => 1, |
106
|
|
|
], |
107
|
|
|
'column3' => [ |
108
|
|
|
'name' => 'column3', |
109
|
|
|
'key' => 'column3', |
110
|
|
|
'label' => 'Column3', |
111
|
|
|
'type' => 'text', |
112
|
|
|
'tableColumn' => false, |
113
|
|
|
'orderable' => false, |
114
|
|
|
'searchLogic' => false, |
115
|
|
|
'priority' => 2, |
116
|
|
|
], |
117
|
|
|
]; |
118
|
|
|
|
119
|
|
|
private $expectedRelationColumnsArrayWithoutPro = [ |
120
|
|
|
'accountDetails' => [ |
121
|
|
|
'name' => 'accountDetails', |
122
|
|
|
'label' => 'AccountDetails', |
123
|
|
|
'type' => 'text', |
124
|
|
|
'key' => 'accountDetails', |
125
|
|
|
'priority' => 0, |
126
|
|
|
'tableColumn' => false, |
127
|
|
|
'orderable' => false, |
128
|
|
|
'searchLogic' => false, |
129
|
|
|
'entity' => 'accountDetails', |
130
|
|
|
'model' => 'Backpack\CRUD\Tests\Unit\Models\AccountDetails', |
131
|
|
|
'relation_type' => 'HasOne', |
132
|
|
|
'attribute' => 'nickname', |
133
|
|
|
], |
134
|
|
|
'accountDetails__nickname' => [ |
135
|
|
|
'name' => 'accountDetails.nickname', |
136
|
|
|
'label' => 'AccountDetails.nickname', |
137
|
|
|
'type' => 'text', |
138
|
|
|
'key' => 'accountDetails__nickname', |
139
|
|
|
'priority' => 1, |
140
|
|
|
'attribute' => 'nickname', |
141
|
|
|
'tableColumn' => false, |
142
|
|
|
'orderable' => false, |
143
|
|
|
'searchLogic' => false, |
144
|
|
|
'relation_type' => 'HasOne', |
145
|
|
|
'entity' => 'accountDetails.nickname', |
146
|
|
|
'model' => 'Backpack\CRUD\Tests\Unit\Models\AccountDetails', |
147
|
|
|
], |
148
|
|
|
'accountDetails__user' => [ |
149
|
|
|
'name' => 'accountDetails.user', |
150
|
|
|
'label' => 'AccountDetails.user', |
151
|
|
|
'type' => 'select', |
152
|
|
|
'key' => 'accountDetails__user', |
153
|
|
|
'priority' => 2, |
154
|
|
|
'tableColumn' => false, |
155
|
|
|
'orderable' => false, |
156
|
|
|
'searchLogic' => false, |
157
|
|
|
'relation_type' => 'BelongsTo', |
158
|
|
|
'entity' => 'accountDetails.user', |
159
|
|
|
'model' => 'Backpack\CRUD\Tests\Unit\Models\User', |
160
|
|
|
'attribute' => 'name', |
161
|
|
|
], |
162
|
|
|
]; |
163
|
|
|
|
164
|
|
|
private $expectedRelationColumnsArrayWithPro = [ |
165
|
|
|
'accountDetails' => [ |
166
|
|
|
'name' => 'accountDetails', |
167
|
|
|
'label' => 'AccountDetails', |
168
|
|
|
'type' => 'relationship', |
169
|
|
|
'key' => 'accountDetails', |
170
|
|
|
'priority' => 0, |
171
|
|
|
'tableColumn' => false, |
172
|
|
|
'orderable' => false, |
173
|
|
|
'searchLogic' => false, |
174
|
|
|
'entity' => 'accountDetails', |
175
|
|
|
'model' => 'Backpack\CRUD\Tests\Unit\Models\AccountDetails', |
176
|
|
|
'relation_type' => 'HasOne', |
177
|
|
|
'attribute' => 'nickname', |
178
|
|
|
], |
179
|
|
|
'accountDetails__nickname' => [ |
180
|
|
|
'name' => 'accountDetails.nickname', |
181
|
|
|
'label' => 'AccountDetails.nickname', |
182
|
|
|
'type' => 'relationship', |
183
|
|
|
'key' => 'accountDetails__nickname', |
184
|
|
|
'priority' => 1, |
185
|
|
|
'attribute' => 'nickname', |
186
|
|
|
'tableColumn' => false, |
187
|
|
|
'orderable' => false, |
188
|
|
|
'searchLogic' => false, |
189
|
|
|
'relation_type' => 'HasOne', |
190
|
|
|
'entity' => 'accountDetails.nickname', |
191
|
|
|
'model' => 'Backpack\CRUD\Tests\Unit\Models\AccountDetails', |
192
|
|
|
], |
193
|
|
|
'accountDetails__user' => [ |
194
|
|
|
'name' => 'accountDetails.user', |
195
|
|
|
'label' => 'AccountDetails.user', |
196
|
|
|
'type' => 'relationship', |
197
|
|
|
'key' => 'accountDetails__user', |
198
|
|
|
'priority' => 2, |
199
|
|
|
'tableColumn' => false, |
200
|
|
|
'orderable' => false, |
201
|
|
|
'searchLogic' => false, |
202
|
|
|
'relation_type' => 'BelongsTo', |
203
|
|
|
'entity' => 'accountDetails.user', |
204
|
|
|
'model' => 'Backpack\CRUD\Tests\Unit\Models\User', |
205
|
|
|
'attribute' => 'name', |
206
|
|
|
], |
207
|
|
|
]; |
208
|
|
|
|
209
|
|
|
private $relationColumnArray = [ |
210
|
|
|
'name' => 'nickname', |
211
|
|
|
'type' => 'select', |
212
|
|
|
'entity' => 'accountDetails', |
213
|
|
|
'attribute' => 'nickname', |
214
|
|
|
]; |
215
|
|
|
|
216
|
|
|
private $expectedRelationColumnArray = [ |
217
|
|
|
'nickname' => [ |
218
|
|
|
'name' => 'nickname', |
219
|
|
|
'type' => 'select', |
220
|
|
|
'entity' => 'accountDetails', |
221
|
|
|
'attribute' => 'nickname', |
222
|
|
|
'label' => 'Nickname', |
223
|
|
|
'model' => 'Backpack\CRUD\Tests\Unit\Models\AccountDetails', |
224
|
|
|
'key' => 'nickname', |
225
|
|
|
'tableColumn' => false, |
226
|
|
|
'orderable' => false, |
227
|
|
|
'searchLogic' => false, |
228
|
|
|
'priority' => 0, |
229
|
|
|
'relation_type' => 'HasOne', |
230
|
|
|
], |
231
|
|
|
]; |
232
|
|
|
|
233
|
|
|
private $nestedRelationColumnArray = [ |
234
|
|
|
'name' => 'accountDetails.article', |
235
|
|
|
]; |
236
|
|
|
|
237
|
|
|
private $secondNestedRelationColumnArray = [ |
238
|
|
|
'name' => 'accountDetails.article', |
239
|
|
|
'attribute' => 'content', |
240
|
|
|
'key' => 'ac_article_content', |
241
|
|
|
]; |
242
|
|
|
|
243
|
|
|
private $expectedNestedRelationColumnArrayWithPro = [ |
244
|
|
|
'accountDetails__article' => [ |
245
|
|
|
'name' => 'accountDetails.article', |
246
|
|
|
'type' => 'relationship', |
247
|
|
|
'entity' => 'accountDetails.article', |
248
|
|
|
'label' => 'AccountDetails.article', |
249
|
|
|
'model' => 'Backpack\CRUD\Tests\Unit\Models\Article', |
250
|
|
|
'key' => 'accountDetails__article', |
251
|
|
|
'tableColumn' => false, |
252
|
|
|
'orderable' => false, |
253
|
|
|
'searchLogic' => false, |
254
|
|
|
'priority' => 0, |
255
|
|
|
'relation_type' => 'BelongsTo', |
256
|
|
|
'attribute' => 'content', |
257
|
|
|
], |
258
|
|
|
'ac_article_content' => [ |
259
|
|
|
'name' => 'accountDetails.article', |
260
|
|
|
'type' => 'relationship', |
261
|
|
|
'entity' => 'accountDetails.article', |
262
|
|
|
'label' => 'AccountDetails.article', |
263
|
|
|
'model' => 'Backpack\CRUD\Tests\Unit\Models\Article', |
264
|
|
|
'key' => 'ac_article_content', |
265
|
|
|
'tableColumn' => false, |
266
|
|
|
'orderable' => false, |
267
|
|
|
'searchLogic' => false, |
268
|
|
|
'priority' => 1, |
269
|
|
|
'relation_type' => 'BelongsTo', |
270
|
|
|
'attribute' => 'content', |
271
|
|
|
], |
272
|
|
|
]; |
273
|
|
|
|
274
|
|
|
private $expectedNestedRelationColumnArrayWithoutPro = [ |
275
|
|
|
'accountDetails__article' => [ |
276
|
|
|
'name' => 'accountDetails.article', |
277
|
|
|
'type' => 'select', |
278
|
|
|
'entity' => 'accountDetails.article', |
279
|
|
|
'label' => 'AccountDetails.article', |
280
|
|
|
'model' => 'Backpack\CRUD\Tests\Unit\Models\Article', |
281
|
|
|
'key' => 'accountDetails__article', |
282
|
|
|
'tableColumn' => false, |
283
|
|
|
'orderable' => false, |
284
|
|
|
'searchLogic' => false, |
285
|
|
|
'priority' => 0, |
286
|
|
|
'relation_type' => 'BelongsTo', |
287
|
|
|
'attribute' => 'content', |
288
|
|
|
], |
289
|
|
|
'ac_article_content' => [ |
290
|
|
|
'name' => 'accountDetails.article', |
291
|
|
|
'type' => 'select', |
292
|
|
|
'entity' => 'accountDetails.article', |
293
|
|
|
'label' => 'AccountDetails.article', |
294
|
|
|
'model' => 'Backpack\CRUD\Tests\Unit\Models\Article', |
295
|
|
|
'key' => 'ac_article_content', |
296
|
|
|
'tableColumn' => false, |
297
|
|
|
'orderable' => false, |
298
|
|
|
'searchLogic' => false, |
299
|
|
|
'priority' => 1, |
300
|
|
|
'relation_type' => 'BelongsTo', |
301
|
|
|
'attribute' => 'content', |
302
|
|
|
], |
303
|
|
|
]; |
304
|
|
|
|
305
|
|
|
/** |
306
|
|
|
* Setup the test environment. |
307
|
|
|
* |
308
|
|
|
* @return void |
309
|
|
|
*/ |
310
|
|
|
protected function setUp(): void |
311
|
|
|
{ |
312
|
|
|
parent::setUp(); |
313
|
|
|
|
314
|
|
|
$this->crudPanel->setOperation('list'); |
315
|
|
|
} |
316
|
|
|
|
317
|
|
|
public function testAddColumnByName() |
318
|
|
|
{ |
319
|
|
|
$this->crudPanel->addColumn('column1'); |
320
|
|
|
|
321
|
|
|
$this->assertEquals($this->expectedOneColumnArray, $this->crudPanel->columns()); |
322
|
|
|
} |
323
|
|
|
|
324
|
|
|
public function testAddColumnsByName() |
325
|
|
|
{ |
326
|
|
|
$this->crudPanel->addColumns(['column1', 'column2']); |
327
|
|
|
|
328
|
|
|
$this->assertEquals(2, count($this->crudPanel->columns())); |
329
|
|
|
$this->assertEquals($this->expectedTwoColumnsArray, $this->crudPanel->columns()); |
330
|
|
|
} |
331
|
|
|
|
332
|
|
|
public function testAddColumnAsArray() |
333
|
|
|
{ |
334
|
|
|
$this->crudPanel->addColumn($this->oneColumnArray); |
335
|
|
|
|
336
|
|
|
$this->assertEquals($this->expectedOneColumnArray, $this->crudPanel->columns()); |
337
|
|
|
} |
338
|
|
|
|
339
|
|
|
public function testAddColumnsAsArray() |
340
|
|
|
{ |
341
|
|
|
$this->crudPanel->addColumns($this->twoColumnsArray); |
342
|
|
|
|
343
|
|
|
$this->assertEquals(2, count($this->crudPanel->columns())); |
344
|
|
|
$this->assertEquals($this->expectedTwoColumnsArray, $this->crudPanel->columns()); |
345
|
|
|
} |
346
|
|
|
|
347
|
|
|
public function testAddColumnNotArray() |
348
|
|
|
{ |
349
|
|
|
$this->expectException(PHP_MAJOR_VERSION == 7 ? \ErrorException::class : \TypeError::class); |
350
|
|
|
// Why? When calling count() on a non-countable entity, |
351
|
|
|
// PHP 7.x will through ErrorException, but PHP 8.x will throw TypeError. |
352
|
|
|
|
353
|
|
|
$this->crudPanel->addColumns('column1'); |
|
|
|
|
354
|
|
|
} |
355
|
|
|
|
356
|
|
|
public function testAddRelationsByName() |
357
|
|
|
{ |
358
|
|
|
$this->crudPanel->setModel(User::class); |
359
|
|
|
$this->crudPanel->addColumn('accountDetails'); |
360
|
|
|
$this->crudPanel->addColumn('accountDetails.nickname'); |
361
|
|
|
$this->crudPanel->addColumn('accountDetails.user'); |
362
|
|
|
|
363
|
|
|
if (backpack_pro()) { |
364
|
|
|
$this->assertEquals($this->expectedRelationColumnsArrayWithPro, $this->crudPanel->columns()); |
365
|
|
|
} else { |
366
|
|
|
$this->assertEquals($this->expectedRelationColumnsArrayWithoutPro, $this->crudPanel->columns()); |
367
|
|
|
} |
368
|
|
|
} |
369
|
|
|
|
370
|
|
|
public function testAddRelationColumn() |
371
|
|
|
{ |
372
|
|
|
$this->crudPanel->setModel(User::class); |
373
|
|
|
$this->crudPanel->addColumn($this->relationColumnArray); |
374
|
|
|
|
375
|
|
|
$this->assertEquals($this->expectedRelationColumnArray, $this->crudPanel->columns()); |
376
|
|
|
} |
377
|
|
|
|
378
|
|
|
public function testAddNestedRelationColumn() |
379
|
|
|
{ |
380
|
|
|
$this->crudPanel->setModel(User::class); |
381
|
|
|
$this->crudPanel->addColumn($this->nestedRelationColumnArray); |
382
|
|
|
$this->crudPanel->addColumn($this->secondNestedRelationColumnArray); |
383
|
|
|
|
384
|
|
|
if (backpack_pro()) { |
385
|
|
|
$this->assertEquals($this->expectedNestedRelationColumnArrayWithPro, $this->crudPanel->columns()); |
386
|
|
|
} else { |
387
|
|
|
$this->assertEquals($this->expectedNestedRelationColumnArrayWithoutPro, $this->crudPanel->columns()); |
388
|
|
|
} |
389
|
|
|
} |
390
|
|
|
|
391
|
|
|
public function testMoveColumnBefore() |
392
|
|
|
{ |
393
|
|
|
$this->crudPanel->addColumns($this->twoColumnsArray); |
394
|
|
|
|
395
|
|
|
$this->crudPanel->beforeColumn('column1'); |
396
|
|
|
|
397
|
|
|
$keys = array_keys($this->crudPanel->columns()); |
398
|
|
|
$this->assertEquals($this->expectedTwoColumnsArray['column2'], $this->crudPanel->columns()[$keys[0]]); |
399
|
|
|
$this->assertEquals(['column2', 'column1'], $keys); |
400
|
|
|
} |
401
|
|
|
|
402
|
|
|
public function testMoveColumnBeforeUnknownColumnName() |
403
|
|
|
{ |
404
|
|
|
$this->crudPanel->addColumns($this->twoColumnsArray); |
405
|
|
|
|
406
|
|
|
$this->crudPanel->beforeColumn('column3'); |
407
|
|
|
|
408
|
|
|
$this->assertEquals(array_keys($this->expectedTwoColumnsArray), array_keys($this->crudPanel->columns())); |
409
|
|
|
} |
410
|
|
|
|
411
|
|
|
public function testMoveColumnAfter() |
412
|
|
|
{ |
413
|
|
|
$this->crudPanel->addColumns($this->threeColumnsArray); |
414
|
|
|
|
415
|
|
|
$this->crudPanel->afterColumn('column1'); |
416
|
|
|
|
417
|
|
|
$keys = array_keys($this->crudPanel->columns()); |
418
|
|
|
$this->assertEquals($this->expectedThreeColumnsArray['column3'], $this->crudPanel->columns()[$keys[1]]); |
419
|
|
|
$this->assertEquals(['column1', 'column3', 'column2'], $keys); |
420
|
|
|
} |
421
|
|
|
|
422
|
|
|
public function testMoveColumnAfterUnknownColumnName() |
423
|
|
|
{ |
424
|
|
|
$this->crudPanel->addColumns($this->twoColumnsArray); |
425
|
|
|
|
426
|
|
|
$this->crudPanel->afterColumn('column3'); |
427
|
|
|
|
428
|
|
|
$this->assertEquals(array_keys($this->expectedTwoColumnsArray), array_keys($this->crudPanel->columns())); |
429
|
|
|
} |
430
|
|
|
|
431
|
|
|
public function testRemoveColumnByName() |
432
|
|
|
{ |
433
|
|
|
$this->crudPanel->addColumns(['column1', 'column2', 'column3']); |
434
|
|
|
|
435
|
|
|
$this->crudPanel->removeColumn('column1'); |
436
|
|
|
|
437
|
|
|
$this->assertEquals(2, count($this->crudPanel->columns())); |
438
|
|
|
$this->assertEquals(['column2', 'column3'], array_keys($this->crudPanel->columns())); |
439
|
|
|
$this->assertNotContains($this->oneColumnArray, $this->crudPanel->columns()); |
440
|
|
|
} |
441
|
|
|
|
442
|
|
|
public function testRemoveUnknownColumnName() |
443
|
|
|
{ |
444
|
|
|
$unknownColumnName = 'column4'; |
445
|
|
|
$this->crudPanel->addColumns(['column1', 'column2', 'column3']); |
446
|
|
|
|
447
|
|
|
$this->crudPanel->removeColumn($unknownColumnName); |
448
|
|
|
|
449
|
|
|
$this->assertEquals(3, count($this->crudPanel->columns())); |
450
|
|
|
$this->assertEquals(['column1', 'column2', 'column3'], array_keys($this->crudPanel->columns())); |
451
|
|
|
$this->assertNotContains($this->otherOneColumnArray, $this->crudPanel->columns()); |
452
|
|
|
} |
453
|
|
|
|
454
|
|
|
public function testRemoveColumnsByName() |
455
|
|
|
{ |
456
|
|
|
$this->crudPanel->addColumns(['column1', 'column2', 'column3']); |
457
|
|
|
|
458
|
|
|
$this->crudPanel->removeColumns($this->twoColumnsArray); |
459
|
|
|
|
460
|
|
|
$this->assertEquals(1, count($this->crudPanel->columns())); |
461
|
|
|
$this->assertEquals(['column3'], array_keys($this->crudPanel->columns())); |
462
|
|
|
$this->assertNotEquals($this->expectedThreeColumnsArray, $this->crudPanel->columns()); |
463
|
|
|
} |
464
|
|
|
|
465
|
|
|
public function testRemoveUnknownColumnsByName() |
466
|
|
|
{ |
467
|
|
|
$unknownColumnNames = ['column4', 'column5']; |
468
|
|
|
$this->crudPanel->addColumns(['column1', 'column2', 'column3']); |
469
|
|
|
|
470
|
|
|
$this->crudPanel->removeColumns($unknownColumnNames); |
471
|
|
|
|
472
|
|
|
$this->assertEquals(3, count($this->crudPanel->columns())); |
473
|
|
|
$this->assertEquals(['column1', 'column2', 'column3'], array_keys($this->crudPanel->columns())); |
474
|
|
|
$this->assertNotContains($this->otherOneColumnArray, $this->crudPanel->columns()); |
475
|
|
|
} |
476
|
|
|
|
477
|
|
|
public function testSetColumnDetails() |
478
|
|
|
{ |
479
|
|
|
$this->markTestIncomplete('Not correctly implemented'); |
480
|
|
|
|
481
|
|
|
// TODO: refactor crud panel sync method |
482
|
|
|
} |
483
|
|
|
|
484
|
|
|
public function testSetColumnsDetails() |
485
|
|
|
{ |
486
|
|
|
$this->markTestIncomplete('Not correctly implemented'); |
487
|
|
|
|
488
|
|
|
// TODO: refactor crud panel sync method |
489
|
|
|
} |
490
|
|
|
|
491
|
|
|
public function testOrderColumns() |
492
|
|
|
{ |
493
|
|
|
$this->crudPanel->addColumns($this->threeColumnsArray); |
494
|
|
|
|
495
|
|
|
$this->crudPanel->orderColumns(['column2', 'column1', 'column3']); |
496
|
|
|
|
497
|
|
|
$this->assertEquals(['column2', 'column1', 'column3'], array_keys($this->crudPanel->columns())); |
498
|
|
|
} |
499
|
|
|
|
500
|
|
|
public function testOrderColumnsIncompleteList() |
501
|
|
|
{ |
502
|
|
|
$this->crudPanel->addColumns($this->threeColumnsArray); |
503
|
|
|
|
504
|
|
|
$this->crudPanel->orderColumns(['column2', 'column3']); |
505
|
|
|
|
506
|
|
|
$this->assertEquals(['column2', 'column3', 'column1'], array_keys($this->crudPanel->columns())); |
507
|
|
|
} |
508
|
|
|
|
509
|
|
|
public function testOrderColumnsEmptyList() |
510
|
|
|
{ |
511
|
|
|
$this->crudPanel->addColumns($this->threeColumnsArray); |
512
|
|
|
|
513
|
|
|
$this->crudPanel->orderColumns([]); |
514
|
|
|
|
515
|
|
|
$this->assertEquals($this->expectedThreeColumnsArray, $this->crudPanel->columns()); |
516
|
|
|
} |
517
|
|
|
|
518
|
|
|
public function testOrderColumnsUnknownList() |
519
|
|
|
{ |
520
|
|
|
$this->crudPanel->addColumns($this->threeColumnsArray); |
521
|
|
|
|
522
|
|
|
$this->crudPanel->orderColumns(['column4', 'column5', 'column6']); |
523
|
|
|
|
524
|
|
|
$this->assertEquals($this->expectedThreeColumnsArray, $this->crudPanel->columns()); |
525
|
|
|
} |
526
|
|
|
|
527
|
|
|
public function testOrderColumnsMixedList() |
528
|
|
|
{ |
529
|
|
|
$this->crudPanel->addColumns($this->threeColumnsArray); |
530
|
|
|
|
531
|
|
|
$this->crudPanel->orderColumns(['column2', 'column5', 'column6']); |
532
|
|
|
|
533
|
|
|
$this->assertEquals(['column2', 'column1', 'column3'], array_keys($this->crudPanel->columns())); |
534
|
|
|
} |
535
|
|
|
|
536
|
|
|
public function testItCanChangeTheColumnKey() |
537
|
|
|
{ |
538
|
|
|
|
539
|
|
|
$this->crudPanel->column('test'); |
540
|
|
|
|
541
|
|
|
$this->assertEquals('test', $this->crudPanel->columns()['test']['key']); |
542
|
|
|
|
543
|
|
|
$this->crudPanel->column('test')->key('new_key'); |
544
|
|
|
|
545
|
|
|
$this->assertEquals('new_key', $this->crudPanel->columns()['new_key']['key']); |
546
|
|
|
|
547
|
|
|
} |
548
|
|
|
} |
549
|
|
|
|