Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit cd0639d

Browse files
committed
Merge branch '2.7' into 2.8
* 2.7: [HttpKernel] clearstatcache() so the Cache sees when a .lck file has been released [WIP] [Form] [TwigBridge] Bootstrap horizontal theme missing tests AssetBundle - fix docs CS: remove impossible default argument value
2 parents 2659c8e + e3f4278 commit cd0639d

File tree

9 files changed

+296
-12
lines changed

9 files changed

+296
-12
lines changed

src/Symfony/Bridge/Twig/Resources/views/Form/bootstrap_3_horizontal_layout.html.twig

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -25,15 +25,13 @@ col-sm-2
2525
{# Rows #}
2626

2727
{% block form_row -%}
28-
{% spaceless %}
2928
<div class="form-group{% if (not compound or force_error|default(false)) and not valid %} has-error{% endif %}">
30-
{{ form_label(form) }}
29+
{{- form_label(form) -}}
3130
<div class="{{ block('form_group_class') }}">
32-
{{ form_widget(form) }}
33-
{{ form_errors(form) }}
31+
{{- form_widget(form) -}}
32+
{{- form_errors(form) -}}
3433
</div>
35-
</div>
36-
{% endspaceless %}
34+
{##}</div>
3735
{%- endblock form_row %}
3836

3937
{% block checkbox_row -%}
Lines changed: 118 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,118 @@
1+
<?php
2+
3+
/*
4+
* This file is part of the Symfony package.
5+
*
6+
* (c) Fabien Potencier <[email protected]>
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 Symfony\Bridge\Twig\Tests\Extension;
13+
14+
use Symfony\Bridge\Twig\Extension\FormExtension;
15+
use Symfony\Bridge\Twig\Form\TwigRenderer;
16+
use Symfony\Bridge\Twig\Form\TwigRendererEngine;
17+
use Symfony\Bridge\Twig\Extension\TranslationExtension;
18+
use Symfony\Bridge\Twig\Tests\Extension\Fixtures\StubTranslator;
19+
use Symfony\Bridge\Twig\Tests\Extension\Fixtures\StubFilesystemLoader;
20+
use Symfony\Component\Form\FormView;
21+
use Symfony\Component\Form\Tests\AbstractBootstrap3HorizontalLayoutTest;
22+
23+
class FormExtensionBootstrap3HorizontalLayoutTest extends AbstractBootstrap3HorizontalLayoutTest
24+
{
25+
/**
26+
* @var FormExtension
27+
*/
28+
protected $extension;
29+
30+
protected $testableFeatures = array(
31+
'choice_attr',
32+
);
33+
34+
protected function setUp()
35+
{
36+
parent::setUp();
37+
38+
$rendererEngine = new TwigRendererEngine(array(
39+
'bootstrap_3_horizontal_layout.html.twig',
40+
'custom_widgets.html.twig',
41+
));
42+
$renderer = new TwigRenderer($rendererEngine, $this->getMock('Symfony\Component\Security\Csrf\CsrfTokenManagerInterface'));
43+
44+
$this->extension = new FormExtension($renderer);
45+
46+
$loader = new StubFilesystemLoader(array(
47+
__DIR__.'/../../Resources/views/Form',
48+
__DIR__.'/Fixtures/templates/form',
49+
));
50+
51+
$environment = new \Twig_Environment($loader, array('strict_variables' => true));
52+
$environment->addExtension(new TranslationExtension(new StubTranslator()));
53+
$environment->addExtension($this->extension);
54+
55+
$this->extension->initRuntime($environment);
56+
}
57+
58+
protected function tearDown()
59+
{
60+
parent::tearDown();
61+
62+
$this->extension = null;
63+
}
64+
65+
protected function renderForm(FormView $view, array $vars = array())
66+
{
67+
return (string) $this->extension->renderer->renderBlock($view, 'form', $vars);
68+
}
69+
70+
protected function renderEnctype(FormView $view)
71+
{
72+
return (string) $this->extension->renderer->searchAndRenderBlock($view, 'enctype');
73+
}
74+
75+
protected function renderLabel(FormView $view, $label = null, array $vars = array())
76+
{
77+
if ($label !== null) {
78+
$vars += array('label' => $label);
79+
}
80+
81+
return (string) $this->extension->renderer->searchAndRenderBlock($view, 'label', $vars);
82+
}
83+
84+
protected function renderErrors(FormView $view)
85+
{
86+
return (string) $this->extension->renderer->searchAndRenderBlock($view, 'errors');
87+
}
88+
89+
protected function renderWidget(FormView $view, array $vars = array())
90+
{
91+
return (string) $this->extension->renderer->searchAndRenderBlock($view, 'widget', $vars);
92+
}
93+
94+
protected function renderRow(FormView $view, array $vars = array())
95+
{
96+
return (string) $this->extension->renderer->searchAndRenderBlock($view, 'row', $vars);
97+
}
98+
99+
protected function renderRest(FormView $view, array $vars = array())
100+
{
101+
return (string) $this->extension->renderer->searchAndRenderBlock($view, 'rest', $vars);
102+
}
103+
104+
protected function renderStart(FormView $view, array $vars = array())
105+
{
106+
return (string) $this->extension->renderer->renderBlock($view, 'form_start', $vars);
107+
}
108+
109+
protected function renderEnd(FormView $view, array $vars = array())
110+
{
111+
return (string) $this->extension->renderer->renderBlock($view, 'form_end', $vars);
112+
}
113+
114+
protected function setTheme(FormView $view, array $themes)
115+
{
116+
$this->extension->renderer->setTheme($view, $themes);
117+
}
118+
}

src/Symfony/Component/Asset/Package.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,9 @@ protected function getContext()
6060
return $this->context;
6161
}
6262

63+
/**
64+
* @return VersionStrategyInterface
65+
*/
6366
protected function getVersionStrategy()
6467
{
6568
return $this->versionStrategy;

src/Symfony/Component/Asset/UrlPackage.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,10 +39,11 @@ class UrlPackage extends Package
3939
private $sslPackage;
4040

4141
/**
42-
* @param string|array $baseUrls Base asset URLs
42+
* @param string|string[] $baseUrls Base asset URLs
4343
* @param VersionStrategyInterface $versionStrategy The version strategy
44+
* @param ContextInterface|null $context Context
4445
*/
45-
public function __construct($baseUrls = array(), VersionStrategyInterface $versionStrategy, ContextInterface $context = null)
46+
public function __construct($baseUrls, VersionStrategyInterface $versionStrategy, ContextInterface $context = null)
4647
{
4748
parent::__construct($versionStrategy, $context);
4849

src/Symfony/Component/Asset/VersionStrategy/StaticVersionStrategy.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,10 @@ class StaticVersionStrategy implements VersionStrategyInterface
2121
private $version;
2222
private $format;
2323

24+
/**
25+
* @param string $version Version number
26+
* @param string $format Url format
27+
*/
2428
public function __construct($version, $format = null)
2529
{
2630
$this->version = $version;

src/Symfony/Component/Form/Extension/DataCollector/FormDataCollector.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -217,7 +217,7 @@ public function getData()
217217
return $this->data;
218218
}
219219

220-
private function recursiveBuildPreliminaryFormTree(FormInterface $form, &$output = null, array &$outputByHash)
220+
private function recursiveBuildPreliminaryFormTree(FormInterface $form, &$output, array &$outputByHash)
221221
{
222222
$hash = spl_object_hash($form);
223223

@@ -236,7 +236,7 @@ private function recursiveBuildPreliminaryFormTree(FormInterface $form, &$output
236236
}
237237
}
238238

239-
private function recursiveBuildFinalFormTree(FormInterface $form = null, FormView $view, &$output = null, array &$outputByHash)
239+
private function recursiveBuildFinalFormTree(FormInterface $form = null, FormView $view, &$output, array &$outputByHash)
240240
{
241241
$viewHash = spl_object_hash($view);
242242
$formHash = null;
Lines changed: 157 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,157 @@
1+
<?php
2+
3+
/*
4+
* This file is part of the Symfony package.
5+
*
6+
* (c) Fabien Potencier <[email protected]>
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 Symfony\Component\Form\Tests;
13+
14+
abstract class AbstractBootstrap3HorizontalLayoutTest extends AbstractBootstrap3LayoutTest
15+
{
16+
public function testLabelOnForm()
17+
{
18+
$form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\DateType');
19+
$view = $form->createView();
20+
$this->renderWidget($view, array('label' => 'foo'));
21+
$html = $this->renderLabel($view);
22+
23+
$this->assertMatchesXpath($html,
24+
'/label
25+
[@class="col-sm-2 control-label required"]
26+
[.="[trans]Name[/trans]"]
27+
'
28+
);
29+
}
30+
31+
public function testLabelDoesNotRenderFieldAttributes()
32+
{
33+
$form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\TextType');
34+
$html = $this->renderLabel($form->createView(), null, array(
35+
'attr' => array(
36+
'class' => 'my&class',
37+
),
38+
));
39+
40+
$this->assertMatchesXpath($html,
41+
'/label
42+
[@for="name"]
43+
[@class="col-sm-2 control-label required"]
44+
'
45+
);
46+
}
47+
48+
public function testLabelWithCustomAttributesPassedDirectly()
49+
{
50+
$form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\TextType');
51+
$html = $this->renderLabel($form->createView(), null, array(
52+
'label_attr' => array(
53+
'class' => 'my&class',
54+
),
55+
));
56+
57+
$this->assertMatchesXpath($html,
58+
'/label
59+
[@for="name"]
60+
[@class="my&class col-sm-2 control-label required"]
61+
'
62+
);
63+
}
64+
65+
public function testLabelWithCustomTextAndCustomAttributesPassedDirectly()
66+
{
67+
$form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\TextType');
68+
$html = $this->renderLabel($form->createView(), 'Custom label', array(
69+
'label_attr' => array(
70+
'class' => 'my&class',
71+
),
72+
));
73+
74+
$this->assertMatchesXpath($html,
75+
'/label
76+
[@for="name"]
77+
[@class="my&class col-sm-2 control-label required"]
78+
[.="[trans]Custom label[/trans]"]
79+
'
80+
);
81+
}
82+
83+
public function testLabelWithCustomTextAsOptionAndCustomAttributesPassedDirectly()
84+
{
85+
$form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\TextType', null, array(
86+
'label' => 'Custom label',
87+
));
88+
$html = $this->renderLabel($form->createView(), null, array(
89+
'label_attr' => array(
90+
'class' => 'my&class',
91+
),
92+
));
93+
94+
$this->assertMatchesXpath($html,
95+
'/label
96+
[@for="name"]
97+
[@class="my&class col-sm-2 control-label required"]
98+
[.="[trans]Custom label[/trans]"]
99+
'
100+
);
101+
}
102+
103+
public function testStartTag()
104+
{
105+
$form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\FormType', null, array(
106+
'method' => 'get',
107+
'action' => 'http://example.com/directory',
108+
));
109+
110+
$html = $this->renderStart($form->createView());
111+
112+
$this->assertSame('<form name="form" method="get" action="http://example.com/directory" class="form-horizontal">', $html);
113+
}
114+
115+
public function testStartTagWithOverriddenVars()
116+
{
117+
$form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\FormType', null, array(
118+
'method' => 'put',
119+
'action' => 'http://example.com/directory',
120+
));
121+
122+
$html = $this->renderStart($form->createView(), array(
123+
'method' => 'post',
124+
'action' => 'http://foo.com/directory',
125+
));
126+
127+
$this->assertSame('<form name="form" method="post" action="http://foo.com/directory" class="form-horizontal">', $html);
128+
}
129+
130+
public function testStartTagForMultipartForm()
131+
{
132+
$form = $this->factory->createBuilder('Symfony\Component\Form\Extension\Core\Type\FormType', null, array(
133+
'method' => 'get',
134+
'action' => 'http://example.com/directory',
135+
))
136+
->add('file', 'Symfony\Component\Form\Extension\Core\Type\FileType')
137+
->getForm();
138+
139+
$html = $this->renderStart($form->createView());
140+
141+
$this->assertSame('<form name="form" method="get" action="http://example.com/directory" class="form-horizontal" enctype="multipart/form-data">', $html);
142+
}
143+
144+
public function testStartTagWithExtraAttributes()
145+
{
146+
$form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\FormType', null, array(
147+
'method' => 'get',
148+
'action' => 'http://example.com/directory',
149+
));
150+
151+
$html = $this->renderStart($form->createView(), array(
152+
'attr' => array('class' => 'foobar'),
153+
));
154+
155+
$this->assertSame('<form name="form" method="get" action="http://example.com/directory" class="foobar form-horizontal">', $html);
156+
}
157+
}

src/Symfony/Component/HttpKernel/HttpCache/Store.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,10 @@ public function unlock(Request $request)
110110

111111
public function isLocked(Request $request)
112112
{
113-
return is_file($this->getPath($this->getCacheKey($request).'.lck'));
113+
$path = $this->getPath($this->getCacheKey($request).'.lck');
114+
clearstatcache(true, $path);
115+
116+
return is_file($path);
114117
}
115118

116119
/**

src/Symfony/Component/HttpKernel/Tests/Controller/ControllerResolverTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -224,7 +224,7 @@ protected function controllerMethod2($foo, $bar = null)
224224
{
225225
}
226226

227-
protected function controllerMethod3($foo, $bar = null, $foobar)
227+
protected function controllerMethod3($foo, $bar, $foobar)
228228
{
229229
}
230230

0 commit comments

Comments
 (0)