| Total Complexity | 5 |
| Total Lines | 31 |
| Duplicated Lines | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 12 | class FuncColumnTest extends CommonTestClass |
||
| 13 | { |
||
| 14 | /** |
||
| 15 | * @throws ConnectException |
||
| 16 | */ |
||
| 17 | public function testFunc(): void |
||
| 18 | { |
||
| 19 | $lib = new Columns\Func('name', [$this, 'columnCallback'], ['x' => 'ytzz']); |
||
| 20 | $this->assertEquals('>==> defytzz', $lib->getValue($this->getRow())); |
||
| 21 | } |
||
| 22 | |||
| 23 | /** |
||
| 24 | * @throws ConnectException |
||
| 25 | */ |
||
| 26 | public function testEscFunc(): void |
||
| 27 | { |
||
| 28 | $lib = new Columns\EscFunc('name', [$this, 'columnCallback']); |
||
| 29 | $this->assertEquals('>==> def', $lib->getValue($this->getRow())); |
||
| 30 | } |
||
| 31 | |||
| 32 | protected function getRow(): Row |
||
| 33 | { |
||
| 34 | return new Row(['id' => 2, 'name' => 'def', 'desc' => '<lang_to_"convert">', 'size' => 456, 'enabled' => 0]); |
||
| 35 | } |
||
| 36 | |||
| 37 | public function columnCallback(...$params): string |
||
| 38 | { |
||
| 39 | $first = reset($params); |
||
| 40 | $next = next($params); |
||
| 41 | $next = (false !== $next) ? $next : ''; |
||
| 42 | return '>==> ' . strval($first) . strval($next); |
||
| 43 | } |
||
| 45 |