1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/* |
4
|
|
|
* This file is part of the core-bundle package. |
5
|
|
|
* |
6
|
|
|
* (c) 2018 WEBEWEB |
7
|
|
|
* |
8
|
|
|
* For the full copyright and license information, please view the LICENSE |
9
|
|
|
* file that was distributed with this source code. |
10
|
|
|
*/ |
11
|
|
|
|
12
|
|
|
namespace WBW\Bundle\CoreBundle\Tests\Renderer; |
13
|
|
|
|
14
|
|
|
use WBW\Bundle\CoreBundle\Assets\TranslatedChoiceLabelInterface; |
15
|
|
|
use WBW\Bundle\CoreBundle\Renderer\FormRenderer; |
16
|
|
|
use WBW\Bundle\CoreBundle\Tests\AbstractTestCase; |
17
|
|
|
use WBW\Library\Sorter\Model\AlphabeticalTreeNodeInterface; |
18
|
|
|
use WBW\Library\Symfony\Assets\ChoiceLabelInterface; |
19
|
|
|
|
20
|
|
|
/** |
21
|
|
|
* Form renderer test. |
22
|
|
|
* |
23
|
|
|
* @author webeweb <https://github.com/webeweb> |
24
|
|
|
* @package WBW\Bundle\CoreBundle\Tests\Renderer |
25
|
|
|
*/ |
26
|
|
|
class FormRendererTest extends AbstractTestCase { |
27
|
|
|
|
28
|
|
|
/** |
29
|
|
|
* Test renderOption() |
30
|
|
|
* |
31
|
|
|
* @return void |
32
|
|
|
*/ |
33
|
|
|
public function testRenderOption(): void { |
34
|
|
|
|
35
|
|
|
$this->assertEquals("This option must implements [Translated]ChoiceLabelInterface", FormRenderer::renderOption($this)); |
36
|
|
|
} |
37
|
|
|
|
38
|
|
|
/** |
39
|
|
|
* Test renderOption() |
40
|
|
|
* |
41
|
|
|
* @return void |
42
|
|
|
*/ |
43
|
|
|
public function testRenderWithAlphabeticalTreeNodeInterface(): void { |
44
|
|
|
|
45
|
|
|
// Set an Alphabetical tree node mock. |
46
|
|
|
$arg = $this->getMockBuilder(AlphabeticalTreeNodeInterface::class)->getMock(); |
47
|
|
|
$arg->expects($this->any())->method("getAlphabeticalTreeNodeParent")->willReturn(null); |
48
|
|
|
|
49
|
|
|
$this->assertEquals("─ This option must implements [Translated]ChoiceLabelInterface", FormRenderer::renderOption($arg)); |
50
|
|
|
} |
51
|
|
|
|
52
|
|
|
/** |
53
|
|
|
* Test renderOption() |
54
|
|
|
* |
55
|
|
|
* @return void |
56
|
|
|
*/ |
57
|
|
|
public function testRenderWithChoiceInterface(): void { |
58
|
|
|
|
59
|
|
|
// Set a Choice label mock. |
60
|
|
|
$arg = $this->getMockBuilder(ChoiceLabelInterface::class)->getMock(); |
61
|
|
|
$arg->expects($this->any())->method("getChoiceLabel")->willReturn("choiceLabel"); |
62
|
|
|
|
63
|
|
|
$this->assertEquals("choiceLabel", FormRenderer::renderOption($arg)); |
64
|
|
|
} |
65
|
|
|
|
66
|
|
|
/** |
67
|
|
|
* Test renderOption() |
68
|
|
|
* |
69
|
|
|
* @return void |
70
|
|
|
*/ |
71
|
|
|
public function testRenderWithNull(): void { |
72
|
|
|
|
73
|
|
|
$this->assertEquals("Empty selection", FormRenderer::renderOption(null)); |
74
|
|
|
} |
75
|
|
|
|
76
|
|
|
/** |
77
|
|
|
* Test renderOption() |
78
|
|
|
* |
79
|
|
|
* @return void |
80
|
|
|
*/ |
81
|
|
|
public function testRenderWithTranslatedChoiceInterface(): void { |
82
|
|
|
|
83
|
|
|
// Set a Translated choice label mock. |
84
|
|
|
$arg = $this->getMockBuilder(TranslatedChoiceLabelInterface::class)->getMock(); |
85
|
|
|
$arg->expects($this->any())->method("getTranslatedChoiceLabel")->willReturn("translatedChoiceLabel"); |
86
|
|
|
|
87
|
|
|
$this->assertEquals("translatedChoiceLabel", FormRenderer::renderOption($arg)); |
88
|
|
|
} |
89
|
|
|
} |
90
|
|
|
|