Skip to content

Commit 96e684b

Browse files
committed
Merge branch '2.8' into 3.0
* 2.8: [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 [DomCrawler] Revert previous restriction, allow selection of every DOMNode object [Serializer] Make metadata interfaces internal [Yaml] fix indented line handling in folded blocks improve BrowserKit test coverage p1
2 parents 4aafa16 + aed7fdf commit 96e684b

File tree

4 files changed

+91
-0
lines changed

4 files changed

+91
-0
lines changed

Form/ChoiceList/ORMQueryBuilderLoader.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ public function getEntitiesByIds($identifier, array $values)
5858
$qb = clone $this->queryBuilder;
5959
$alias = current($qb->getRootAliases());
6060
$parameter = 'ORMQueryBuilderLoader_getEntitiesByIds_'.$identifier;
61+
$parameter = str_replace('.', '_', $parameter);
6162
$where = $qb->expr()->in($alias.'.'.$identifier, ':'.$parameter);
6263

6364
// 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+
}

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
{
@@ -84,4 +85,38 @@ public function testFilterNonIntegerValues()
8485
$loader = new ORMQueryBuilderLoader($qb);
8586
$loader->getEntitiesByIds('id', array(1, '', 2, 3, 'foo'));
8687
}
88+
89+
public function testEmbeddedIdentifierName()
90+
{
91+
if (Version::compare('2.5.0') > 0) {
92+
$this->markTestSkipped('Applicable only for Doctrine >= 2.5.0');
93+
94+
return;
95+
}
96+
97+
$em = DoctrineTestHelper::createTestEntityManager();
98+
99+
$query = $this->getMockBuilder('QueryMock')
100+
->setMethods(array('setParameter', 'getResult', 'getSql', '_doExecute'))
101+
->getMock();
102+
103+
$query->expects($this->once())
104+
->method('setParameter')
105+
->with('ORMQueryBuilderLoader_getEntitiesByIds_id_value', array(1, 2, 3), Connection::PARAM_INT_ARRAY)
106+
->willReturn($query);
107+
108+
$qb = $this->getMockBuilder('Doctrine\ORM\QueryBuilder')
109+
->setConstructorArgs(array($em))
110+
->setMethods(array('getQuery'))
111+
->getMock();
112+
$qb->expects($this->once())
113+
->method('getQuery')
114+
->willReturn($query);
115+
116+
$qb->select('e')
117+
->from('Symfony\Bridge\Doctrine\Tests\Fixtures\EmbeddedIdentifierEntity', 'e');
118+
119+
$loader = new ORMQueryBuilderLoader($qb);
120+
$loader->getEntitiesByIds('id.value', array(1, '', 2, 3, 'foo'));
121+
}
87122
}

0 commit comments

Comments
 (0)