|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
declare(strict_types=1); |
|
4
|
|
|
|
|
5
|
|
|
namespace AbterPhp\Admin\Grid\Factory\Table; |
|
6
|
|
|
|
|
7
|
|
|
use AbterPhp\Framework\Grid\Cell\Cell; |
|
8
|
|
|
use AbterPhp\Framework\Grid\Component\Header; |
|
9
|
|
|
use AbterPhp\Framework\Grid\Row\Row; |
|
10
|
|
|
use PHPUnit\Framework\TestCase; |
|
11
|
|
|
|
|
12
|
|
|
class HeaderFactoryTest extends TestCase |
|
13
|
|
|
{ |
|
14
|
|
|
public function testCreateWithoutActions() |
|
15
|
|
|
{ |
|
16
|
|
|
$baseUrl = '/foo?'; |
|
17
|
|
|
|
|
18
|
|
|
$sut = new HeaderFactory(); |
|
19
|
|
|
|
|
20
|
|
|
$header = $sut->create(false, [], $baseUrl); |
|
21
|
|
|
|
|
22
|
|
|
$this->assertInstanceOf(Header::class, $header); |
|
23
|
|
|
$this->assertCount(1, $header); |
|
24
|
|
|
$this->assertInstanceOf(Row::class, $header[0]); |
|
25
|
|
|
|
|
26
|
|
|
/** @var Row $firstRow */ |
|
27
|
|
|
$firstRow = $header[0]; |
|
28
|
|
|
$this->assertCount(0, $firstRow->getCells()); |
|
29
|
|
|
} |
|
30
|
|
|
|
|
31
|
|
|
public function testCreateWithActions() |
|
32
|
|
|
{ |
|
33
|
|
|
$baseUrl = '/foo?'; |
|
34
|
|
|
|
|
35
|
|
|
$sut = new HeaderFactory(); |
|
36
|
|
|
|
|
37
|
|
|
$header = $sut->create(true, [], $baseUrl); |
|
38
|
|
|
|
|
39
|
|
|
$this->assertInstanceOf(Header::class, $header); |
|
40
|
|
|
$this->assertCount(1, $header); |
|
41
|
|
|
$this->assertInstanceOf(Row::class, $header[0]); |
|
42
|
|
|
|
|
43
|
|
|
/** @var Row $firstRow */ |
|
44
|
|
|
$firstRow = $header[0]; |
|
45
|
|
|
$this->assertCount(1, $firstRow->getCells()); |
|
46
|
|
|
$this->assertInstanceOf(Cell::class, $firstRow->getCells()[0]); |
|
47
|
|
|
} |
|
48
|
|
|
|
|
49
|
|
|
public function testCreateWithSortable() |
|
50
|
|
|
{ |
|
51
|
|
|
$baseUrl = '/foo?'; |
|
52
|
|
|
|
|
53
|
|
|
$sut = new HeaderFactory(); |
|
54
|
|
|
|
|
55
|
|
|
$header = $sut->create(true, [], $baseUrl); |
|
56
|
|
|
|
|
57
|
|
|
$this->assertInstanceOf(Header::class, $header); |
|
58
|
|
|
$this->assertCount(1, $header); |
|
59
|
|
|
$this->assertInstanceOf(Row::class, $header[0]); |
|
60
|
|
|
|
|
61
|
|
|
/** @var Row $firstRow */ |
|
62
|
|
|
$firstRow = $header[0]; |
|
63
|
|
|
$this->assertCount(1, $firstRow->getCells()); |
|
64
|
|
|
$this->assertInstanceOf(Cell::class, $firstRow->getCells()[0]); |
|
65
|
|
|
} |
|
66
|
|
|
} |
|
67
|
|
|
|