1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
declare(strict_types=1); |
4
|
|
|
|
5
|
|
|
namespace AbterPhp\Files\Grid\Factory; |
6
|
|
|
|
7
|
|
|
use AbterPhp\Admin\Grid\Factory\GridFactory; |
8
|
|
|
use AbterPhp\Admin\Grid\Factory\PaginationFactory; |
9
|
|
|
use AbterPhp\Files\Domain\Entities\FileCategory as Entity; |
10
|
|
|
use AbterPhp\Files\Grid\Factory\Table\FileCategory as TableFactory; |
11
|
|
|
use AbterPhp\Files\Grid\Filters\FileCategory as Filters; |
12
|
|
|
use AbterPhp\Framework\Grid\IGrid; |
13
|
|
|
use Opulence\Routing\Urls\UrlGenerator; |
14
|
|
|
use PHPUnit\Framework\MockObject\MockObject; |
15
|
|
|
use PHPUnit\Framework\TestCase; |
16
|
|
|
|
17
|
|
|
class FileCategoryTest extends TestCase |
18
|
|
|
{ |
19
|
|
|
/** @var FileCategory - System Under Test */ |
20
|
|
|
protected $sut; |
21
|
|
|
|
22
|
|
|
/** @var MockObject|UrlGenerator */ |
23
|
|
|
protected $urlGeneratorMock; |
24
|
|
|
|
25
|
|
|
/** @var MockObject|PaginationFactory */ |
26
|
|
|
protected $paginationFactoryMock; |
27
|
|
|
|
28
|
|
|
/** @var MockObject|TableFactory */ |
29
|
|
|
protected $tableFactoryMock; |
30
|
|
|
|
31
|
|
|
/** @var MockObject|GridFactory */ |
32
|
|
|
protected $gridFactoryMock; |
33
|
|
|
|
34
|
|
|
/** @var MockObject|Filters */ |
35
|
|
|
protected $filtersMock; |
36
|
|
|
|
37
|
|
|
public function setUp(): void |
38
|
|
|
{ |
39
|
|
|
$this->urlGeneratorMock = $this->createMock(UrlGenerator::class); |
40
|
|
|
$this->paginationFactoryMock = $this->createMock(PaginationFactory::class); |
41
|
|
|
$this->tableFactoryMock = $this->createMock(TableFactory::class); |
42
|
|
|
$this->gridFactoryMock = $this->createMock(GridFactory::class); |
43
|
|
|
$this->filtersMock = $this->createMock(Filters::class); |
44
|
|
|
|
45
|
|
|
$this->sut = new FileCategory( |
46
|
|
|
$this->urlGeneratorMock, |
47
|
|
|
$this->paginationFactoryMock, |
48
|
|
|
$this->tableFactoryMock, |
49
|
|
|
$this->gridFactoryMock, |
50
|
|
|
$this->filtersMock |
51
|
|
|
); |
52
|
|
|
} |
53
|
|
|
|
54
|
|
|
public function testCreateGrid() |
55
|
|
|
{ |
56
|
|
|
$params = []; |
57
|
|
|
$baseUrl = ''; |
58
|
|
|
|
59
|
|
|
$actualResult = $this->sut->createGrid($params, $baseUrl); |
60
|
|
|
|
61
|
|
|
$this->assertInstanceOf(IGrid::class, $actualResult); |
62
|
|
|
} |
63
|
|
|
|
64
|
|
|
public function testGetIsPublic() |
65
|
|
|
{ |
66
|
|
|
$entityMock = $this->createMock(Entity::class); |
67
|
|
|
$entityMock->expects($this->any())->method('isPublic')->willReturn(true); |
68
|
|
|
|
69
|
|
|
$actualResult = $this->sut->getIsPublic($entityMock); |
70
|
|
|
|
71
|
|
|
$this->assertSame('framework:yes', $actualResult); |
72
|
|
|
} |
73
|
|
|
} |
74
|
|
|
|