Skip to content

Commit 8d99d57

Browse files
committed
Merge branch '3.2'
* 3.2: fixed tests fixed tests revert typo fix [Form] Fix ChoiceType to ensure submitted data is not nested unnecessarily Fix phpstorm helper to the official format Test inline styles with non-decorated formatter Fix RuntimeException when an Emacs buffer is modified [Yaml] add tests for specific mapping keys
2 parents c10f89f + 120f293 commit 8d99d57

File tree

6 files changed

+71
-3
lines changed

6 files changed

+71
-3
lines changed

src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ public function load(array $configs, ContainerBuilder $container)
131131
'macvim' => 'mvim://open?url=file://%%f&line=%%l',
132132
'emacs' => 'emacs://open?url=file://%%f&line=%%l',
133133
'sublime' => 'subl://open?url=file://%%f&line=%%l',
134-
'phpstorm' => 'phpstorm://open?url=file://%%f&line=%%l',
134+
'phpstorm' => 'phpstorm://open?file=%%f&line=%%l',
135135
);
136136
$ide = $config['ide'];
137137

src/Symfony/Component/Config/Resource/DirectoryResource.php

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,8 +90,15 @@ public function isFresh($timestamp)
9090
continue;
9191
}
9292

93+
// for broken links
94+
try {
95+
$fileMTime = $file->getMTime();
96+
} catch (\RuntimeException $e) {
97+
continue;
98+
}
99+
93100
// early return if a file's mtime exceeds the passed timestamp
94-
if ($timestamp < $file->getMTime()) {
101+
if ($timestamp < $fileMTime) {
95102
return false;
96103
}
97104
}

src/Symfony/Component/Console/Tests/Formatter/OutputFormatterTest.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -257,6 +257,9 @@ public function testNotDecoratedFormatter()
257257
$this->assertEquals(
258258
'some question', $formatter->format('<question>some question</question>')
259259
);
260+
$this->assertEquals(
261+
'some text with inline style', $formatter->format('<fg=red>some text with inline style</>')
262+
);
260263

261264
$formatter->setDecorated(true);
262265

@@ -272,6 +275,9 @@ public function testNotDecoratedFormatter()
272275
$this->assertEquals(
273276
"\033[30;46msome question\033[39;49m", $formatter->format('<question>some question</question>')
274277
);
278+
$this->assertEquals(
279+
"\033[31msome text with inline style\033[39m", $formatter->format('<fg=red>some text with inline style</>')
280+
);
275281
}
276282

277283
public function testContentWithLineBreaks()

src/Symfony/Component/Form/Extension/Core/Type/ChoiceType.php

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,22 @@ public function buildForm(FormBuilderInterface $builder, array $options)
156156
// transformation is merged back into the original collection
157157
$builder->addEventSubscriber(new MergeCollectionListener(true, true));
158158
}
159+
160+
// To avoid issues when the submitted choices are arrays (i.e. array to string conversions),
161+
// we have to ensure that all elements of the submitted choice data are strings or null.
162+
$builder->addEventListener(FormEvents::PRE_SUBMIT, function (FormEvent $event) {
163+
$data = $event->getData();
164+
165+
if (!is_array($data)) {
166+
return;
167+
}
168+
169+
foreach ($data as $v) {
170+
if (null !== $v && !is_string($v)) {
171+
throw new TransformationFailedException('All choices submitted must be NULL or strings.');
172+
}
173+
}
174+
}, 256);
159175
}
160176

161177
/**

src/Symfony/Component/Form/Tests/Extension/Core/Type/ChoiceTypeTest.php

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,10 @@
1313

1414
use Symfony\Component\Form\ChoiceList\View\ChoiceGroupView;
1515
use Symfony\Component\Form\ChoiceList\View\ChoiceView;
16+
use Symfony\Component\Form\Extension\Core\ChoiceList\ObjectChoiceList;
17+
use Symfony\Component\Form\Test\TypeTestCase;
1618

17-
class ChoiceTypeTest extends \Symfony\Component\Form\Test\TypeTestCase
19+
class ChoiceTypeTest extends TypeTestCase
1820
{
1921
private $choices = array(
2022
'Bernhard' => 'a',
@@ -1743,4 +1745,30 @@ public function testCustomChoiceTypeDoesNotInheritChoiceLabels()
17431745
// In this case the 'choice_label' closure returns null and not the closure from the first choice type.
17441746
$this->assertNull($form->get('subChoice')->getConfig()->getOption('choice_label'));
17451747
}
1748+
1749+
/**
1750+
* @dataProvider invalidNestedValueTestMatrix
1751+
*/
1752+
public function testSubmitInvalidNestedValue($multiple, $expanded, $submissionData)
1753+
{
1754+
$form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\ChoiceType', null, array(
1755+
'choices' => $this->choices,
1756+
'multiple' => $multiple,
1757+
'expanded' => $expanded,
1758+
));
1759+
1760+
$form->submit($submissionData);
1761+
$this->assertFalse($form->isSynchronized());
1762+
$this->assertEquals('All choices submitted must be NULL or strings.', $form->getTransformationFailure()->getMessage());
1763+
}
1764+
1765+
public function invalidNestedValueTestMatrix()
1766+
{
1767+
return array(
1768+
'non-multiple, non-expanded' => array(false, false, array(array())),
1769+
'non-multiple, expanded' => array(false, true, array(array())),
1770+
'multiple, non-expanded' => array(true, false, array(array())),
1771+
'multiple, expanded' => array(true, true, array(array())),
1772+
);
1773+
}
17461774
}

src/Symfony/Component/Yaml/Tests/InlineTest.php

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -718,4 +718,15 @@ public function getTestsForNullValues()
718718
'null before comma' => array('{foo:, bar: baz}', array('foo' => null, 'bar' => 'baz')),
719719
);
720720
}
721+
722+
public function testBooleanMappingKeysAreConvertedToStrings()
723+
{
724+
$this->assertSame(array('false' => 'foo'), Inline::parse('{false: foo}'));
725+
$this->assertSame(array('true' => 'foo'), Inline::parse('{true: foo}'));
726+
}
727+
728+
public function testTheEmptyStringIsAValidMappingKey()
729+
{
730+
$this->assertSame(array('' => 'foo'), Inline::parse('{ "": foo }'));
731+
}
721732
}

0 commit comments

Comments
 (0)