1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
declare(strict_types=1); |
4
|
|
|
|
5
|
|
|
namespace AbterPhp\PropellerAdmin\Decorator\Navigation; |
6
|
|
|
|
7
|
|
|
use AbterPhp\Framework\Constant\Html5; |
8
|
|
|
use AbterPhp\Framework\Html\Component; |
9
|
|
|
use AbterPhp\Framework\Navigation\Navigation; |
10
|
|
|
use Opulence\Routing\Urls\UrlGenerator; |
11
|
|
|
use PHPUnit\Framework\MockObject\MockObject; |
12
|
|
|
use PHPUnit\Framework\TestCase; |
13
|
|
|
|
14
|
|
|
class NavbarTest extends TestCase |
15
|
|
|
{ |
16
|
|
|
/** @var Navbar - System Under Test */ |
17
|
|
|
protected $sut; |
18
|
|
|
|
19
|
|
|
/** @var UrlGenerator|MockObject */ |
20
|
|
|
protected $urlGeneratorMock; |
21
|
|
|
|
22
|
|
|
public function setUp(): void |
23
|
|
|
{ |
24
|
|
|
$this->urlGeneratorMock = $this->getMockBuilder(UrlGenerator::class) |
25
|
|
|
->disableOriginalConstructor() |
26
|
|
|
->onlyMethods(['createFromName']) |
27
|
|
|
->getMock(); |
28
|
|
|
|
29
|
|
|
$this->sut = (new Navbar($this->urlGeneratorMock))->init(); |
30
|
|
|
|
31
|
|
|
parent::setUp(); |
32
|
|
|
} |
33
|
|
|
|
34
|
|
|
public function testDecorateWithEmptyComponents() |
35
|
|
|
{ |
36
|
|
|
$this->sut->decorate([]); |
37
|
|
|
|
38
|
|
|
$this->assertTrue(true, 'No error was found.'); |
39
|
|
|
} |
40
|
|
|
|
41
|
|
|
public function testDecorateNonMatchingComponents() |
42
|
|
|
{ |
43
|
|
|
$this->sut->decorate([new Component()]); |
44
|
|
|
|
45
|
|
|
$this->assertTrue(true, 'No error was found.'); |
46
|
|
|
} |
47
|
|
|
|
48
|
|
|
public function testDecorateWithDoubleInit() |
49
|
|
|
{ |
50
|
|
|
$this->sut->init(); |
51
|
|
|
$this->sut->decorate([new Component()]); |
52
|
|
|
|
53
|
|
|
$this->testDecorateNonMatchingComponents(); |
54
|
|
|
} |
55
|
|
|
|
56
|
|
|
public function testDecorateNavbar() |
57
|
|
|
{ |
58
|
|
|
$navbar = new Navigation([Navigation::INTENT_NAVBAR]); |
59
|
|
|
|
60
|
|
|
$this->sut->decorate([$navbar]); |
61
|
|
|
|
62
|
|
|
$this->assertStringContainsString(Navbar::NAVBAR_CLASS, $navbar->getAttribute(Html5::ATTR_CLASS)); |
|
|
|
|
63
|
|
|
$this->assertCount(1, $navbar->getNodes()); |
64
|
|
|
} |
65
|
|
|
} |
66
|
|
|
|