Skip to content

Commit 4d2ea16

Browse files
Merge branch '2.8'
* 2.8: Add Spanish translation for BIC validator Added translation for BIC validator Sent out a status text for unknown HTTP headers. [DependencyInjection] Unescape parameters for all types of injection [Process] Fix trailing space in PHP binary finder Remove tmp addition of zend-stdlib [WebProfilerBundle] Fix minitoolbar height [Form] Fix ResolvedFormType deprecation notices [Serializer] add missing unit tests related to Encoder add it back Conflicts: src/Symfony/Bridge/ProxyManager/composer.json src/Symfony/Component/Form/ResolvedFormType.php
2 parents dba51b4 + fe6e9e4 commit 4d2ea16

File tree

14 files changed

+356
-24
lines changed

14 files changed

+356
-24
lines changed

composer.json

-1
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,6 @@
8080
"doctrine/orm": "~2.4,>=2.4.5",
8181
"doctrine/doctrine-bundle": "~1.4",
8282
"monolog/monolog": "~1.11",
83-
"zendframework/zend-stdlib": "~2.2",
8483
"ocramius/proxy-manager": "~0.4|~1.0",
8584
"egulias/email-validator": "~1.2",
8685
"symfony/security-acl": "~2.8|~3.0",

src/Symfony/Bridge/ProxyManager/composer.json

-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818
"require": {
1919
"php": ">=5.5.9",
2020
"symfony/dependency-injection": "~2.8|~3.0",
21-
"zendframework/zend-stdlib": "~2.2",
2221
"ocramius/proxy-manager": "~0.4|~1.0"
2322
},
2423
"require-dev": {

src/Symfony/Bundle/WebProfilerBundle/Resources/views/Profiler/toolbar.css.twig

+12-3
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,20 @@
22
background-color: #222;
33
bottom: 0;
44
display: none;
5-
height: 36px;
6-
padding: 5px 6px 0;
5+
height: 30px;
6+
padding: 6px 6px 0;
77
position: fixed;
88
right: 0;
99
z-index: 99999;
1010
}
11+
.sf-minitoolbar a {
12+
display: block;
13+
}
14+
.sf-minitoolbar svg,
15+
.sf-minitoolbar img {
16+
max-height: 24px;
17+
max-width: 24px;
18+
}
1119

1220
.sf-toolbarreset * {
1321
-webkit-box-sizing: content-box;
@@ -36,7 +44,8 @@
3644
}
3745
.sf-toolbarreset svg,
3846
.sf-toolbarreset img {
39-
max-height: 20px;
47+
max-height: 24px;
48+
max-width: 24px;
4049
}
4150

4251
.sf-toolbarreset .hide-button {

src/Symfony/Component/DependencyInjection/ContainerBuilder.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -872,7 +872,7 @@ private function createService(Definition $definition, $id, $tryProxy = true)
872872
$this->callMethod($service, $call);
873873
}
874874

875-
$properties = $this->resolveServices($parameterBag->resolveValue($definition->getProperties()));
875+
$properties = $this->resolveServices($parameterBag->unescapeValue($parameterBag->resolveValue($definition->getProperties())));
876876
foreach ($properties as $name => $value) {
877877
$service->$name = $value;
878878
}
@@ -1038,7 +1038,7 @@ private function callMethod($service, $call)
10381038
}
10391039
}
10401040

1041-
call_user_func_array(array($service, $call[0]), $this->resolveServices($this->getParameterBag()->resolveValue($call[1])));
1041+
call_user_func_array(array($service, $call[0]), $this->resolveServices($this->getParameterBag()->unescapeValue($this->getParameterBag()->resolveValue($call[1]))));
10421042
}
10431043

10441044
/**

src/Symfony/Component/DependencyInjection/Tests/ContainerBuilderTest.php

+18
Original file line numberDiff line numberDiff line change
@@ -304,6 +304,24 @@ public function testCreateServiceMethodCalls()
304304
$this->assertEquals(array('bar', $builder->get('bar')), $builder->get('foo1')->bar, '->createService() replaces the values in the method calls arguments');
305305
}
306306

307+
public function testCreateServiceMethodCallsWithEscapedParam()
308+
{
309+
$builder = new ContainerBuilder();
310+
$builder->register('bar', 'stdClass');
311+
$builder->register('foo1', 'FooClass')->addMethodCall('setBar', array(array('%%unescape_it%%')));
312+
$builder->setParameter('value', 'bar');
313+
$this->assertEquals(array('%unescape_it%'), $builder->get('foo1')->bar, '->createService() replaces the values in the method calls arguments');
314+
}
315+
316+
public function testCreateServiceProperties()
317+
{
318+
$builder = new ContainerBuilder();
319+
$builder->register('bar', 'stdClass');
320+
$builder->register('foo1', 'FooClass')->setProperty('bar', array('%value%', new Reference('bar'), '%%unescape_it%%'));
321+
$builder->setParameter('value', 'bar');
322+
$this->assertEquals(array('bar', $builder->get('bar'), '%unescape_it%'), $builder->get('foo1')->bar, '->createService() replaces the values in the properties');
323+
}
324+
307325
public function testCreateServiceConfigurator()
308326
{
309327
$builder = new ContainerBuilder();

src/Symfony/Component/HttpFoundation/Response.php

+2-1
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,7 @@ class Response
160160
415 => 'Unsupported Media Type',
161161
416 => 'Range Not Satisfiable',
162162
417 => 'Expectation Failed',
163+
418 => 'I\'m a teapot', // RFC2324
163164
422 => 'Unprocessable Entity', // RFC4918
164165
423 => 'Locked', // RFC4918
165166
424 => 'Failed Dependency', // RFC4918
@@ -454,7 +455,7 @@ public function setStatusCode($code, $text = null)
454455
}
455456

456457
if (null === $text) {
457-
$this->statusText = isset(self::$statusTexts[$code]) ? self::$statusTexts[$code] : '';
458+
$this->statusText = isset(self::$statusTexts[$code]) ? self::$statusTexts[$code] : 'unknown status';
458459

459460
return $this;
460461
}

src/Symfony/Component/HttpFoundation/Tests/ResponseTest.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -695,7 +695,7 @@ public function getStatusCodeFixtures()
695695
array('200', null, 'OK'),
696696
array('200', false, ''),
697697
array('200', 'foo', 'foo'),
698-
array('199', null, ''),
698+
array('199', null, 'unknown status'),
699699
array('199', false, ''),
700700
array('199', 'foo', 'foo'),
701701
);

src/Symfony/Component/Process/PhpExecutableFinder.php

+5-2
Original file line numberDiff line numberDiff line change
@@ -35,14 +35,17 @@ public function __construct()
3535
*/
3636
public function find($includeArgs = true)
3737
{
38+
$args = $this->findArguments();
39+
$args = $includeArgs && $args ? ' '.implode(' ', $args) : '';
40+
3841
// HHVM support
3942
if (defined('HHVM_VERSION')) {
40-
return (getenv('PHP_BINARY') ?: PHP_BINARY).($includeArgs ? ' '.implode(' ', $this->findArguments()) : '');
43+
return (getenv('PHP_BINARY') ?: PHP_BINARY).$args;
4144
}
4245

4346
// PHP_BINARY return the current sapi executable
4447
if (defined('PHP_BINARY') && PHP_BINARY && in_array(PHP_SAPI, array('cli', 'cli-server', 'phpdbg')) && is_file(PHP_BINARY)) {
45-
return PHP_BINARY.($includeArgs ? ' '.implode(' ', $this->findArguments()) : '');
48+
return PHP_BINARY.$args;
4649
}
4750

4851
if ($php = getenv('PHP_PATH')) {
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
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\Serializer\Tests\Encoder;
13+
14+
use Symfony\Component\Serializer\Encoder\ChainDecoder;
15+
16+
class ChainDecoderTest extends \PHPUnit_Framework_TestCase
17+
{
18+
const FORMAT_1 = 'format1';
19+
const FORMAT_2 = 'format2';
20+
const FORMAT_3 = 'format3';
21+
22+
private $chainDecoder;
23+
private $decoder1;
24+
private $decoder2;
25+
26+
protected function setUp()
27+
{
28+
$this->decoder1 = $this
29+
->getMockBuilder('Symfony\Component\Serializer\Encoder\DecoderInterface')
30+
->getMock();
31+
32+
$this->decoder1
33+
->method('supportsDecoding')
34+
->will($this->returnValueMap(array(
35+
array(self::FORMAT_1, true),
36+
array(self::FORMAT_2, false),
37+
array(self::FORMAT_3, false),
38+
)));
39+
40+
$this->decoder2 = $this
41+
->getMockBuilder('Symfony\Component\Serializer\Encoder\DecoderInterface')
42+
->getMock();
43+
44+
$this->decoder2
45+
->method('supportsDecoding')
46+
->will($this->returnValueMap(array(
47+
array(self::FORMAT_1, false),
48+
array(self::FORMAT_2, true),
49+
array(self::FORMAT_3, false),
50+
)));
51+
52+
$this->chainDecoder = new ChainDecoder(array($this->decoder1, $this->decoder2));
53+
}
54+
55+
public function testSupportsDecoding()
56+
{
57+
$this->assertTrue($this->chainDecoder->supportsDecoding(self::FORMAT_1));
58+
$this->assertTrue($this->chainDecoder->supportsDecoding(self::FORMAT_2));
59+
$this->assertFalse($this->chainDecoder->supportsDecoding(self::FORMAT_3));
60+
}
61+
62+
public function testDecode()
63+
{
64+
$this->decoder1->expects($this->never())->method('decode');
65+
$this->decoder2->expects($this->once())->method('decode');
66+
67+
$this->chainDecoder->decode('string_to_decode', self::FORMAT_2);
68+
}
69+
70+
/**
71+
* @expectedException Symfony\Component\Serializer\Exception\RuntimeException
72+
*/
73+
public function testDecodeUnsupportedFormat()
74+
{
75+
$this->chainDecoder->decode('string_to_decode', self::FORMAT_3);
76+
}
77+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,129 @@
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\Serializer\Tests\Encoder;
13+
14+
use Symfony\Component\Serializer\Encoder\ChainEncoder;
15+
use Symfony\Component\Serializer\Encoder\NormalizationAwareInterface;
16+
17+
class ChainEncoderTest extends \PHPUnit_Framework_TestCase
18+
{
19+
const FORMAT_1 = 'format1';
20+
const FORMAT_2 = 'format2';
21+
const FORMAT_3 = 'format3';
22+
23+
private $chainEncoder;
24+
private $encoder1;
25+
private $encoder2;
26+
27+
protected function setUp()
28+
{
29+
$this->encoder1 = $this
30+
->getMockBuilder('Symfony\Component\Serializer\Encoder\EncoderInterface')
31+
->getMock();
32+
33+
$this->encoder1
34+
->method('supportsEncoding')
35+
->will($this->returnValueMap(array(
36+
array(self::FORMAT_1, true),
37+
array(self::FORMAT_2, false),
38+
array(self::FORMAT_3, false),
39+
)));
40+
41+
$this->encoder2 = $this
42+
->getMockBuilder('Symfony\Component\Serializer\Encoder\EncoderInterface')
43+
->getMock();
44+
45+
$this->encoder2
46+
->method('supportsEncoding')
47+
->will($this->returnValueMap(array(
48+
array(self::FORMAT_1, false),
49+
array(self::FORMAT_2, true),
50+
array(self::FORMAT_3, false),
51+
)));
52+
53+
$this->chainEncoder = new ChainEncoder(array($this->encoder1, $this->encoder2));
54+
}
55+
56+
public function testSupportsEncoding()
57+
{
58+
$this->assertTrue($this->chainEncoder->supportsEncoding(self::FORMAT_1));
59+
$this->assertTrue($this->chainEncoder->supportsEncoding(self::FORMAT_2));
60+
$this->assertFalse($this->chainEncoder->supportsEncoding(self::FORMAT_3));
61+
}
62+
63+
public function testEncode()
64+
{
65+
$this->encoder1->expects($this->never())->method('encode');
66+
$this->encoder2->expects($this->once())->method('encode');
67+
68+
$this->chainEncoder->encode(array('foo' => 123), self::FORMAT_2);
69+
}
70+
71+
/**
72+
* @expectedException Symfony\Component\Serializer\Exception\RuntimeException
73+
*/
74+
public function testEncodeUnsupportedFormat()
75+
{
76+
$this->chainEncoder->encode(array('foo' => 123), self::FORMAT_3);
77+
}
78+
79+
public function testNeedsNormalizationBasic()
80+
{
81+
$this->assertTrue($this->chainEncoder->needsNormalization(self::FORMAT_1));
82+
$this->assertTrue($this->chainEncoder->needsNormalization(self::FORMAT_2));
83+
}
84+
85+
/**
86+
* @dataProvider booleanProvider
87+
*/
88+
public function testNeedsNormalizationChainNormalizationAware($bool)
89+
{
90+
$chainEncoder = $this
91+
->getMockBuilder('Symfony\Component\Serializer\Tests\Encoder\ChainNormalizationAwareEncoder')
92+
->getMock();
93+
94+
$chainEncoder->method('supportsEncoding')->willReturn(true);
95+
$chainEncoder->method('needsNormalization')->willReturn($bool);
96+
97+
$sut = new ChainEncoder(array($chainEncoder));
98+
99+
$this->assertEquals($bool, $sut->needsNormalization(self::FORMAT_1));
100+
}
101+
102+
public function testNeedsNormalizationNormalizationAware()
103+
{
104+
$encoder = new NormalizationAwareEncoder();
105+
$sut = new ChainEncoder(array($encoder));
106+
107+
$this->assertFalse($sut->needsNormalization(self::FORMAT_1));
108+
}
109+
110+
public function booleanProvider()
111+
{
112+
return array(
113+
array(true),
114+
array(false),
115+
);
116+
}
117+
}
118+
119+
class ChainNormalizationAwareEncoder extends ChainEncoder implements NormalizationAwareInterface
120+
{
121+
}
122+
123+
class NormalizationAwareEncoder implements NormalizationAwareInterface
124+
{
125+
public function supportsEncoding($format)
126+
{
127+
return true;
128+
}
129+
}

0 commit comments

Comments
 (0)