Merge branch '3.3' into 3.4
* 3.3: [HttpFoundation] Use the correct syntax for session gc based on Pdo driver Removed assertDateTimeEquals() methods. Revert "bug #24987 [Console] Fix global console flag when used in chain (Simperfit)" Revert "bug #25487 [Console] Fix a bug when passing a letter that could be an alias (Simperfit)" Disable CSP header on exception pages only in debug Fixed submitting disabled buttons Fixed Button::setParent() when already submitted Improve assertions Restore RoleInterface import Improve assertions SCA: get rid of repetitive calls allow null values for root nodes in YAML configs revert useless tests fixtures changes [VarDumper] Fix docblock Improve phpdoc to make it more explicit
This commit is contained in:
commit
d5ff094258
@ -39,8 +39,9 @@ class Application extends BaseApplication
|
||||
|
||||
parent::__construct('Symfony', Kernel::VERSION);
|
||||
|
||||
$this->getDefinition()->addOption(new InputOption('--env', '-e', InputOption::VALUE_REQUIRED, 'The environment name', $kernel->getEnvironment()));
|
||||
$this->getDefinition()->addOption(new InputOption('--no-debug', null, InputOption::VALUE_NONE, 'Switches off debug mode'));
|
||||
$inputDefinition = $this->getDefinition();
|
||||
$inputDefinition->addOption(new InputOption('--env', '-e', InputOption::VALUE_REQUIRED, 'The Environment name.', $kernel->getEnvironment()));
|
||||
$inputDefinition->addOption(new InputOption('--no-debug', null, InputOption::VALUE_NONE, 'Switches off debug mode.'));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -945,8 +945,9 @@ class FrameworkExtension extends Extension
|
||||
if (1 === count($engines)) {
|
||||
$container->setAlias('templating', (string) reset($engines))->setPublic(true);
|
||||
} else {
|
||||
$templateEngineDefinition = $container->getDefinition('templating.engine.delegating');
|
||||
foreach ($engines as $engine) {
|
||||
$container->getDefinition('templating.engine.delegating')->addMethodCall('addEngine', array($engine));
|
||||
$templateEngineDefinition->addMethodCall('addEngine', array($engine));
|
||||
}
|
||||
$container->setAlias('templating', 'templating.engine.delegating')->setPublic(true);
|
||||
}
|
||||
|
@ -1,9 +1,6 @@
|
||||
<?php
|
||||
|
||||
$container->loadFromExtension('framework', array(
|
||||
'assets' => array(
|
||||
'enabled' => true,
|
||||
),
|
||||
'templating' => array(
|
||||
'engines' => array('php', 'twig'),
|
||||
),
|
||||
|
@ -6,7 +6,6 @@
|
||||
http://symfony.com/schema/dic/symfony http://symfony.com/schema/dic/symfony/symfony-1.0.xsd">
|
||||
|
||||
<framework:config>
|
||||
<framework:assets enabled="true" />
|
||||
<framework:templating>
|
||||
<framework:engine>php</framework:engine>
|
||||
<framework:engine>twig</framework:engine>
|
||||
|
@ -1,5 +1,3 @@
|
||||
framework:
|
||||
assets:
|
||||
enabled: true
|
||||
templating:
|
||||
engines: [php, twig]
|
||||
|
@ -86,9 +86,9 @@ class MainConfigurationTest extends TestCase
|
||||
$processor = new Processor();
|
||||
$configuration = new MainConfiguration(array(), array());
|
||||
$processedConfig = $processor->processConfiguration($configuration, array($config));
|
||||
$this->assertTrue(isset($processedConfig['firewalls']['stub']['logout']['csrf_token_generator']));
|
||||
$this->assertArrayHasKey('csrf_token_generator', $processedConfig['firewalls']['stub']['logout']);
|
||||
$this->assertEquals('a_token_generator', $processedConfig['firewalls']['stub']['logout']['csrf_token_generator']);
|
||||
$this->assertTrue(isset($processedConfig['firewalls']['stub']['logout']['csrf_token_id']));
|
||||
$this->assertArrayHasKey('csrf_token_id', $processedConfig['firewalls']['stub']['logout']);
|
||||
$this->assertEquals('a_token_id', $processedConfig['firewalls']['stub']['logout']['csrf_token_id']);
|
||||
}
|
||||
|
||||
|
@ -128,6 +128,7 @@
|
||||
<tag name="monolog.logger" channel="request" />
|
||||
<argument>%twig.exception_listener.controller%</argument>
|
||||
<argument type="service" id="logger" on-invalid="null" />
|
||||
<argument>%kernel.debug%</argument>
|
||||
</service>
|
||||
|
||||
<service id="twig.controller.exception" class="Symfony\Bundle\TwigBundle\Controller\ExceptionController" public="true">
|
||||
|
@ -285,16 +285,6 @@ class ArgvInput extends Input
|
||||
if ($token === $value || 0 === strpos($token, $value.'=')) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (0 === strpos($token, '-') && 0 !== strpos($token, '--')) {
|
||||
$noValue = explode('=', $token);
|
||||
$token = $noValue[0];
|
||||
$searchableToken = str_replace('-', '', $token);
|
||||
$searchableValue = str_replace('-', '', $value);
|
||||
if ('' !== $searchableToken && '' !== $searchableValue && false !== strpos($searchableToken, $searchableValue)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -314,12 +314,6 @@ class ArgvInputTest extends TestCase
|
||||
$input = new ArgvInput(array('cli.php', '-f', 'foo'));
|
||||
$this->assertTrue($input->hasParameterOption('-f'), '->hasParameterOption() returns true if the given short option is in the raw input');
|
||||
|
||||
$input = new ArgvInput(array('cli.php', '-fh'));
|
||||
$this->assertTrue($input->hasParameterOption('-fh'), '->hasParameterOption() returns true if the given short option is in the raw input');
|
||||
|
||||
$input = new ArgvInput(array('cli.php', '-e=test'));
|
||||
$this->assertFalse($input->hasParameterOption('-s'), '->hasParameterOption() returns true if the given short option is in the raw input');
|
||||
|
||||
$input = new ArgvInput(array('cli.php', '--foo', 'foo'));
|
||||
$this->assertTrue($input->hasParameterOption('--foo'), '->hasParameterOption() returns true if the given short option is in the raw input');
|
||||
|
||||
|
@ -422,12 +422,16 @@ class ContainerBuilder extends Container implements TaggedContainerInterface
|
||||
* @throws BadMethodCallException When this ContainerBuilder is compiled
|
||||
* @throws \LogicException if the extension is not registered
|
||||
*/
|
||||
public function loadFromExtension($extension, array $values = array())
|
||||
public function loadFromExtension($extension, array $values = null)
|
||||
{
|
||||
if ($this->isCompiled()) {
|
||||
throw new BadMethodCallException('Cannot load from an extension on a compiled container.');
|
||||
}
|
||||
|
||||
if (func_num_args() < 2) {
|
||||
$values = array();
|
||||
}
|
||||
|
||||
$namespace = $this->getExtension($extension)->getAlias();
|
||||
|
||||
$this->extensionConfigs[$namespace][] = $values;
|
||||
|
@ -821,7 +821,7 @@ class YamlFileLoader extends FileLoader
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!is_array($values)) {
|
||||
if (!is_array($values) && null !== $values) {
|
||||
$values = array();
|
||||
}
|
||||
|
||||
|
@ -262,23 +262,23 @@ class ResolveDefinitionTemplatesPassTest extends TestCase
|
||||
$this->process($container);
|
||||
|
||||
$configurator = $container->getDefinition('sibling')->getConfigurator();
|
||||
$this->assertSame('Symfony\Component\DependencyInjection\Definition', get_class($configurator));
|
||||
$this->assertInstanceOf('Symfony\Component\DependencyInjection\Definition', $configurator);
|
||||
$this->assertSame('parentClass', $configurator->getClass());
|
||||
|
||||
$factory = $container->getDefinition('sibling')->getFactory();
|
||||
$this->assertSame('Symfony\Component\DependencyInjection\Definition', get_class($factory[0]));
|
||||
$this->assertInstanceOf('Symfony\Component\DependencyInjection\Definition', $factory[0]);
|
||||
$this->assertSame('parentClass', $factory[0]->getClass());
|
||||
|
||||
$argument = $container->getDefinition('sibling')->getArgument(0);
|
||||
$this->assertSame('Symfony\Component\DependencyInjection\Definition', get_class($argument));
|
||||
$this->assertInstanceOf('Symfony\Component\DependencyInjection\Definition', $argument);
|
||||
$this->assertSame('parentClass', $argument->getClass());
|
||||
|
||||
$properties = $container->getDefinition('sibling')->getProperties();
|
||||
$this->assertSame('Symfony\Component\DependencyInjection\Definition', get_class($properties['prop']));
|
||||
$this->assertInstanceOf('Symfony\Component\DependencyInjection\Definition', $properties['prop']);
|
||||
$this->assertSame('parentClass', $properties['prop']->getClass());
|
||||
|
||||
$methodCalls = $container->getDefinition('sibling')->getMethodCalls();
|
||||
$this->assertSame('Symfony\Component\DependencyInjection\Definition', get_class($methodCalls[0][1][0]));
|
||||
$this->assertInstanceOf('Symfony\Component\DependencyInjection\Definition', $methodCalls[0][1][0]);
|
||||
$this->assertSame('parentClass', $methodCalls[0][1][0]->getClass());
|
||||
}
|
||||
|
||||
|
@ -8,7 +8,14 @@ class ProjectExtension implements ExtensionInterface
|
||||
{
|
||||
public function load(array $configs, ContainerBuilder $configuration)
|
||||
{
|
||||
$config = call_user_func_array('array_merge', $configs);
|
||||
$configuration->setParameter('project.configs', $configs);
|
||||
$configs = array_filter($configs);
|
||||
|
||||
if ($configs) {
|
||||
$config = call_user_func_array('array_merge', $configs);
|
||||
} else {
|
||||
$config = array();
|
||||
}
|
||||
|
||||
$configuration->setDefinition('project.service.bar', new Definition('FooClass'));
|
||||
$configuration->setParameter('project.parameter.bar', isset($config['foo']) ? $config['foo'] : 'foobar');
|
||||
|
@ -0,0 +1 @@
|
||||
project: ~
|
@ -221,6 +221,17 @@ class YamlFileLoaderTest extends TestCase
|
||||
}
|
||||
}
|
||||
|
||||
public function testExtensionWithNullConfig()
|
||||
{
|
||||
$container = new ContainerBuilder();
|
||||
$container->registerExtension(new \ProjectExtension());
|
||||
$loader = new YamlFileLoader($container, new FileLocator(self::$fixturesPath.'/yaml'));
|
||||
$loader->load('null_config.yml');
|
||||
$container->compile();
|
||||
|
||||
$this->assertSame(array(null), $container->getParameter('project.configs'));
|
||||
}
|
||||
|
||||
public function testSupports()
|
||||
{
|
||||
$loader = new YamlFileLoader(new ContainerBuilder(), new FileLocator());
|
||||
|
@ -106,6 +106,10 @@ class Button implements \IteratorAggregate, FormInterface
|
||||
*/
|
||||
public function setParent(FormInterface $parent = null)
|
||||
{
|
||||
if ($this->submitted) {
|
||||
throw new AlreadySubmittedException('You cannot set the parent of a submitted button');
|
||||
}
|
||||
|
||||
$this->parent = $parent;
|
||||
}
|
||||
|
||||
|
@ -43,6 +43,12 @@ class SubmitButton extends Button implements ClickableInterface
|
||||
*/
|
||||
public function submit($submittedData, $clearMissing = true)
|
||||
{
|
||||
if ($this->getConfig()->getDisabled()) {
|
||||
$this->clicked = false;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
parent::submit($submittedData, $clearMissing);
|
||||
|
||||
$this->clicked = null !== $submittedData;
|
||||
|
@ -30,6 +30,20 @@ class ButtonTest extends TestCase
|
||||
$this->factory = $this->getMockBuilder('Symfony\Component\Form\FormFactoryInterface')->getMock();
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException \Symfony\Component\Form\Exception\AlreadySubmittedException
|
||||
*/
|
||||
public function testSetParentOnSubmittedButton()
|
||||
{
|
||||
$button = $this->getButtonBuilder('button')
|
||||
->getForm()
|
||||
;
|
||||
|
||||
$button->submit('');
|
||||
|
||||
$button->setParent($this->getFormBuilder('form')->getForm());
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider getDisabledStates
|
||||
*/
|
||||
@ -37,11 +51,13 @@ class ButtonTest extends TestCase
|
||||
{
|
||||
$form = $this->getFormBuilder('form')
|
||||
->setDisabled($parentDisabled)
|
||||
->getForm();
|
||||
->getForm()
|
||||
;
|
||||
|
||||
$button = $this->getButtonBuilder('button')
|
||||
->setDisabled($buttonDisabled)
|
||||
->getForm();
|
||||
->getForm()
|
||||
;
|
||||
|
||||
$button->setParent($form);
|
||||
|
||||
|
@ -1014,6 +1014,28 @@ class CompoundFormTest extends AbstractFormTest
|
||||
$this->assertSame($button, $this->form->getClickedButton());
|
||||
}
|
||||
|
||||
public function testDisabledButtonIsNotSubmitted()
|
||||
{
|
||||
$button = new SubmitButtonBuilder('submit');
|
||||
$submit = $button
|
||||
->setDisabled(true)
|
||||
->getForm();
|
||||
|
||||
$form = $this->createForm()
|
||||
->add($this->getBuilder('text')->getForm())
|
||||
->add($submit)
|
||||
;
|
||||
|
||||
$form->submit(array(
|
||||
'text' => '',
|
||||
'submit' => '',
|
||||
));
|
||||
|
||||
$this->assertTrue($submit->isDisabled());
|
||||
$this->assertFalse($submit->isClicked());
|
||||
$this->assertFalse($submit->isSubmitted());
|
||||
}
|
||||
|
||||
protected function createForm()
|
||||
{
|
||||
return $this->getBuilder()
|
||||
|
@ -1,22 +0,0 @@
|
||||
<?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\Extension\Core\DataTransformer;
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
abstract class DateTimeTestCase extends TestCase
|
||||
{
|
||||
public static function assertDateTimeEquals(\DateTime $expected, \DateTime $actual)
|
||||
{
|
||||
self::assertEquals($expected->format('U'), $actual->format('U'));
|
||||
}
|
||||
}
|
@ -11,9 +11,10 @@
|
||||
|
||||
namespace Symfony\Component\Form\Tests\Extension\Core\DataTransformer;
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use Symfony\Component\Form\Extension\Core\DataTransformer\DateTimeToArrayTransformer;
|
||||
|
||||
class DateTimeToArrayTransformerTest extends DateTimeTestCase
|
||||
class DateTimeToArrayTransformerTest extends TestCase
|
||||
{
|
||||
public function testTransform()
|
||||
{
|
||||
@ -160,7 +161,7 @@ class DateTimeToArrayTransformerTest extends DateTimeTestCase
|
||||
|
||||
$output = new \DateTime('2010-02-03 04:05:06 UTC');
|
||||
|
||||
$this->assertDateTimeEquals($output, $transformer->reverseTransform($input));
|
||||
$this->assertEquals($output, $transformer->reverseTransform($input));
|
||||
}
|
||||
|
||||
public function testReverseTransformWithSomeZero()
|
||||
@ -178,7 +179,7 @@ class DateTimeToArrayTransformerTest extends DateTimeTestCase
|
||||
|
||||
$output = new \DateTime('2010-02-03 04:00:00 UTC');
|
||||
|
||||
$this->assertDateTimeEquals($output, $transformer->reverseTransform($input));
|
||||
$this->assertEquals($output, $transformer->reverseTransform($input));
|
||||
}
|
||||
|
||||
public function testReverseTransformCompletelyEmpty()
|
||||
@ -323,7 +324,7 @@ class DateTimeToArrayTransformerTest extends DateTimeTestCase
|
||||
$output = new \DateTime('2010-02-03 04:05:06 Asia/Hong_Kong');
|
||||
$output->setTimezone(new \DateTimeZone('America/New_York'));
|
||||
|
||||
$this->assertDateTimeEquals($output, $transformer->reverseTransform($input));
|
||||
$this->assertEquals($output, $transformer->reverseTransform($input));
|
||||
}
|
||||
|
||||
public function testReverseTransformToDifferentTimezone()
|
||||
@ -342,7 +343,7 @@ class DateTimeToArrayTransformerTest extends DateTimeTestCase
|
||||
$output = new \DateTime('2010-02-03 04:05:06 UTC');
|
||||
$output->setTimezone(new \DateTimeZone('Asia/Hong_Kong'));
|
||||
|
||||
$this->assertDateTimeEquals($output, $transformer->reverseTransform($input));
|
||||
$this->assertEquals($output, $transformer->reverseTransform($input));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -11,10 +11,11 @@
|
||||
|
||||
namespace Symfony\Component\Form\Tests\Extension\Core\DataTransformer;
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use Symfony\Component\Form\Extension\Core\DataTransformer\DateTimeToLocalizedStringTransformer;
|
||||
use Symfony\Component\Intl\Util\IntlTestHelper;
|
||||
|
||||
class DateTimeToLocalizedStringTransformerTest extends DateTimeTestCase
|
||||
class DateTimeToLocalizedStringTransformerTest extends TestCase
|
||||
{
|
||||
protected $dateTime;
|
||||
protected $dateTimeWithoutSeconds;
|
||||
@ -223,7 +224,7 @@ class DateTimeToLocalizedStringTransformerTest extends DateTimeTestCase
|
||||
{
|
||||
$transformer = new DateTimeToLocalizedStringTransformer('UTC', 'UTC', null, \IntlDateFormatter::FULL);
|
||||
|
||||
$this->assertDateTimeEquals($this->dateTime, $transformer->reverseTransform('03.02.2010, 04:05:06 GMT+00:00'));
|
||||
$this->assertEquals($this->dateTime, $transformer->reverseTransform('03.02.2010, 04:05:06 GMT+00:00'));
|
||||
}
|
||||
|
||||
public function testReverseTransformFromDifferentLocale()
|
||||
@ -232,7 +233,7 @@ class DateTimeToLocalizedStringTransformerTest extends DateTimeTestCase
|
||||
|
||||
$transformer = new DateTimeToLocalizedStringTransformer('UTC', 'UTC');
|
||||
|
||||
$this->assertDateTimeEquals($this->dateTimeWithoutSeconds, $transformer->reverseTransform('Feb 3, 2010, 04:05 AM'));
|
||||
$this->assertEquals($this->dateTimeWithoutSeconds, $transformer->reverseTransform('Feb 3, 2010, 04:05 AM'));
|
||||
}
|
||||
|
||||
public function testReverseTransformWithDifferentTimezones()
|
||||
@ -242,7 +243,7 @@ class DateTimeToLocalizedStringTransformerTest extends DateTimeTestCase
|
||||
$dateTime = new \DateTime('2010-02-03 04:05:00 Asia/Hong_Kong');
|
||||
$dateTime->setTimezone(new \DateTimeZone('America/New_York'));
|
||||
|
||||
$this->assertDateTimeEquals($dateTime, $transformer->reverseTransform('03.02.2010, 04:05'));
|
||||
$this->assertEquals($dateTime, $transformer->reverseTransform('03.02.2010, 04:05'));
|
||||
}
|
||||
|
||||
public function testReverseTransformOnlyDateWithDifferentTimezones()
|
||||
@ -251,21 +252,21 @@ class DateTimeToLocalizedStringTransformerTest extends DateTimeTestCase
|
||||
|
||||
$dateTime = new \DateTime('2017-01-10 11:00', new \DateTimeZone('Europe/Berlin'));
|
||||
|
||||
$this->assertDateTimeEquals($dateTime, $transformer->reverseTransform('2017-01-10'));
|
||||
$this->assertEquals($dateTime, $transformer->reverseTransform('2017-01-10'));
|
||||
}
|
||||
|
||||
public function testReverseTransformWithDifferentPatterns()
|
||||
{
|
||||
$transformer = new DateTimeToLocalizedStringTransformer('UTC', 'UTC', \IntlDateFormatter::FULL, \IntlDateFormatter::FULL, \IntlDateFormatter::GREGORIAN, 'MM*yyyy*dd HH|mm|ss');
|
||||
|
||||
$this->assertDateTimeEquals($this->dateTime, $transformer->reverseTransform('02*2010*03 04|05|06'));
|
||||
$this->assertEquals($this->dateTime, $transformer->reverseTransform('02*2010*03 04|05|06'));
|
||||
}
|
||||
|
||||
public function testReverseTransformDateOnlyWithDstIssue()
|
||||
{
|
||||
$transformer = new DateTimeToLocalizedStringTransformer('Europe/Rome', 'Europe/Rome', \IntlDateFormatter::FULL, \IntlDateFormatter::FULL, \IntlDateFormatter::GREGORIAN, 'dd/MM/yyyy');
|
||||
|
||||
$this->assertDateTimeEquals(
|
||||
$this->assertEquals(
|
||||
new \DateTime('1978-05-28', new \DateTimeZone('Europe/Rome')),
|
||||
$transformer->reverseTransform('28/05/1978')
|
||||
);
|
||||
@ -275,7 +276,7 @@ class DateTimeToLocalizedStringTransformerTest extends DateTimeTestCase
|
||||
{
|
||||
$transformer = new DateTimeToLocalizedStringTransformer('Europe/Rome', 'Europe/Rome', \IntlDateFormatter::FULL, \IntlDateFormatter::FULL, \IntlDateFormatter::GREGORIAN, "'day': dd 'month': MM 'year': yyyy");
|
||||
|
||||
$this->assertDateTimeEquals(
|
||||
$this->assertEquals(
|
||||
new \DateTime('1978-05-28', new \DateTimeZone('Europe/Rome')),
|
||||
$transformer->reverseTransform('day: 28 month: 05 year: 1978')
|
||||
);
|
||||
@ -329,7 +330,7 @@ class DateTimeToLocalizedStringTransformerTest extends DateTimeTestCase
|
||||
{
|
||||
$transformer = new DateTimeToLocalizedStringTransformer('UTC', 'UTC', \IntlDateFormatter::SHORT);
|
||||
|
||||
$this->assertDateTimeEquals($this->dateTimeWithoutSeconds, $transformer->reverseTransform('31.04.10 04:05'));
|
||||
$this->assertEquals($this->dateTimeWithoutSeconds, $transformer->reverseTransform('31.04.10 04:05'));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -11,9 +11,10 @@
|
||||
|
||||
namespace Symfony\Component\Form\Tests\Extension\Core\DataTransformer;
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use Symfony\Component\Form\Extension\Core\DataTransformer\DateTimeToRfc3339Transformer;
|
||||
|
||||
class DateTimeToRfc3339TransformerTest extends DateTimeTestCase
|
||||
class DateTimeToRfc3339TransformerTest extends TestCase
|
||||
{
|
||||
protected $dateTime;
|
||||
protected $dateTimeWithoutSeconds;
|
||||
@ -106,9 +107,9 @@ class DateTimeToRfc3339TransformerTest extends DateTimeTestCase
|
||||
$transformer = new DateTimeToRfc3339Transformer($toTz, $fromTz);
|
||||
|
||||
if (null !== $to) {
|
||||
$this->assertDateTimeEquals(new \DateTime($to), $transformer->reverseTransform($from));
|
||||
$this->assertEquals(new \DateTime($to), $transformer->reverseTransform($from));
|
||||
} else {
|
||||
$this->assertSame($to, $transformer->reverseTransform($from));
|
||||
$this->assertNull($transformer->reverseTransform($from));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -11,9 +11,10 @@
|
||||
|
||||
namespace Symfony\Component\Form\Tests\Extension\Core\DataTransformer;
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use Symfony\Component\Form\Extension\Core\DataTransformer\DateTimeToStringTransformer;
|
||||
|
||||
class DateTimeToStringTransformerTest extends DateTimeTestCase
|
||||
class DateTimeToStringTransformerTest extends TestCase
|
||||
{
|
||||
public function dataProvider()
|
||||
{
|
||||
@ -124,7 +125,7 @@ class DateTimeToStringTransformerTest extends DateTimeTestCase
|
||||
|
||||
$output = new \DateTime($output);
|
||||
|
||||
$this->assertDateTimeEquals($output, $reverseTransformer->reverseTransform($input));
|
||||
$this->assertEquals($output, $reverseTransformer->reverseTransform($input));
|
||||
}
|
||||
|
||||
public function testReverseTransformEmpty()
|
||||
@ -142,7 +143,7 @@ class DateTimeToStringTransformerTest extends DateTimeTestCase
|
||||
$input = $output->format('Y-m-d H:i:s');
|
||||
$output->setTimezone(new \DateTimeZone('America/New_York'));
|
||||
|
||||
$this->assertDateTimeEquals($output, $reverseTransformer->reverseTransform($input));
|
||||
$this->assertEquals($output, $reverseTransformer->reverseTransform($input));
|
||||
}
|
||||
|
||||
public function testReverseTransformExpectsString()
|
||||
|
@ -11,9 +11,10 @@
|
||||
|
||||
namespace Symfony\Component\Form\Tests\Extension\Core\DataTransformer;
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use Symfony\Component\Form\Extension\Core\DataTransformer\DateTimeToTimestampTransformer;
|
||||
|
||||
class DateTimeToTimestampTransformerTest extends DateTimeTestCase
|
||||
class DateTimeToTimestampTransformerTest extends TestCase
|
||||
{
|
||||
public function testTransform()
|
||||
{
|
||||
@ -83,7 +84,7 @@ class DateTimeToTimestampTransformerTest extends DateTimeTestCase
|
||||
$output = new \DateTime('2010-02-03 04:05:06 UTC');
|
||||
$input = $output->format('U');
|
||||
|
||||
$this->assertDateTimeEquals($output, $reverseTransformer->reverseTransform($input));
|
||||
$this->assertEquals($output, $reverseTransformer->reverseTransform($input));
|
||||
}
|
||||
|
||||
public function testReverseTransformEmpty()
|
||||
@ -101,7 +102,7 @@ class DateTimeToTimestampTransformerTest extends DateTimeTestCase
|
||||
$input = $output->format('U');
|
||||
$output->setTimezone(new \DateTimeZone('Asia/Hong_Kong'));
|
||||
|
||||
$this->assertDateTimeEquals($output, $reverseTransformer->reverseTransform($input));
|
||||
$this->assertEquals($output, $reverseTransformer->reverseTransform($input));
|
||||
}
|
||||
|
||||
public function testReverseTransformExpectsValidTimestamp()
|
||||
|
@ -49,7 +49,7 @@ class DateTimeTypeTest extends BaseTypeTest
|
||||
|
||||
$dateTime = new \DateTime('2010-06-02 03:04:00 UTC');
|
||||
|
||||
$this->assertDateTimeEquals($dateTime, $form->getData());
|
||||
$this->assertEquals($dateTime, $form->getData());
|
||||
}
|
||||
|
||||
public function testSubmitString()
|
||||
@ -133,7 +133,7 @@ class DateTimeTypeTest extends BaseTypeTest
|
||||
|
||||
$form->submit($input);
|
||||
|
||||
$this->assertDateTimeEquals(new \DateTime('2010-06-02 03:00:00 UTC'), $form->getData());
|
||||
$this->assertEquals(new \DateTime('2010-06-02 03:00:00 UTC'), $form->getData());
|
||||
}
|
||||
|
||||
public function testSubmitWithSeconds()
|
||||
@ -165,7 +165,7 @@ class DateTimeTypeTest extends BaseTypeTest
|
||||
|
||||
$form->submit($input);
|
||||
|
||||
$this->assertDateTimeEquals(new \DateTime('2010-06-02 03:04:05 UTC'), $form->getData());
|
||||
$this->assertEquals(new \DateTime('2010-06-02 03:04:05 UTC'), $form->getData());
|
||||
}
|
||||
|
||||
public function testSubmitDifferentTimezones()
|
||||
@ -215,7 +215,7 @@ class DateTimeTypeTest extends BaseTypeTest
|
||||
|
||||
$outputTime->setTimezone(new \DateTimeZone('America/New_York'));
|
||||
|
||||
$this->assertDateTimeEquals($outputTime, $form->getData());
|
||||
$this->assertEquals($outputTime, $form->getData());
|
||||
$this->assertEquals('2010-06-02T03:04:00-10:00', $form->getViewData());
|
||||
}
|
||||
|
||||
@ -266,7 +266,7 @@ class DateTimeTypeTest extends BaseTypeTest
|
||||
'time' => '03:04',
|
||||
));
|
||||
|
||||
$this->assertDateTimeEquals($dateTime, $form->getData());
|
||||
$this->assertEquals($dateTime, $form->getData());
|
||||
}
|
||||
|
||||
public function testInitializeWithDateTime()
|
||||
|
@ -64,7 +64,7 @@ class DateTypeTest extends BaseTypeTest
|
||||
|
||||
$form->submit('2010-06-02');
|
||||
|
||||
$this->assertDateTimeEquals(new \DateTime('2010-06-02 UTC'), $form->getData());
|
||||
$this->assertEquals(new \DateTime('2010-06-02 UTC'), $form->getData());
|
||||
$this->assertEquals('2010-06-02', $form->getViewData());
|
||||
}
|
||||
|
||||
@ -80,7 +80,7 @@ class DateTypeTest extends BaseTypeTest
|
||||
|
||||
$form->submit('2010');
|
||||
|
||||
$this->assertDateTimeEquals(new \DateTime('2010-01-01 UTC'), $form->getData());
|
||||
$this->assertEquals(new \DateTime('2010-01-01 UTC'), $form->getData());
|
||||
$this->assertEquals('2010', $form->getViewData());
|
||||
}
|
||||
|
||||
@ -101,7 +101,7 @@ class DateTypeTest extends BaseTypeTest
|
||||
|
||||
$form->submit('2.6.2010');
|
||||
|
||||
$this->assertDateTimeEquals(new \DateTime('2010-06-02 UTC'), $form->getData());
|
||||
$this->assertEquals(new \DateTime('2010-06-02 UTC'), $form->getData());
|
||||
$this->assertEquals('02.06.2010', $form->getViewData());
|
||||
}
|
||||
|
||||
@ -194,7 +194,7 @@ class DateTypeTest extends BaseTypeTest
|
||||
|
||||
$dateTime = new \DateTime('2010-06-02 UTC');
|
||||
|
||||
$this->assertDateTimeEquals($dateTime, $form->getData());
|
||||
$this->assertEquals($dateTime, $form->getData());
|
||||
$this->assertEquals($text, $form->getViewData());
|
||||
}
|
||||
|
||||
@ -217,7 +217,7 @@ class DateTypeTest extends BaseTypeTest
|
||||
|
||||
$dateTime = new \DateTime('2010-06-02 UTC');
|
||||
|
||||
$this->assertDateTimeEquals($dateTime, $form->getData());
|
||||
$this->assertEquals($dateTime, $form->getData());
|
||||
$this->assertEquals($text, $form->getViewData());
|
||||
}
|
||||
|
||||
@ -254,7 +254,7 @@ class DateTypeTest extends BaseTypeTest
|
||||
|
||||
$form->submit('06*2010*02');
|
||||
|
||||
$this->assertDateTimeEquals(new \DateTime('2010-06-02 UTC'), $form->getData());
|
||||
$this->assertEquals(new \DateTime('2010-06-02 UTC'), $form->getData());
|
||||
$this->assertEquals('06*2010*02', $form->getViewData());
|
||||
}
|
||||
|
||||
@ -468,7 +468,7 @@ class DateTypeTest extends BaseTypeTest
|
||||
|
||||
// 2010-06-02 00:00:00 UTC
|
||||
// 2010-06-01 20:00:00 UTC-4
|
||||
$this->assertDateTimeEquals($dateTime, $form->getData());
|
||||
$this->assertEquals($dateTime, $form->getData());
|
||||
$this->assertEquals('01.06.2010', $form->getViewData());
|
||||
}
|
||||
|
||||
|
@ -315,7 +315,7 @@ class TimeTypeTest extends BaseTypeTest
|
||||
'second' => (int) $outputTime->format('s'),
|
||||
);
|
||||
|
||||
$this->assertDateTimeEquals($dateTime, $form->getData());
|
||||
$this->assertEquals($dateTime, $form->getData());
|
||||
$this->assertEquals($displayedData, $form->getViewData());
|
||||
}
|
||||
|
||||
|
@ -401,7 +401,11 @@ class PdoSessionHandler extends AbstractSessionHandler
|
||||
$this->gcCalled = false;
|
||||
|
||||
// delete the session records that have expired
|
||||
$sql = "DELETE FROM $this->table WHERE $this->lifetimeCol < :time - $this->timeCol";
|
||||
if ('mysql' === $this->driver) {
|
||||
$sql = "DELETE FROM $this->table WHERE $this->lifetimeCol + $this->timeCol < :time";
|
||||
} else {
|
||||
$sql = "DELETE FROM $this->table WHERE $this->lifetimeCol < :time - $this->timeCol";
|
||||
}
|
||||
|
||||
$stmt = $this->pdo->prepare($sql);
|
||||
$stmt->bindValue(':time', time(), \PDO::PARAM_INT);
|
||||
|
@ -34,8 +34,9 @@ class AddRequestFormatsListener implements EventSubscriberInterface
|
||||
*/
|
||||
public function onKernelRequest(GetResponseEvent $event)
|
||||
{
|
||||
$request = $event->getRequest();
|
||||
foreach ($this->formats as $format => $mimeTypes) {
|
||||
$event->getRequest()->setFormat($format, $mimeTypes);
|
||||
$request->setFormat($format, $mimeTypes);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -32,11 +32,13 @@ class ExceptionListener implements EventSubscriberInterface
|
||||
{
|
||||
protected $controller;
|
||||
protected $logger;
|
||||
protected $debug;
|
||||
|
||||
public function __construct($controller, LoggerInterface $logger = null)
|
||||
public function __construct($controller, LoggerInterface $logger = null, $debug = false)
|
||||
{
|
||||
$this->controller = $controller;
|
||||
$this->logger = $logger;
|
||||
$this->debug = $debug;
|
||||
}
|
||||
|
||||
public function onKernelException(GetResponseForExceptionEvent $event)
|
||||
@ -71,7 +73,7 @@ class ExceptionListener implements EventSubscriberInterface
|
||||
|
||||
$event->setResponse($response);
|
||||
|
||||
if ($eventDispatcher instanceof EventDispatcherInterface) {
|
||||
if ($this->debug && $eventDispatcher instanceof EventDispatcherInterface) {
|
||||
$cspRemovalListener = function (FilterResponseEvent $event) use (&$cspRemovalListener, $eventDispatcher) {
|
||||
$event->getResponse()->headers->remove('Content-Security-Policy');
|
||||
$eventDispatcher->removeListener(KernelEvents::RESPONSE, $cspRemovalListener);
|
||||
|
@ -134,7 +134,7 @@ class ExceptionListenerTest extends TestCase
|
||||
return new Response($request->getRequestFormat());
|
||||
}));
|
||||
|
||||
$listener = new ExceptionListener('foo', $this->getMockBuilder('Psr\Log\LoggerInterface')->getMock());
|
||||
$listener = new ExceptionListener('foo', $this->getMockBuilder('Psr\Log\LoggerInterface')->getMock(), true);
|
||||
|
||||
$dispatcher->addSubscriber($listener);
|
||||
|
||||
|
@ -1125,7 +1125,7 @@ class Process implements \IteratorAggregate
|
||||
/**
|
||||
* Sets the environment variables.
|
||||
*
|
||||
* An environment variable value should be a string.
|
||||
* Each environment variable value should be a string.
|
||||
* If it is an array, the variable is ignored.
|
||||
* If it is false or null, it will be removed when
|
||||
* env vars are otherwise inherited.
|
||||
|
@ -11,6 +11,8 @@
|
||||
|
||||
namespace Symfony\Component\Security\Core\Authentication\Token;
|
||||
|
||||
use Symfony\Component\Security\Core\Role\RoleInterface;
|
||||
|
||||
/**
|
||||
* PreAuthenticatedToken implements a pre-authenticated token.
|
||||
*
|
||||
|
@ -101,9 +101,9 @@ abstract class AbstractDumper implements DataDumperInterface, DumperInterface
|
||||
/**
|
||||
* Sets the indentation pad string.
|
||||
*
|
||||
* @param string $pad A string the will be prepended to dumped lines, repeated by nesting level
|
||||
* @param string $pad A string that will be prepended to dumped lines, repeated by nesting level
|
||||
*
|
||||
* @return string The indent pad
|
||||
* @return string The previous indent pad
|
||||
*/
|
||||
public function setIndentPad($pad)
|
||||
{
|
||||
|
Reference in New Issue
Block a user