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

Skip to content

Commit 1fa24cb

Browse files
author
Robin Chalas
committed
Merge branch '3.4' into 4.1
* 3.4: properly fix tests on PHP 5 fix tests on PHP 5 bug #29697 [DI] Fixed wrong factory method in exception (Wojciech Gorczyca) Changed gender choice types to color remove no longer needed PHP version checks Fixed groupBy argument value in DefaultChoiceListFactoryTest [HttpKernel] Correctly Render Signed URIs Containing Fragments [HttpFoundation] Fix request uri when it starts with double slashes
2 parents 96b962d + 7af9c5d commit 1fa24cb

File tree

15 files changed

+134
-30
lines changed

15 files changed

+134
-30
lines changed

.github/build-packages.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
$mergeBase = trim(shell_exec(sprintf('git merge-base "%s" HEAD', array_shift($dirs))));
1717

1818
$packages = array();
19-
$flags = \PHP_VERSION_ID >= 50400 ? JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE : 0;
19+
$flags = JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE;
2020

2121
foreach ($dirs as $k => $dir) {
2222
if (!system("git diff --name-only $mergeBase -- $dir", $exitStatus)) {

src/Symfony/Component/DependencyInjection/Tests/Compiler/ResolveNamedArgumentsPassTest.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
use Symfony\Component\DependencyInjection\ContainerBuilder;
1717
use Symfony\Component\DependencyInjection\Reference;
1818
use Symfony\Component\DependencyInjection\Tests\Fixtures\CaseSensitiveClass;
19-
use Symfony\Component\DependencyInjection\Tests\Fixtures\FactoryDummy;
19+
use Symfony\Component\DependencyInjection\Tests\Fixtures\FactoryDummyWithoutReturnTypes;
2020
use Symfony\Component\DependencyInjection\Tests\Fixtures\NamedArgumentsDummy;
2121
use Symfony\Component\DependencyInjection\Tests\Fixtures\NamedArgumentsVariadicsDummy;
2222
use Symfony\Component\DependencyInjection\Tests\Fixtures\SimilarArgumentsDummy;
@@ -120,16 +120,16 @@ public function testArgumentNotFound()
120120

121121
/**
122122
* @expectedException \Symfony\Component\DependencyInjection\Exception\InvalidArgumentException
123-
* @expectedExceptionMessage Invalid service "Symfony\Component\DependencyInjection\Tests\Fixtures\TestDefinition1": method "Symfony\Component\DependencyInjection\Tests\Fixtures\FactoryDummy::create()" has no argument named "$notFound". Check your service definition.
123+
* @expectedExceptionMessage Invalid service "Symfony\Component\DependencyInjection\Tests\Fixtures\TestDefinition1": method "Symfony\Component\DependencyInjection\Tests\Fixtures\FactoryDummyWithoutReturnTypes::createTestDefinition1()" has no argument named "$notFound". Check your service definition.
124124
*/
125125
public function testCorrectMethodReportedInException()
126126
{
127127
$container = new ContainerBuilder();
128128

129-
$container->register(FactoryDummy::class, FactoryDummy::class);
129+
$container->register(FactoryDummyWithoutReturnTypes::class, FactoryDummyWithoutReturnTypes::class);
130130

131131
$definition = $container->register(TestDefinition1::class, TestDefinition1::class);
132-
$definition->setFactory(array(FactoryDummy::class, 'create'));
132+
$definition->setFactory(array(FactoryDummyWithoutReturnTypes::class, 'createTestDefinition1'));
133133
$definition->setArguments(array('$notFound' => '123'));
134134

135135
$pass = new ResolveNamedArgumentsPass();
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
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\DependencyInjection\Tests\Fixtures;
13+
14+
class FactoryDummyWithoutReturnTypes
15+
{
16+
public function createTestDefinition1()
17+
{
18+
}
19+
}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
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\DependencyInjection\Tests\Fixtures;
13+
14+
use Symfony\Component\DependencyInjection\Definition;
15+
16+
class TestDefinition1 extends Definition
17+
{
18+
}

src/Symfony/Component/Form/Forms.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,8 @@
2626
* ->add('firstName', 'Symfony\Component\Form\Extension\Core\Type\TextType')
2727
* ->add('lastName', 'Symfony\Component\Form\Extension\Core\Type\TextType')
2828
* ->add('age', 'Symfony\Component\Form\Extension\Core\Type\IntegerType')
29-
* ->add('gender', 'Symfony\Component\Form\Extension\Core\Type\ChoiceType', array(
30-
* 'choices' => array('Male' => 'm', 'Female' => 'f'),
29+
* ->add('color', 'Symfony\Component\Form\Extension\Core\Type\ChoiceType', array(
30+
* 'choices' => array('Red' => 'r', 'Blue' => 'b'),
3131
* ))
3232
* ->getForm();
3333
*

src/Symfony/Component/Form/Tests/ChoiceList/Factory/DefaultChoiceListFactoryTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -443,7 +443,7 @@ public function testCreateViewFlatGroupByEmpty()
443443
array($this->obj2, $this->obj3),
444444
null, // label
445445
null, // index
446-
array() // ignored
446+
null // group
447447
);
448448

449449
$this->assertFlatView($view);

src/Symfony/Component/Form/Tests/CompoundFormPerformanceTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,8 @@ public function testArrayBasedForm()
3131
$form = $this->factory->createBuilder('Symfony\Component\Form\Extension\Core\Type\FormType')
3232
->add('firstName', 'Symfony\Component\Form\Extension\Core\Type\TextType')
3333
->add('lastName', 'Symfony\Component\Form\Extension\Core\Type\TextType')
34-
->add('gender', 'Symfony\Component\Form\Extension\Core\Type\ChoiceType', array(
35-
'choices' => array('male' => 'Male', 'female' => 'Female'),
34+
->add('color', 'Symfony\Component\Form\Extension\Core\Type\ChoiceType', array(
35+
'choices' => array('red' => 'Red', 'blue' => 'Blue'),
3636
'required' => false,
3737
))
3838
->add('age', 'Symfony\Component\Form\Extension\Core\Type\NumberType')

src/Symfony/Component/HttpFoundation/Request.php

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1696,15 +1696,23 @@ protected function prepareRequestUri()
16961696
} elseif ($this->server->has('REQUEST_URI')) {
16971697
$requestUri = $this->server->get('REQUEST_URI');
16981698

1699-
// HTTP proxy reqs setup request URI with scheme and host [and port] + the URL path, only use URL path
1700-
$uriComponents = parse_url($requestUri);
1699+
if ('' !== $requestUri && '/' === $requestUri[0]) {
1700+
// To only use path and query remove the fragment.
1701+
if (false !== $pos = strpos($requestUri, '#')) {
1702+
$requestUri = substr($requestUri, 0, $pos);
1703+
}
1704+
} else {
1705+
// HTTP proxy reqs setup request URI with scheme and host [and port] + the URL path,
1706+
// only use URL path.
1707+
$uriComponents = parse_url($requestUri);
17011708

1702-
if (isset($uriComponents['path'])) {
1703-
$requestUri = $uriComponents['path'];
1704-
}
1709+
if (isset($uriComponents['path'])) {
1710+
$requestUri = $uriComponents['path'];
1711+
}
17051712

1706-
if (isset($uriComponents['query'])) {
1707-
$requestUri .= '?'.$uriComponents['query'];
1713+
if (isset($uriComponents['query'])) {
1714+
$requestUri .= '?'.$uriComponents['query'];
1715+
}
17081716
}
17091717
} elseif ($this->server->has('ORIG_PATH_INFO')) {
17101718
// IIS 5.0, PHP as CGI

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

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -283,6 +283,55 @@ public function testCreateWithRequestUri()
283283
$this->assertEquals('http://test.com/foo', $request->getUri());
284284
}
285285

286+
/**
287+
* @dataProvider getRequestUriData
288+
*/
289+
public function testGetRequestUri($serverRequestUri, $expected, $message)
290+
{
291+
$request = new Request();
292+
$request->server->add(array(
293+
'REQUEST_URI' => $serverRequestUri,
294+
295+
// For having http://test.com
296+
'SERVER_NAME' => 'test.com',
297+
'SERVER_PORT' => 80,
298+
));
299+
300+
$this->assertSame($expected, $request->getRequestUri(), $message);
301+
$this->assertSame($expected, $request->server->get('REQUEST_URI'), 'Normalize the request URI.');
302+
}
303+
304+
public function getRequestUriData()
305+
{
306+
$message = 'Do not modify the path.';
307+
yield array('/foo', '/foo', $message);
308+
yield array('//bar/foo', '//bar/foo', $message);
309+
yield array('///bar/foo', '///bar/foo', $message);
310+
311+
$message = 'Handle when the scheme, host are on REQUEST_URI.';
312+
yield array('http://test.com/foo?bar=baz', '/foo?bar=baz', $message);
313+
314+
$message = 'Handle when the scheme, host and port are on REQUEST_URI.';
315+
yield array('http://test.com:80/foo', '/foo', $message);
316+
yield array('https://test.com:8080/foo', '/foo', $message);
317+
yield array('https://test.com:443/foo', '/foo', $message);
318+
319+
$message = 'Fragment should not be included in the URI';
320+
yield array('http://test.com/foo#bar', '/foo', $message);
321+
yield array('/foo#bar', '/foo', $message);
322+
}
323+
324+
public function testGetRequestUriWithoutRequiredHeader()
325+
{
326+
$expected = '';
327+
328+
$request = new Request();
329+
330+
$message = 'Fallback to empty URI when headers are missing.';
331+
$this->assertSame($expected, $request->getRequestUri(), $message);
332+
$this->assertSame($expected, $request->server->get('REQUEST_URI'), 'Normalize the request URI.');
333+
}
334+
286335
public function testCreateCheckPrecedence()
287336
{
288337
// server is used by default

src/Symfony/Component/HttpKernel/Tests/DataCollector/DumpDataCollectorTest.php

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -144,11 +144,8 @@ public function testFlushNothingWhenDataDumperIsProvided()
144144
$collector->dump($data);
145145
$line = __LINE__ - 1;
146146
$output = preg_replace("/\033\[[^m]*m/", '', ob_get_clean());
147-
if (\PHP_VERSION_ID >= 50400) {
148-
$this->assertSame("DumpDataCollectorTest.php on line {$line}:\n456\n", $output);
149-
} else {
150-
$this->assertSame("\"DumpDataCollectorTest.php on line {$line}:\"\n456\n", $output);
151-
}
147+
148+
$this->assertSame("DumpDataCollectorTest.php on line {$line}:\n456\n", $output);
152149

153150
ob_start();
154151
$collector->__destruct();

0 commit comments

Comments
 (0)