8000 Add Tests · symfony/symfony@8094804 · GitHub
[go: up one dir, main page]

Skip to content

Commit 8094804

Browse files
Mathieu Piotmpiot
Mathieu Piot
authored andcommitted
Add Tests
1 parent 067c681 commit 8094804

9 files changed

+80
-0
lines changed

src/Symfony/Bridge/Twig/Tests/Extension/FormExtensionBootstrap3HorizontalLayoutTest.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,11 @@ protected function renderLabel(FormView $view, $label = null, array $vars = arra
6969
return (string) $this->renderer->searchAndRenderBlock($view, 'label', $vars);
7070
}
7171

72+
protected function renderHelp(FormView $view, array $vars = array())
73+
{
74+
return (string) $this->renderer->searchAndRenderBlock($view, 'help', $vars);
75+
}
76+
7277
protected function renderErrors(FormView $view)
7378
{
7479
return (string) $this->renderer->searchAndRenderBlock($view, 'errors');

src/Symfony/Bridge/Twig/Tests/Extension/FormExtensionBootstrap3LayoutTest.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,11 @@ protected function renderLabel(FormView $view, $label = null, array $vars = arra
8989
return (string) $this->renderer->searchAndRenderBlock($view, 'label', $vars);
9090
}
9191

92+
protected function renderHelp(FormView $view, array $vars = array())
93+
{
94+
return (string) $this->renderer->searchAndRenderBlock($view, 'help', $vars);
95+
}
96+
9297
protected function renderErrors(FormView $view)
9398
{
9499
return (string) $this->renderer->searchAndRenderBlock($view, 'errors');

src/Symfony/Bridge/Twig/Tests/Extension/FormExtensionBootstrap4HorizontalLayoutTest.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,11 @@ protected function renderLabel(FormView $view, $label = null, array $vars = arra
7070
return (string) $this->renderer->searchAndRenderBlock($view, 'label', $vars);
7171
}
7272

73+
protected function renderHelp(FormView $view, array $vars = array())
74+
{
75+
return (string) $this->renderer->searchAndRenderBlock($view, 'help', $vars);
76+
}
77+
7378
protected function renderErrors(FormView $view)
7479
{
7580
return (string) $this->renderer->searchAndRenderBlock($view, 'errors');

src/Symfony/Bridge/Twig/Tests/Extension/FormExtensionBootstrap4LayoutTest.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,11 @@ protected function renderLabel(FormView $view, $label = null, array $vars = arra
9292
return (string) $this->renderer->searchAndRenderBlock($view, 'label', $vars);
9393
}
9494

95+
protected function renderHelp(FormView $view, array $vars = array())
96+
{
97+
return (string) $this->renderer->searchAndRenderBlock($view, 'help', $vars);
98+
}
99+
95100
protected function renderErrors(FormView $view)
96101
{
97102
return (string) $this->renderer->searchAndRenderBlock($view, 'errors');

src/Symfony/Bridge/Twig/Tests/Extension/FormExtensionDivLayoutTest.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -179,6 +179,11 @@ protected function renderLabel(FormView $view, $label = null, array $vars = arra
179179
return (string) $this->renderer->searchAndRenderBlock($view, 'label', $vars);
180180
}
181181

182+
protected function renderHelp(FormView $view, array $vars = array())
183+
{
184+
return (string) $this->renderer->searchAndRenderBlock($view, 'help', $vars);
185+
}
186+
182187
protected function renderErrors(FormView $view)
183188
{
184189
return (string) $this->renderer->searchAndRenderBlock($view, 'errors');

src/Symfony/Bridge/Twig/Tests/Extension/FormExtensionTableLayoutTest.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,11 @@ protected function renderLabel(FormView $view, $label = null, array $vars = arra
9090
return (string) $this->renderer->searchAndRenderBlock($view, 'label', $vars);
9191
}
9292

93+
protected function renderHelp(FormView $view, array $vars = array())
94+
{
95+
return (string) $this->renderer->searchAndRenderBlock($view, 'help', $vars);
96+
}
97+
9398
protected function renderErrors(FormView $view)
9499
{
95100
return (string) $this->renderer->searchAndRenderBlock($view, 'errors');

src/Symfony/Component/Form/Tests/AbstractBootstrap3LayoutTest.php

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,22 @@ public function testLabelWithCustomTextAsOptionAndCustomAttributesPassedDirectly
102102
);
103103
}
104104

105+
public function testHelp()
106+
{
107+
$form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\TextType', null, [
108+
'help' => 'Help text test!'
109+
]);
110+
$view = $form->createView();
111+
$html = $this->renderHelp($view);
112+
113+
$this->assertMatchesXpath($html,
114+
'/span
115+
[@class="help-block"]
116+
[.="[trans]Help text test![/trans]"]
117+
'
118+
);
119+
}
120+
105121
public function testErrors()
106122
{
107123
$form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\TextType');

src/Symfony/Component/Form/Tests/AbstractBootstrap4LayoutTest.php

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,22 @@ public function testLegendOnExpandedType()
151151
);
152152
}
153153

154+
public function testHelp()
155+
{
156+
$form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\TextType', null, [
157+
'help' => 'Help text test!'
158+
]);
159+
$view = $form->createView();
160+
$html = $this->renderHelp($view);
161+
162+
$this->assertMatchesXpath($html,
163+
'/small
164+
[@class="form-text text-muted"]
165+
[.="[trans]Help text test![/trans]"]
166+
'
167+
);
168+
}
169+
154170
public function testErrors()
155171
{
156172
$form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\TextType');

src/Symfony/Component/Form/Tests/AbstractLayoutTest.php

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,8 @@ abstract protected function renderForm(FormView $view, array $vars = array());
113113

114114
abstract protected function renderLabel(FormView $view, $label = null, array $vars = array());
115115

116+
abstract protected function renderHelp(FormView $view, array $vars = array());
117+
116118
abstract protected function renderErrors(FormView $view);
117119

118120
abstract protected function renderWidget(FormView $view, array $vars = array());
@@ -408,6 +410,22 @@ public function testLabelFormatOnButtonId()
408410
);
409411
}
410412

413+
public function testHelp()
414+
{
415+
$form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\TextType', null, [
416+
'help' => 'Help text test!'
417+
]);
418+
$view = $form->createView();
419+
$html = $this->renderHelp($view);
420+
421+
$this->assertMatchesXpath($html,
422+
'/p
423+
[@class="help-text"]
424+
[.="[trans]Help text test![/trans]"]
425+
'
426+
);
427+
}
428+
411429
public function testErrors()
412430
{
413431
$form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\TextType');

0 commit comments

Comments
 (0)
0