|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace coreTests\Columns; |
|
4
|
|
|
|
|
5
|
|
|
|
|
6
|
|
|
use CommonTestClass; |
|
7
|
|
|
use kalanis\kw_connect\arrays\Row; |
|
8
|
|
|
use kalanis\kw_connect\core\ConnectException; |
|
9
|
|
|
use kalanis\kw_table\core\Table\Columns; |
|
10
|
|
|
|
|
11
|
|
|
|
|
12
|
|
|
class DeepColumnTest extends CommonTestClass |
|
13
|
|
|
{ |
|
14
|
|
|
/** |
|
15
|
|
|
* @throws ConnectException |
|
16
|
|
|
*/ |
|
17
|
|
|
public function testMultiSelect(): void |
|
18
|
|
|
{ |
|
19
|
|
|
$lib = new Columns\MultiSelectCheckbox('id'); |
|
20
|
|
|
$this->assertEquals('<input type="checkbox" name="multiselect[2]" class="multiselect">', $lib->getValue($this->getRow())); |
|
21
|
|
|
$this->assertFalse($lib->canOrder()); |
|
22
|
|
|
} |
|
23
|
|
|
|
|
24
|
|
|
/** |
|
25
|
|
|
* @throws ConnectException |
|
26
|
|
|
*/ |
|
27
|
|
|
public function testRowDataFormatted(): void |
|
28
|
|
|
{ |
|
29
|
|
|
$lib = new Columns\RowData(['name', 'size'], [$this, 'mergeSize']); |
|
30
|
|
|
$this->assertEquals('def::456', $lib->getValue($this->getRow())); |
|
31
|
|
|
} |
|
32
|
|
|
|
|
33
|
|
|
/** |
|
34
|
|
|
* @throws ConnectException |
|
35
|
|
|
*/ |
|
36
|
|
|
public function testMulti(): void |
|
37
|
|
|
{ |
|
38
|
|
|
$lib = new Columns\Multi('!!!', 'id'); |
|
39
|
|
|
$lib->addColumn(new Columns\Bold('name')); |
|
40
|
|
|
$lib->addColumn(new Columns\Currency('size', 'EUR')); |
|
41
|
|
|
$this->assertEquals('<strong>def</strong>!!!456 EUR', $lib->getValue($this->getRow())); |
|
42
|
|
|
$this->assertFalse($lib->canOrder()); |
|
43
|
|
|
} |
|
44
|
|
|
|
|
45
|
|
|
/** |
|
46
|
|
|
* @throws ConnectException |
|
47
|
|
|
*/ |
|
48
|
|
|
public function testMultiLink(): void |
|
49
|
|
|
{ |
|
50
|
|
|
$lib = new Columns\MultiColumnLink('id', [ |
|
51
|
|
|
new Columns\Bold('name'), |
|
52
|
|
|
new Columns\Currency('size', 'EUR'), |
|
53
|
|
|
], [$this, 'mergeSize']); |
|
54
|
|
|
$this->assertEquals('2::<strong>def</strong>::456 EUR', $lib->getValue($this->getRow())); |
|
55
|
|
|
$this->assertFalse($lib->canOrder()); |
|
56
|
|
|
} |
|
57
|
|
|
|
|
58
|
|
|
protected function getRow(): Row |
|
59
|
|
|
{ |
|
60
|
|
|
return new Row(['id' => 2, 'name' => 'def', 'desc' => '<lang_to_"convert">', 'size' => 456, 'enabled' => 0]); |
|
61
|
|
|
} |
|
62
|
|
|
|
|
63
|
|
|
public function mergeSize($params): string |
|
64
|
|
|
{ |
|
65
|
|
|
return implode('::', $params); |
|
66
|
|
|
} |
|
67
|
|
|
} |
|
68
|
|
|
|