8000 Merge branch '2.7' into 2.8 · symfony/symfony@2712922 · GitHub
[go: up one dir, main page]

Skip to content

Commit 2712922

Browse files
committed
Merge branch '2.7' into 2.8
* 2.7: [2.7] Fixed flatten exception recursion with errors Embedded identifier support Also transform inline mappings to objects Change the ExtensionInterface load method definition to bo identical to the documentation. add and correct armenian translations [Config] Fix array sort on normalization in edge case [Security] Run tests on all PHP versions [Serializer] Make metadata interfaces internal [Yaml] fix indented line handling in folded blocks improve BrowserKit test coverage p1
2 parents 09efd06 + 97cf53f commit 2712922

File tree

19 files changed

+469
-79
lines changed

19 files changed

+469
-79
lines changed

src/Symfony/Bridge/Doctrine/Form/ChoiceList/ORMQueryBuilderLoader.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,7 @@ public function getEntitiesByIds($identifier, array $values)
9292
$qb = clone $this->queryBuilder;
9393
$alias = current($qb->getRootAliases());
9494
$parameter = 'ORMQueryBuilderLoader_getEntitiesByIds_'.$identifier;
95+
$parameter = str_replace('.', '_', $parameter);
9596
$where = $qb->expr()->in($alias.'.'.$identifier, ':'.$parameter);
9697

9798
// Guess type
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
<?php
2+
3+
/*
4+
* This file is part of the Symfony package.
5+
*
6+
* (c) Fabien Potencier <fabien@symfony.com>
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\Bridge\Doctrine\Tests\Fixtures\Embeddable;
13+
14+
use Doctrine\ORM\Mapping as ORM;
15+
16+
/**
17+
* @ORM\Embeddable
18+
*/
19+
class Identifier
20+
{
21+
/**
22+
* @var int
23+
*
24+
* @ORM\Id
25+
* @ORM\Column(type="integer")
26+
*/
27+
protected $value;
28+
}
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
<?php
2+
3+
/*
4+
* This file is part of the Symfony package.
5+
*
6+
* (c) Fabien Potencier <fabien@symfony.com>
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\Bridge\Doctrine\Tests\Fixtures;
13+
14+
use Doctrine\ORM\Mapping as ORM;
15+
16+
/**
17+
* @ORM\Entity
18+
*/
19+
class EmbeddedIdentifierEntity
20+
{
21+
/**
22+
* @var Embeddable\Identifier
23+
*
24+
* @ORM\Embedded(class="Symfony\Bridge\Doctrine\Tests\Fixtures\Embeddable\Identifier")
25+
*/
26+
protected $id;
27+
}

src/Symfony/Bridge/Doctrine/Tests/Form/ChoiceList/ORMQueryBuilderLoaderTest.php

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
use Symfony\Bridge\Doctrine\Form\ChoiceList\ORMQueryBuilderLoader;
1515
use Symfony\Bridge\Doctrine\Test\DoctrineTestHelper;
1616
use Doctrine\DBAL\Connection;
17+
use Doctrine\ORM\Version;
1718

1819
class ORMQueryBuilderLoaderTest extends \PHPUnit_Framework_TestCase
1920
{
@@ -104,4 +105,38 @@ public function testFilterNonIntegerValues()
104105
$loader = new ORMQueryBuilderLoader($qb);
105106
$loader->getEntitiesByIds('id', array(1, '', 2, 3, 'foo'));
106107
}
108+
109+
public function testEmbeddedIdentifierName()
110+
{
111+
if (Version::compare('2.5.0') > 0) {
112+
$this->markTestSkipped('Applicable only for Doctrine >= 2.5.0');
113+
114+
return;
115+
}
116+
117+
$em = DoctrineTestHelper::createTestEntityManager();
118+
119+
$query = $this->getMockBuilder('QueryMock')
120+
->setMethods(array('setParameter', 'getResult', 'getSql', '_doExecute'))
121+
->getMock();
122+
123+
$query->expects($this->once())
124+
->method('setParameter')
125+
->with('ORMQueryBuilderLoader_getEntitiesByIds_id_value', array(1, 2, 3), Connection::PARAM_INT_ARRAY)
126+
->willReturn($query);
127+
128+
$qb = $this->getMockBuilder('Doctrine\ORM\QueryBuilder')
129+
->setConstructorArgs(array($em))
130+
->setMethods(array('getQuery'))
131+
->getMock();
132+
$qb->expects($this->once())
133+
->method('getQuery')
134+
->willReturn($query);
135+
136+
$qb->select('e')
137+
->from('Symfony\Bridge\Doctrine\Tests\Fixtures\EmbeddedIdentifierEntity', 'e');
138+
139+
$loader = new ORMQueryBuilderLoader($qb);
140+
$loader->getEntitiesByIds('id.value', array(1, '', 2, 3, 'foo'));
141+
}
107142
}

src/Symfony/Bundle/SecurityBundle/Tests/Functional/Bundle/FirewallEntryPointBundle/DependencyInjection/FirewallEntryPointExtension.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818

1919
class FirewallEntryPointExtension extends Extension
2020
{
21-
public function load(array $config, ContainerBuilder $container)
21+
public function load(array $configs, ContainerBuilder $container)
2222
{
2323
$loader = new XmlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config'));
2424
$loader->load('services.xml');

src/Symfony/Component/BrowserKit/Tests/ClientTest.php

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -640,4 +640,24 @@ public function testSetServerParameterInRequest()
640640
$this->assertArrayHasKey('HTTPS', $server);
641641
$this->assertFalse($server['HTTPS']);
642642
}
643+
644+
public function testInternalRequest()
645+
{
646+
$client = new TestClient();
647+
648+
$client->request('GET', 'https://www.example.com/https/www.example.com', array(), array(), array(
649+
'HTTP_HOST' => 'testhost',
650+
'HTTP_USER_AGENT' => 'testua',
651+
'HTTPS' => false,
652+
'NEW_SERVER_KEY' => 'new-server-key-value',
653+
));
654+
655+
$this->assertInstanceOf('Symfony\Component\BrowserKit\Request', $client->getInternalRequest());
656+
}
657+
658+
public function testInternalRequestNull()
659+
{
660+
$client = new TestClient();
661+
$this->assertNull($client->getInternalRequest());
662+
}
643663
}

src/Symfony/Component/BrowserKit/Tests/CookieJarTest.php

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -174,6 +174,16 @@ public function testCookieExpireWithNullPaths()
174174
$this->assertEquals(array(), array_keys($cookieJar->allValues('http://example.com/')));
175175
}
176176

177+
public function testCookieExpireWithDomain()
178+
{
179+
$cookieJar = new CookieJar();
180+
$cookieJar->set($cookie1 = new Cookie('foo', 'bar1', null, '/foo', 'http://example2.com/'));
181+
$cookieJar->expire('foo', '/foo', 'http://example2.com/');
182+
183+
$this->assertNull($cookieJar->get('foo'), '->get() returns null if the cookie is expired');
184+
$this->assertEquals(array(), array_keys($cookieJar->allValues('http://example2.com/')));
185+
}
186+
177187
public function testCookieWithSameNameButDifferentPaths()
178188
{
179189
$cookieJar = new CookieJar();
@@ -207,6 +217,14 @@ public function testCookieGetWithSubdomain()
207217
$this->assertEquals($cookie2, $cookieJar->get('foo1', '/', 'test.example.com'));
208218
}
209219

220+
public function testCookieGetWithWrongSubdomain()
221+
{
222+
$cookieJar = new CookieJar();
223+
$cookieJar->set($cookie1 = new Cookie('foo1', 'bar', null, '/', 'test.example.com'));
224+
225+
$this->assertNull($cookieJar->get('foo1', '/', 'foo.example.com'));
226+
}
227+
210228
public function testCookieGetWithSubdirectory()
211229
{
212230
$cookieJar = new CookieJar();

src/Symfony/Component/BrowserKit/Tests/CookieTest.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -176,4 +176,13 @@ public function testIsExpired()
176176
$cookie = new Cookie('foo', 'bar', 0);
177177
$this->assertFalse($cookie->isExpired());
178178
}
179+
180+
/**
181+
* @expectedException UnexpectedValueException
182+
* @expectedExceptionMessage The cookie expiration time "string" is not valid.
183+
*/
184+
public function testConstructException()
185+
{
186+
$cookie = new Cookie('foo', 'bar', 'string');
187+
}
179188
}

src/Symfony/Component/Config/Definition/ArrayNode.php

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -56,14 +56,17 @@ protected function preNormalize($value)
5656
return $value;
5757
}
5858

59+
$normalized = array();
60+
5961
foreach ($value as $k => $v) {
6062
if (false !== strpos($k, '-') && false === strpos($k, '_') && !array_key_exists($normalizedKey = str_replace('-', '_', $k), $value)) {
61-
$value[$normalizedKey] = $v;
62-
unset($value[$k]);
63+
$normalized[$normalizedKey] = $v;
64+
} else {
65+
$normalized[$k] = $v;
6366
}
6467
}
6568

66-
return $value;
69+
return $normalized;
6770
}
6871

6972
/**

src/Symfony/Component/Config/Tests/Definition/ArrayNodeTest.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,10 @@ public function getPreNormalizationTests()
8686
array('foo-bar_moo' => 'foo'),
8787
array('foo-bar_moo' => 'foo'),
8888
),
89+
array(
90+
array('anything-with-dash-and-no-underscore' => 'first', 'no_dash' => 'second'),
91+
array('anything_with_dash_and_no_underscore' => 'first', 'no_dash' => 'second'),
92+
),
8993
array(
9094
array('foo-bar' => null, 'foo_bar' => 'foo'),
9195
array('foo-bar' => null, 'foo_bar' => 'foo'),

src/Symfony/Component/Debug/Exception/FlattenException.php

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -94,8 +94,13 @@ public static function create(\Exception $exception, $statusCode = null, array $
9494
$e->setClass(get_class($exception));
9595
$e->setFile($exception->getFile());
9696
$e->setLine($exception->getLine());
97-
if ($exception->getPrevious()) {
98-
$e->setPrevious(static::create($exception->getPrevious()));
97+
98+
$previous = $exception->getPrevious();
99+
100+
if ($previous instanceof \Exception) {
101+
$e->setPrevious(static::create($previous));
102+
} elseif ($previous instanceof \Throwable) {
103+
$e->setPrevious(static::create(new FatalThrowableError($previous)));
99104
}
100105

101106
return $e;

src/Symfony/Component/Debug/Tests/Exception/FlattenExceptionTest.php

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,20 @@ public function testPrevious(\Exception $exception, $statusCode)
131131
$this->assertSame(array($flattened2), $flattened->getAllPrevious());
132132
}
133133

134+
/**
135+
* @requires PHP 7.0
136+
*/
137+
public function testPreviousError()
138+
{
139+
$exception = new \Exception('test', 123, new \ParseError('Oh noes!', 42));
140+
141+
$flattened = FlattenException::create($exception)->getPrevious();
142+
143+
$this->assertEquals($flattened->getMessage(), 'Parse error: Oh noes!', 'The message is copied from the original exception.');
144+
$this->assertEquals($flattened->getCode(), 42, 'The code is copied from the original exception.');
145+
$this->assertEquals($flattened->getClass(), 'Symfony\Component\Debug\Exception\FatalThrowableError', 'The class is set to the class of the original exception');
146+
}
147+
134148
/**
135149
* @dataProvider flattenDataProvider
136150
*/

src/Symfony/Component/DependencyInjection/Extension/ExtensionInterface.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,12 @@ interface ExtensionInterface
2323
/**
2424
* Loads a specific configuration.
2525
*
26-
* @param array $config An array of configuration values
26+
* @param array $configs An array of configuration values
2727
* @param ContainerBuilder $container A ContainerBuilder instance
2828
*
2929
* @throws \InvalidArgumentException When provided tag is not defined in this extension
3030
*/
31-
public function load(array $config, ContainerBuilder $container);
31+
public function load(array $configs, ContainerBuilder $container);
3232

3333
/**
3434
* Returns the namespace to be used for this extension (XML namespace).

src/Symfony/Component/Security/Core/Tests/Encoder/BCryptPasswordEncoderTest.php

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -45,19 +45,13 @@ public function testCostInRange()
4545
}
4646
}
4747

48-
/**
49-
* @requires PHP 5.3.7
50-
*/
5148
public function testResultLength()
5249
{
5350
$encoder = new BCryptPasswordEncoder(self::VALID_COST);
5451
$result = $encoder->encodePassword(self::PASSWORD, null);
5552
$this->assertEquals(60, strlen($result));
5653
}
5754

58-
/**
59-
* @requires PHP 5.3.7
60-
*/
6155
public function testValidation()
6256
{
6357
$encoder = new BCryptPasswordEncoder(self::VALID_COST);
@@ -76,9 +70,6 @@ public function testEncodePasswordLength()
7670
$encoder->encodePassword(str_repeat('a', 73), 'salt');
7771
}
7872

79-
/**
80-
* @requires PHP 5.3.7
81-
*/
8273
public function testCheckPasswordLength()
8374
{
8475
$encoder = new BCryptPasswordEncoder(self::VALID_COST);

src/Symfony/Component/Serializer/Mapping/AttributeMetadataInterface.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@
1616
*
1717
* Primarily, the metadata stores serialization groups.
1818
*
19+
* @internal
20+
*
1921
* @author Kévin Dunglas <dunglas@gmail.com>
2022
*/
2123
interface AttributeMetadataInterface

src/Symfony/Component/Serializer/Mapping/ClassMetadataInterface.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@
1818
*
1919
* There may only exist one metadata for each attribute according to its name.
2020
*
21+
* @internal
22+
*
2123
* @author Kévin Dunglas <dunglas@gmail.com>
2224
*/
2325
interface ClassMetadataInterface

0 commit comments

Comments
 (0)
0