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

Skip to content

Commit d15bb73

Browse files
committed
Merge branch '2.3'
* 2.3: Added sleep() workaround for windows php rename bug [HttpKernel] removed unused variable [Form] Fixed: Added "validation_groups" option to submit button [Process] Fix for #8754 (Timed-out processes are successful) Conflicts: src/Symfony/Component/Form/Tests/Extension/Validator/Type/FormTypeValidatorExtensionTest.php
2 parents a67f5d0 + 91e5b10 commit d15bb73

File tree

9 files changed

+116
-61
lines changed

9 files changed

+116
-61
lines changed

src/Symfony/Bundle/FrameworkBundle/Command/CacheClearCommand.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,9 @@ protected function execute(InputInterface $input, OutputInterface $output)
8383
$this->warmup($warmupDir, $realCacheDir, !$input->getOption('no-optional-warmers'));
8484

8585
$filesystem->rename($realCacheDir, $oldCacheDir);
86+
if (defined('PHP_WINDOWS_VERSION_BUILD')) {
87+
sleep(1); // workaround for windows php rename bug
88+
}
8689
$filesystem->rename($warmupDir, $realCacheDir);
8790
}
8891

src/Symfony/Component/Form/Extension/Validator/Type/SubmitTypeValidatorExtension.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,10 @@
1111

1212
namespace Symfony\Component\Form\Extension\Validator\Type;
1313

14-
use Symfony\Component\Form\AbstractTypeExtension;
15-
1614
/**
1715
* @author Bernhard Schussek <[email protected]>
1816
*/
19-
class SubmitTypeValidatorExtension extends AbstractTypeExtension
17+
class SubmitTypeValidatorExtension extends BaseValidatorExtension
2018
{
2119
/**
2220
* {@inheritdoc}
Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
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\Extension\Validator\Type;
13+
14+
use Symfony\Component\Form\Test\FormInterface;
15+
16+
/**
17+
* @author Bernhard Schussek <[email protected]>
18+
*/
19+
abstract class BaseValidatorExtensionTest extends TypeTestCase
20+
{
21+
public function testValidationGroupNullByDefault()
22+
{
23+
$form = $this->createForm();
24+
25+
$this->assertNull($form->getConfig()->getOption('validation_groups'));
26+
}
27+
28+
public function testValidationGroupsTransformedToArray()
29+
{
30+
$form = $this->createForm(array(
31+
'validation_groups' => 'group',
32+
));
33+
34+
$this->assertEquals(array('group'), $form->getConfig()->getOption('validation_groups'));
35+
}
36+
37+
public function testValidationGroupsCanBeSetToArray()
38+
{
39+
$form = $this->createForm(array(
40+
'validation_groups' => array('group1', 'group2'),
41+
));
42+
43+
$this->assertEquals(array('group1', 'group2'), $form->getConfig()->getOption('validation_groups'));
44+
}
45+
46+
public function testValidationGroupsCanBeSetToFalse()
47+
{
48+
$form = $this->createForm(array(
49+
'validation_groups' => false,
50+
));
51+
52+
$this->assertEquals(array(), $form->getConfig()->getOption('validation_groups'));
53+
}
54+
55+
public function testValidationGroupsCanBeSetToCallback()
56+
{
57+
$form = $this->createForm(array(
58+
'validation_groups' => array($this, 'testValidationGroupsCanBeSetToCallback'),
59+
));
60+
61+
$this->assertTrue(is_callable($form->getConfig()->getOption('validation_groups')));
62+
}
63+
64+
public function testValidationGroupsCanBeSetToClosure()
65+
{
66+
$form = $this->createForm(array(
67+
'validation_groups' => function(FormInterface $form){ return null; },
68+
));
69+
70+
$this->assertTrue(is_callable($form->getConfig()->getOption('validation_groups')));
71+
}
72+
73+
abstract protected function createForm(array $options = array());
74+
}

src/Symfony/Component/Form/Tests/Extension/Validator/Type/FormTypeValidatorExtensionTest.php

Lines changed: 6 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -11,63 +11,10 @@
1111

1212
namespace Symfony\Component\Form\Tests\Extension\Validator\Type;
1313

14-
use Symfony\Component\Form\FormInterface;
1514
use Symfony\Component\Validator\ConstraintViolationList;
1615

17-
class FormTypeValidatorExtensionTest extends TypeTestCase
16+
class FormTypeValidatorExtensionTest extends BaseValidatorExtensionTest
1817
{
19-
public function testValidationGroupNullByDefault()
20-
{
21-
$form = $this->factory->create('form');
22-
23-
$this->assertNull($form->getConfig()->getOption('validation_groups'));
24-
}
25-
26-
public function testValidationGroupsTransformedToArray()
27-
{
28-
$form = $this->factory->create('form', null, array(
29-
'validation_groups' => 'group',
30-
));
31-
32-
$this->assertEquals(array('group'), $form->getConfig()->getOption('validation_groups'));
33-
}
34-
35-
public function testValidationGroupsCanBeSetToArray()
36-
{
37-
$form = $this->factory->create('form', null, array(
38-
'validation_groups' => array('group1', 'group2'),
39-
));
40-
41-
$this->assertEquals(array('group1', 'group2'), $form->getConfig()->getOption('validation_groups'));
42-
}
43-
44-
public function testValidationGroupsCanBeSetToFalse()
45-
{
46-
$form = $this->factory->create('form', null, array(
47-
'validation_groups' => false,
48-
));
49-
50-
$this->assertEquals(array(), $form->getConfig()->getOption('validation_groups'));
51-
}
52-
53-
public function testValidationGroupsCanBeSetToCallback()
54-
{
55-
$form = $this->factory->create('form', null, array(
56-
'validation_groups' => array($this, 'testValidationGroupsCanBeSetToCallback'),
57-
));
58-
59-
$this->assertTrue(is_callable($form->getConfig()->getOption('validation_groups')));
60-
}
61-
62-
public function testValidationGroupsCanBeSetToClosure()
63-
{
64-
$form = $this->factory->create('form', null, array(
65-
'validation_groups' => function(FormInterface $form){ return null; },
66-
));
67-
68-
$this->assertTrue(is_callable($form->getConfig()->getOption('validation_groups')));
69-
}
70-
7118
public function testSubmitValidatesData()
7219
{
7320
$builder = $this->factory->createBuilder(
@@ -88,4 +35,9 @@ public function testSubmitValidatesData()
8835
// specific data is irrelevant
8936
$form->submit(array());
9037
}
38+
39+
protected function createForm(array $options = array())
40+
{
41+
return $this->factory->create('form', null, $options);
42+
}
9143
}
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
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\Extension\Validator\Type;
13+
14+
class SubmitTypeValidatorExtensionTest extends BaseValidatorExtensionTest
15+
{
16+
protected function createForm(array $options = array())
17+
{
18+
return $this->factory->create('submit', null, $options);
19+
}
20+
}

src/Symfony/Component/HttpKernel/Kernel.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,8 @@ abstract class Kernel implements KernelInterface, TerminableInterface
5858
protected $booted;
5959
protected $name;
6060
protected $startTime;
61-
protected $classes;
6261
protected $loadClassCache;
62+
protected $errorReportingLevel;
6363

6464
const VERSION = '2.4.0-DEV';
6565
const VERSION_ID = '20400';
@@ -83,7 +83,6 @@ public function __construct($environment, $debug)
8383
$this->booted = false;
8484
$this->rootDir = $this->getRootDir();
8585
$this->name = $this->getName();
86-
$this->classes = array();
8786
$this->bundles = array();
8887

8988
if ($this->debug) {

src/Symfony/Component/Process/Process.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -651,9 +651,9 @@ public function stop($timeout = 10, $signal = null)
651651
$timeoutMicro = microtime(true) + $timeout;
652652
if ($this->isRunning()) {
653653
proc_terminate($this->process);
654-
while ($this->isRunning() && microtime(true) < $timeoutMicro) {
654+
do {
655655
usleep(1000);
656-
}
656+
} while ($this->isRunning() && microtime(true) < $timeoutMicro);
657657

658658
if ($this->isRunning() && !$this->isSigchildEnabled()) {
659659
if (null !== $signal || defined('SIGKILL')) {

src/Symfony/Component/Process/Tests/AbstractProcessTest.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -445,6 +445,7 @@ public function testCheckTimeoutOnStartedProcess()
445445
$duration = microtime(true) - $start;
446446

447447
$this->assertLessThan($timeout + $precision, $duration);
448+
$this->assertFalse($process->isSuccessful());
448449
}
449450

450451
/**

src/Symfony/Component/Process/Tests/SigchildDisabledProcessTest.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,14 @@ public function testProcessWithoutTermSignal()
6161
parent::testProcessWithoutTermSignal();
6262
}
6363

64+
/**
65+
* @expectedException \Symfony\Component\Process\Exception\RuntimeException
66+
*/
67+
public function testCheckTimeoutOnStartedProcess()
68+
{
69+
parent::testCheckTimeoutOnStartedProcess();
70+
}
71+
6472
/**
6573
* @expectedException \Symfony\Component\Process\Exception\RuntimeException
6674
*/

0 commit comments

Comments
 (0)