|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
declare(strict_types=1); |
|
4
|
|
|
|
|
5
|
|
|
namespace AbterPhp\Framework\Bootstrappers\Grid; |
|
6
|
|
|
|
|
7
|
|
|
use AbterPhp\Framework\Constant\Env; |
|
8
|
|
|
use AbterPhp\Framework\Environments\Environment; |
|
9
|
|
|
use AbterPhp\Framework\Grid\Pagination\Options as PaginationOptions; |
|
10
|
|
|
use AbterPhp\Framework\I18n\ITranslator; |
|
11
|
|
|
use Opulence\Ioc\Container; |
|
12
|
|
|
use PHPUnit\Framework\TestCase; |
|
13
|
|
|
|
|
14
|
|
|
class GridBootstrapperTest extends TestCase |
|
15
|
|
|
{ |
|
16
|
|
|
/** @var GridBootstrapper - System Under Test */ |
|
17
|
|
|
protected GridBootstrapper $sut; |
|
18
|
|
|
|
|
19
|
|
|
public function setUp(): void |
|
20
|
|
|
{ |
|
21
|
|
|
Environment::setVar(Env::PAGINATION_SIZE_OPTIONS, '5,25'); |
|
22
|
|
|
Environment::setVar(Env::PAGINATION_SIZE_DEFAULT, '5'); |
|
23
|
|
|
Environment::setVar(Env::PAGINATION_NUMBER_COUNT, '2'); |
|
24
|
|
|
|
|
25
|
|
|
$this->sut = new GridBootstrapper(); |
|
26
|
|
|
} |
|
27
|
|
|
|
|
28
|
|
|
public function tearDown(): void |
|
29
|
|
|
{ |
|
30
|
|
|
Environment::unsetVar(Env::PAGINATION_SIZE_OPTIONS); |
|
31
|
|
|
Environment::unsetVar(Env::PAGINATION_SIZE_DEFAULT); |
|
32
|
|
|
Environment::unsetVar(Env::PAGINATION_NUMBER_COUNT); |
|
33
|
|
|
} |
|
34
|
|
|
|
|
35
|
|
|
public function testRegisterBindings(): void |
|
36
|
|
|
{ |
|
37
|
|
|
$mockTranslator = $this->getMockBuilder(ITranslator::class)->getMock(); |
|
38
|
|
|
|
|
39
|
|
|
$container = new Container(); |
|
40
|
|
|
$container->bindInstance(ITranslator::class, $mockTranslator); |
|
41
|
|
|
|
|
42
|
|
|
$this->sut->registerBindings($container); |
|
43
|
|
|
|
|
44
|
|
|
$actual = $container->resolve(PaginationOptions::class); |
|
45
|
|
|
$this->assertInstanceOf(PaginationOptions::class, $actual); |
|
46
|
|
|
} |
|
47
|
|
|
} |
|
48
|
|
|
|