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
This commit is contained in:
commit
cd0639d95b
@ -25,15 +25,13 @@ col-sm-2
|
||||
{# Rows #}
|
||||
|
||||
{% block form_row -%}
|
||||
{% spaceless %}
|
||||
<div class="form-group{% if (not compound or force_error|default(false)) and not valid %} has-error{% endif %}">
|
||||
{{ form_label(form) }}
|
||||
{{- form_label(form) -}}
|
||||
<div class="{{ block('form_group_class') }}">
|
||||
{{ form_widget(form) }}
|
||||
{{ form_errors(form) }}
|
||||
{{- form_widget(form) -}}
|
||||
{{- form_errors(form) -}}
|
||||
</div>
|
||||
</div>
|
||||
{% endspaceless %}
|
||||
{##}</div>
|
||||
{%- endblock form_row %}
|
||||
|
||||
{% block checkbox_row -%}
|
||||
|
@ -0,0 +1,118 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Bridge\Twig\Tests\Extension;
|
||||
|
||||
use Symfony\Bridge\Twig\Extension\FormExtension;
|
||||
use Symfony\Bridge\Twig\Form\TwigRenderer;
|
||||
use Symfony\Bridge\Twig\Form\TwigRendererEngine;
|
||||
use Symfony\Bridge\Twig\Extension\TranslationExtension;
|
||||
use Symfony\Bridge\Twig\Tests\Extension\Fixtures\StubTranslator;
|
||||
use Symfony\Bridge\Twig\Tests\Extension\Fixtures\StubFilesystemLoader;
|
||||
use Symfony\Component\Form\FormView;
|
||||
use Symfony\Component\Form\Tests\AbstractBootstrap3HorizontalLayoutTest;
|
||||
|
||||
class FormExtensionBootstrap3HorizontalLayoutTest extends AbstractBootstrap3HorizontalLayoutTest
|
||||
{
|
||||
/**
|
||||
* @var FormExtension
|
||||
*/
|
||||
protected $extension;
|
||||
|
||||
protected $testableFeatures = array(
|
||||
'choice_attr',
|
||||
);
|
||||
|
||||
protected function setUp()
|
||||
{
|
||||
parent::setUp();
|
||||
|
||||
$rendererEngine = new TwigRendererEngine(array(
|
||||
'bootstrap_3_horizontal_layout.html.twig',
|
||||
'custom_widgets.html.twig',
|
||||
));
|
||||
$renderer = new TwigRenderer($rendererEngine, $this->getMock('Symfony\Component\Security\Csrf\CsrfTokenManagerInterface'));
|
||||
|
||||
$this->extension = new FormExtension($renderer);
|
||||
|
||||
$loader = new StubFilesystemLoader(array(
|
||||
__DIR__.'/../../Resources/views/Form',
|
||||
__DIR__.'/Fixtures/templates/form',
|
||||
));
|
||||
|
||||
$environment = new \Twig_Environment($loader, array('strict_variables' => true));
|
||||
$environment->addExtension(new TranslationExtension(new StubTranslator()));
|
||||
$environment->addExtension($this->extension);
|
||||
|
||||
$this->extension->initRuntime($environment);
|
||||
}
|
||||
|
||||
protected function tearDown()
|
||||
{
|
||||
parent::tearDown();
|
||||
|
||||
$this->extension = null;
|
||||
}
|
||||
|
||||
protected function renderForm(FormView $view, array $vars = array())
|
||||
{
|
||||
return (string) $this->extension->renderer->renderBlock($view, 'form', $vars);
|
||||
}
|
||||
|
||||
protected function renderEnctype(FormView $view)
|
||||
{
|
||||
return (string) $this->extension->renderer->searchAndRenderBlock($view, 'enctype');
|
||||
}
|
||||
|
||||
protected function renderLabel(FormView $view, $label = null, array $vars = array())
|
||||
{
|
||||
if ($label !== null) {
|
||||
$vars += array('label' => $label);
|
||||
}
|
||||
|
||||
return (string) $this->extension->renderer->searchAndRenderBlock($view, 'label', $vars);
|
||||
}
|
||||
|
||||
protected function renderErrors(FormView $view)
|
||||
{
|
||||
return (string) $this->extension->renderer->searchAndRenderBlock($view, 'errors');
|
||||
}
|
||||
|
||||
protected function renderWidget(FormView $view, array $vars = array())
|
||||
{
|
||||
return (string) $this->extension->renderer->searchAndRenderBlock($view, 'widget', $vars);
|
||||
}
|
||||
|
||||
protected function renderRow(FormView $view, array $vars = array())
|
||||
{
|
||||
return (string) $this->extension->renderer->searchAndRenderBlock($view, 'row', $vars);
|
||||
}
|
||||
|
||||
protected function renderRest(FormView $view, array $vars = array())
|
||||
{
|
||||
return (string) $this->extension->renderer->searchAndRenderBlock($view, 'rest', $vars);
|
||||
}
|
||||
|
||||
protected function renderStart(FormView $view, array $vars = array())
|
||||
{
|
||||
return (string) $this->extension->renderer->renderBlock($view, 'form_start', $vars);
|
||||
}
|
||||
|
||||
protected function renderEnd(FormView $view, array $vars = array())
|
||||
{
|
||||
return (string) $this->extension->renderer->renderBlock($view, 'form_end', $vars);
|
||||
}
|
||||
|
||||
protected function setTheme(FormView $view, array $themes)
|
||||
{
|
||||
$this->extension->renderer->setTheme($view, $themes);
|
||||
}
|
||||
}
|
@ -60,6 +60,9 @@ class Package implements PackageInterface
|
||||
return $this->context;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return VersionStrategyInterface
|
||||
*/
|
||||
protected function getVersionStrategy()
|
||||
{
|
||||
return $this->versionStrategy;
|
||||
|
@ -39,10 +39,11 @@ class UrlPackage extends Package
|
||||
private $sslPackage;
|
||||
|
||||
/**
|
||||
* @param string|array $baseUrls Base asset URLs
|
||||
* @param string|string[] $baseUrls Base asset URLs
|
||||
* @param VersionStrategyInterface $versionStrategy The version strategy
|
||||
* @param ContextInterface|null $context Context
|
||||
*/
|
||||
public function __construct($baseUrls = array(), VersionStrategyInterface $versionStrategy, ContextInterface $context = null)
|
||||
public function __construct($baseUrls, VersionStrategyInterface $versionStrategy, ContextInterface $context = null)
|
||||
{
|
||||
parent::__construct($versionStrategy, $context);
|
||||
|
||||
|
@ -21,6 +21,10 @@ class StaticVersionStrategy implements VersionStrategyInterface
|
||||
private $version;
|
||||
private $format;
|
||||
|
||||
/**
|
||||
* @param string $version Version number
|
||||
* @param string $format Url format
|
||||
*/
|
||||
public function __construct($version, $format = null)
|
||||
{
|
||||
$this->version = $version;
|
||||
|
@ -217,7 +217,7 @@ class FormDataCollector extends DataCollector implements FormDataCollectorInterf
|
||||
return $this->data;
|
||||
}
|
||||
|
||||
private function recursiveBuildPreliminaryFormTree(FormInterface $form, &$output = null, array &$outputByHash)
|
||||
private function recursiveBuildPreliminaryFormTree(FormInterface $form, &$output, array &$outputByHash)
|
||||
{
|
||||
$hash = spl_object_hash($form);
|
||||
|
||||
@ -236,7 +236,7 @@ class FormDataCollector extends DataCollector implements FormDataCollectorInterf
|
||||
}
|
||||
}
|
||||
|
||||
private function recursiveBuildFinalFormTree(FormInterface $form = null, FormView $view, &$output = null, array &$outputByHash)
|
||||
private function recursiveBuildFinalFormTree(FormInterface $form = null, FormView $view, &$output, array &$outputByHash)
|
||||
{
|
||||
$viewHash = spl_object_hash($view);
|
||||
$formHash = null;
|
||||
|
@ -0,0 +1,157 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Component\Form\Tests;
|
||||
|
||||
abstract class AbstractBootstrap3HorizontalLayoutTest extends AbstractBootstrap3LayoutTest
|
||||
{
|
||||
public function testLabelOnForm()
|
||||
{
|
||||
$form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\DateType');
|
||||
$view = $form->createView();
|
||||
$this->renderWidget($view, array('label' => 'foo'));
|
||||
$html = $this->renderLabel($view);
|
||||
|
||||
$this->assertMatchesXpath($html,
|
||||
'/label
|
||||
[@class="col-sm-2 control-label required"]
|
||||
[.="[trans]Name[/trans]"]
|
||||
'
|
||||
);
|
||||
}
|
||||
|
||||
public function testLabelDoesNotRenderFieldAttributes()
|
||||
{
|
||||
$form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\TextType');
|
||||
$html = $this->renderLabel($form->createView(), null, array(
|
||||
'attr' => array(
|
||||
'class' => 'my&class',
|
||||
),
|
||||
));
|
||||
|
||||
$this->assertMatchesXpath($html,
|
||||
'/label
|
||||
[@for="name"]
|
||||
[@class="col-sm-2 control-label required"]
|
||||
'
|
||||
);
|
||||
}
|
||||
|
||||
public function testLabelWithCustomAttributesPassedDirectly()
|
||||
{
|
||||
$form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\TextType');
|
||||
$html = $this->renderLabel($form->createView(), null, array(
|
||||
'label_attr' => array(
|
||||
'class' => 'my&class',
|
||||
),
|
||||
));
|
||||
|
||||
$this->assertMatchesXpath($html,
|
||||
'/label
|
||||
[@for="name"]
|
||||
[@class="my&class col-sm-2 control-label required"]
|
||||
'
|
||||
);
|
||||
}
|
||||
|
||||
public function testLabelWithCustomTextAndCustomAttributesPassedDirectly()
|
||||
{
|
||||
$form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\TextType');
|
||||
$html = $this->renderLabel($form->createView(), 'Custom label', array(
|
||||
'label_attr' => array(
|
||||
'class' => 'my&class',
|
||||
),
|
||||
));
|
||||
|
||||
$this->assertMatchesXpath($html,
|
||||
'/label
|
||||
[@for="name"]
|
||||
[@class="my&class col-sm-2 control-label required"]
|
||||
[.="[trans]Custom label[/trans]"]
|
||||
'
|
||||
);
|
||||
}
|
||||
|
||||
public function testLabelWithCustomTextAsOptionAndCustomAttributesPassedDirectly()
|
||||
{
|
||||
$form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\TextType', null, array(
|
||||
'label' => 'Custom label',
|
||||
));
|
||||
$html = $this->renderLabel($form->createView(), null, array(
|
||||
'label_attr' => array(
|
||||
'class' => 'my&class',
|
||||
),
|
||||
));
|
||||
|
||||
$this->assertMatchesXpath($html,
|
||||
'/label
|
||||
[@for="name"]
|
||||
[@class="my&class col-sm-2 control-label required"]
|
||||
[.="[trans]Custom label[/trans]"]
|
||||
'
|
||||
);
|
||||
}
|
||||
|
||||
public function testStartTag()
|
||||
{
|
||||
$form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\FormType', null, array(
|
||||
'method' => 'get',
|
||||
'action' => 'http://example.com/directory',
|
||||
));
|
||||
|
||||
$html = $this->renderStart($form->createView());
|
||||
|
||||
$this->assertSame('<form name="form" method="get" action="http://example.com/directory" class="form-horizontal">', $html);
|
||||
}
|
||||
|
||||
public function testStartTagWithOverriddenVars()
|
||||
{
|
||||
$form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\FormType', null, array(
|
||||
'method' => 'put',
|
||||
'action' => 'http://example.com/directory',
|
||||
));
|
||||
|
||||
$html = $this->renderStart($form->createView(), array(
|
||||
'method' => 'post',
|
||||
'action' => 'http://foo.com/directory',
|
||||
));
|
||||
|
||||
$this->assertSame('<form name="form" method="post" action="http://foo.com/directory" class="form-horizontal">', $html);
|
||||
}
|
||||
|
||||
public function testStartTagForMultipartForm()
|
||||
{
|
||||
$form = $this->factory->createBuilder('Symfony\Component\Form\Extension\Core\Type\FormType', null, array(
|
||||
'method' => 'get',
|
||||
'action' => 'http://example.com/directory',
|
||||
))
|
||||
->add('file', 'Symfony\Component\Form\Extension\Core\Type\FileType')
|
||||
->getForm();
|
||||
|
||||
$html = $this->renderStart($form->createView());
|
||||
|
||||
$this->assertSame('<form name="form" method="get" action="http://example.com/directory" class="form-horizontal" enctype="multipart/form-data">', $html);
|
||||
}
|
||||
|
||||
public function testStartTagWithExtraAttributes()
|
||||
{
|
||||
$form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\FormType', null, array(
|
||||
'method' => 'get',
|
||||
'action' => 'http://example.com/directory',
|
||||
));
|
||||
|
||||
$html = $this->renderStart($form->createView(), array(
|
||||
'attr' => array('class' => 'foobar'),
|
||||
));
|
||||
|
||||
$this->assertSame('<form name="form" method="get" action="http://example.com/directory" class="foobar form-horizontal">', $html);
|
||||
}
|
||||
}
|
@ -110,7 +110,10 @@ class Store implements StoreInterface
|
||||
|
||||
public function isLocked(Request $request)
|
||||
{
|
||||
return is_file($this->getPath($this->getCacheKey($request).'.lck'));
|
||||
$path = $this->getPath($this->getCacheKey($request).'.lck');
|
||||
clearstatcache(true, $path);
|
||||
|
||||
return is_file($path);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -224,7 +224,7 @@ class ControllerResolverTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
}
|
||||
|
||||
protected function controllerMethod3($foo, $bar = null, $foobar)
|
||||
protected function controllerMethod3($foo, $bar, $foobar)
|
||||
{
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user