Skip to content

Commit aed7fdf

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 152c512 + b2bc4aa commit aed7fdf

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
@@ -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+
}

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
}

0 commit comments

Comments
 (0)