1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84
|
<?php
declare(strict_types=1);
namespace Doctrine\Tests\ORM\Functional\Ticket;
use Doctrine\ORM\Mapping\Column;
use Doctrine\ORM\Mapping\Entity;
use Doctrine\ORM\Mapping\GeneratedValue;
use Doctrine\ORM\Mapping\Id;
use Doctrine\ORM\Mapping\OneToOne;
use Doctrine\ORM\QueryBuilder;
use Doctrine\Tests\OrmFunctionalTestCase;
use function assert;
class DDC1757Test extends OrmFunctionalTestCase
{
public function testFailingCase(): void
{
$qb = $this->_em->createQueryBuilder();
assert($qb instanceof QueryBuilder);
$qb->select('_a')
->from(DDC1757A::class, '_a')
->from(DDC1757B::class, '_b')
->join('_b.c', '_c')
->join('_c.d', '_d');
$q = $qb->getQuery();
$dql = $q->getDQL();
// Show difference between expected and actual queries on error
self::assertEquals(
'SELECT _a FROM ' . __NAMESPACE__ . '\DDC1757A _a, ' . __NAMESPACE__ . '\DDC1757B _b INNER JOIN _b.c _c INNER JOIN _c.d _d',
$dql,
'Wrong DQL query',
);
}
}
#[Entity]
class DDC1757A
{
#[Column(type: 'integer')]
#[Id]
#[GeneratedValue(strategy: 'AUTO')]
private int $id;
}
#[Entity]
class DDC1757B
{
#[Column(type: 'integer')]
#[Id]
#[GeneratedValue(strategy: 'AUTO')]
private int $id;
#[OneToOne(targetEntity: 'DDC1757C')]
private DDC1757C $c;
}
#[Entity]
class DDC1757C
{
/** @var int */
#[Column(type: 'integer')]
#[Id]
#[GeneratedValue(strategy: 'AUTO')]
public $id;
#[OneToOne(targetEntity: 'DDC1757D')]
private DDC1757D $d;
}
#[Entity]
class DDC1757D
{
/** @var int */
#[Column(type: 'integer')]
#[Id]
#[GeneratedValue(strategy: 'AUTO')]
public $id;
}
|