Skip to content

Commit 47b80b4

Browse files
committed
tests: compatible with master Latte, DI, Application
1 parent 85df902 commit 47b80b4

File tree

11 files changed

+28
-40
lines changed

11 files changed

+28
-40
lines changed

src/Bridges/FormsLatte/FormMacros.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ public function macroForm(MacroNode $node, PhpWriter $writer)
6363
return $writer->write(
6464
'echo Nette\Bridges\FormsLatte\Runtime::renderFormBegin($form = $_form = '
6565
. ($name[0] === '$' ? 'is_object(%node.word) ? %node.word : ' : '')
66-
. '$_control[%node.word], %node.array)'
66+
. '$this->global->uiControl[%node.word], %node.array)'
6767
);
6868
}
6969

@@ -164,7 +164,7 @@ public function macroNameAttr(MacroNode $node, PhpWriter $writer)
164164
return $writer->write(
165165
'echo Nette\Bridges\FormsLatte\Runtime::renderFormBegin($form = $_form = '
166166
. ($name[0] === '$' ? 'is_object(%0.word) ? %0.word : ' : '')
167-
. '$_control[%0.word], %1.var, FALSE)',
167+
. '$this->global->uiControl[%0.word], %1.var, FALSE)',
168168
$name,
169169
array_fill_keys(array_keys($node->htmlNode->attrs), NULL)
170170
);

tests/Forms.DI/FormsExtension.phpt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ test(function () {
2727
\'Nette\Forms\Controls\SelectBox::VALID\': "SelectBox test"
2828
', 'neon'));
2929

30-
eval($compiler->compile($config, 'Container1'));
30+
eval($compiler->addConfig($config)->setClassName('Container1')->compile());
3131

3232
$container = new Container1;
3333
$container->initialize();
@@ -48,5 +48,5 @@ Assert::exception(function () {
4848
Foo\Bar: custom validator
4949
', 'neon'));
5050

51-
eval($compiler->compile($config, 'Container2'));
51+
eval($compiler->addConfig($config)->setClassName('Container2')->compile());
5252
}, Nette\InvalidArgumentException::class, 'Constant Nette\Forms\Form::Foo\Bar or constant Foo\Bar does not exist.');

tests/Forms.Latte/FormMacros.button.phpt

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ $form->addSubmit('send', 'Sign in');
1717

1818
$latte = new Latte\Engine;
1919
FormMacros::install($latte->getCompiler());
20+
$latte->addProvider('uiControl', ['myForm' => $form]);
2021

2122
Assert::matchFile(
2223
__DIR__ . '/expected/FormMacros.button.phtml',
@@ -25,8 +26,5 @@ Assert::matchFile(
2526

2627
Assert::matchFile(
2728
__DIR__ . '/expected/FormMacros.button.html',
28-
$latte->renderToString(
29-
__DIR__ . '/templates/forms.button.latte',
30-
['_control' => ['myForm' => $form]]
31-
)
29+
$latte->renderToString(__DIR__ . '/templates/forms.button.latte')
3230
);

tests/Forms.Latte/FormMacros.formContainer.phpt

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,15 +38,13 @@ $form->addSubmit('input8', 'Input 8');
3838

3939
$latte = new Latte\Engine;
4040
FormMacros::install($latte->getCompiler());
41+
$latte->addProvider('uiControl', ['myForm' => $form]);
4142

4243
Assert::matchFile(
4344
__DIR__ . '/expected/FormMacros.formContainer.phtml',
4445
$latte->compile(__DIR__ . '/templates/forms.formContainer.latte')
4546
);
4647
Assert::matchFile(
4748
__DIR__ . '/expected/FormMacros.formContainer.html',
48-
$latte->renderToString(
49-
__DIR__ . '/templates/forms.formContainer.latte',
50-
['_control' => ['myForm' => $form]]
51-
)
49+
$latte->renderToString(__DIR__ . '/templates/forms.formContainer.latte')
5250
);

tests/Forms.Latte/FormMacros.forms.phpt

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ $form['my'] = new MyControl;
3939

4040
$latte = new Latte\Engine;
4141
FormMacros::install($latte->getCompiler());
42+
$latte->addProvider('uiControl', ['myForm' => $form]);
4243

4344
$form['username']->addError('error');
4445

@@ -48,8 +49,5 @@ Assert::matchFile(
4849
);
4950
Assert::matchFile(
5051
__DIR__ . '/expected/FormMacros.forms.html',
51-
$latte->renderToString(
52-
__DIR__ . '/templates/forms.latte',
53-
['_control' => ['myForm' => $form]]
54-
)
52+
$latte->renderToString(__DIR__ . '/templates/forms.latte')
5553
);

tests/Forms.Latte/FormMacros.get.phpt

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,15 +19,13 @@ $form->addSubmit('send', 'Sign in');
1919

2020
$latte = new Latte\Engine;
2121
FormMacros::install($latte->getCompiler());
22+
$latte->addProvider('uiControl', ['myForm' => $form]);
2223

2324
Assert::matchFile(
2425
__DIR__ . '/expected/FormMacros.get.phtml',
2526
$latte->compile(__DIR__ . '/templates/forms.get.latte')
2627
);
2728
Assert::matchFile(
2829
__DIR__ . '/expected/FormMacros.get.html',
29-
$latte->renderToString(
30-
__DIR__ . '/templates/forms.get.latte',
31-
['_control' => ['myForm' => $form]]
32-
)
30+
$latte->renderToString(__DIR__ . '/templates/forms.get.latte')
3331
);

tests/Forms.Latte/expected/FormMacros.button.phtml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ class Template%a% extends Latte\Template
77
function render()
88
{
99
%A%<form<?php
10-
echo Nette\Bridges\FormsLatte\Runtime::renderFormBegin($form = $_form = $_control["myForm"], array (
10+
echo Nette\Bridges\FormsLatte\Runtime::renderFormBegin($form = $_form = $this->global->uiControl["myForm"], array (
1111
), FALSE) ?>>
1212
<button<?php
1313
$_input = $_form["send"];

tests/Forms.Latte/expected/FormMacros.formContainer.phtml

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,8 @@ class Template%a% extends Latte\Template
66

77
function render()
88
{
9-
extract($this->params);
10-
// prolog Latte\Macros\CoreMacros
11-
if ($this->initialize($_b, $_l, $_g)) return;
12-
13-
// main template
14-
echo Nette\Bridges\FormsLatte\Runtime::renderFormBegin($form = $_form = $_control["myForm"], []) ?>
9+
%A%
10+
echo Nette\Bridges\FormsLatte\Runtime::renderFormBegin($form = $_form = $this->global->uiControl["myForm"], []) ?>
1511

1612
<table>
1713
<tr>

tests/Forms.Latte/expected/FormMacros.forms.phtml

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ class Template%a% extends Latte\Template
77
function render()
88
{
99
%A%
10-
echo Nette\Bridges\FormsLatte\Runtime::renderFormBegin($form = $_form = $_control["myForm"], ['id' => 'myForm', 'class'=>"ajax"]) ?>
10+
echo Nette\Bridges\FormsLatte\Runtime::renderFormBegin($form = $_form = $this->global->uiControl["myForm"], ['id' => 'myForm', 'class'=>"ajax"]) ?>
1111

1212
<?php
1313
$iterations = 0;
@@ -21,11 +21,11 @@ class Template%a% extends Latte\Template
2121
$_input = is_object($name) ? $name : $_form[$name];
2222
echo $_input->getControl()->addAttributes(['title' => 'Hello', 'size' => 10]) ?>
2323

24-
<?php echo LFilters::escapeHtmlText($_input->getError()) ?>
24+
<?php echo LR\Filters::escapeHtml($_input->getError()) ?>
2525

2626
<?php
2727
$_input = is_object($name) ? $name : $_form[$name];
28-
echo LFilters::escapeHtmlText($_input->getError()) ?>
28+
echo LR\Filters::escapeHtml($_input->getError()) ?>
2929

3030

3131
<br>
@@ -38,7 +38,7 @@ class Template%a% extends Latte\Template
3838

3939
<?php
4040
$_input = is_object($form[$name]) ? $form[$name] : $_form[$form[$name]];
41-
echo LFilters::escapeHtmlText($_input->getError()) ?>
41+
echo LR\Filters::escapeHtml($_input->getError()) ?>
4242

4343
<?php
4444
$iterations++;
@@ -83,7 +83,7 @@ class Template%a% extends Latte\Template
8383

8484

8585
<?php
86-
echo Nette\Bridges\FormsLatte\Runtime::renderFormBegin($form = $_form = $_control["myForm"], []);
86+
echo Nette\Bridges\FormsLatte\Runtime::renderFormBegin($form = $_form = $this->global->uiControl["myForm"], []);
8787
echo Nette\Bridges\FormsLatte\Runtime::renderFormEnd($_form) ?>
8888

8989

@@ -94,7 +94,7 @@ class Template%a% extends Latte\Template
9494
if (isset($this->params['label'])) trigger_error('Variable $label overwritten in foreach.');
9595
foreach ($form['sex']->items as $key => $label) {
9696
?> <?php if ($_label = $_form["sex"]->getLabelPart($key)) echo $_label->startTag() ?> <?php echo $_form["sex"]->getControlPart($key) ?> <?php
97-
echo LFilters::escapeHtmlText($label);
97+
echo LR\Filters::escapeHtml($label);
9898
if ($_label) echo $_label->endTag() ?>
9999

100100
<label title=hello<?php
@@ -154,7 +154,7 @@ class Template%a% extends Latte\Template
154154
if (isset($this->params['label'])) trigger_error('Variable $label overwritten in foreach.');
155155
foreach ($form['checklist']->items as $key => $label) {
156156
?> <?php if ($_label = $_form["checklist"]->getLabelPart($key)) echo $_label->startTag() ?> <?php echo $_form["checklist"]->getControlPart($key) ?> <?php
157-
echo LFilters::escapeHtmlText($label);
157+
echo LR\Filters::escapeHtml($label);
158158
if ($_label) echo $_label->endTag() ?>
159159

160160
<label<?php
@@ -184,7 +184,7 @@ class Template%a% extends Latte\Template
184184
<?php
185185
if (1) {
186186
?><form id="myForm" class="ajax"<?php
187-
echo Nette\Bridges\FormsLatte\Runtime::renderFormBegin($form = $_form = $_control["myForm"], array (
187+
echo Nette\Bridges\FormsLatte\Runtime::renderFormBegin($form = $_form = $this->global->uiControl["myForm"], array (
188188
'id' => NULL,
189189
'class' => NULL,
190190
), FALSE) ?>>
@@ -198,7 +198,7 @@ class Template%a% extends Latte\Template
198198

199199

200200
<FORM<?php
201-
echo Nette\Bridges\FormsLatte\Runtime::renderFormBegin($form = $_form = is_object($_control['myForm']) ? $_control['myForm'] : $_control[$_control['myForm']], array (
201+
echo Nette\Bridges\FormsLatte\Runtime::renderFormBegin($form = $_form = is_object($this->global->uiControl['myForm']) ? $this->global->uiControl['myForm'] : $this->global->uiControl[$this->global->uiControl['myForm']], array (
202202
), FALSE) ?>>
203203
<input<?php
204204
$_input = $_form["username"];
@@ -212,7 +212,7 @@ class Template%a% extends Latte\Template
212212
echo $_input->getControl()->getHtml() ?></select>
213213

214214

215-
<textarea title="<?php echo LFilters::escapeHtmlAttr(10) ?>"<?php
215+
<textarea title="<?php echo LR\Filters::escapeHtmlAttr(10) ?>"<?php
216216
$_input = $_form["area"];
217217
echo $_input->{method_exists($_input, 'getControlPart')?'getControlPart':'getControl'}()->addAttributes(array (
218218
'title' => NULL,

tests/Forms.Latte/expected/FormMacros.get.phtml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
<?php
22
%A%
3-
echo Nette\Bridges\FormsLatte\Runtime::renderFormBegin($form = $_form = $_control["myForm"], []);
3+
echo Nette\Bridges\FormsLatte\Runtime::renderFormBegin($form = $_form = $this->global->uiControl["myForm"], []);
44
echo Nette\Bridges\FormsLatte\Runtime::renderFormEnd($_form) ?>
55

66

77
<form<?php
8-
echo Nette\Bridges\FormsLatte\Runtime::renderFormBegin($form = $_form = $_control["myForm"], array (
8+
echo Nette\Bridges\FormsLatte\Runtime::renderFormBegin($form = $_form = $this->global->uiControl["myForm"], array (
99
), FALSE) ?>>
1010
<?php echo Nette\Bridges\FormsLatte\Runtime::renderFormEnd($_form, FALSE) ?></form>
1111
<?php

0 commit comments

Comments
 (0)