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
|
<?php
declare(strict_types=1);
namespace Doctrine\Tests\ORM\Functional\Ticket;
use Doctrine\Tests\Models\GH10334\GH10334Foo;
use Doctrine\Tests\Models\GH10334\GH10334FooCollection;
use Doctrine\Tests\Models\GH10334\GH10334Product;
use Doctrine\Tests\Models\GH10334\GH10334ProductType;
use Doctrine\Tests\Models\GH10334\GH10334ProductTypeId;
use Doctrine\Tests\OrmFunctionalTestCase;
class GH10334Test extends OrmFunctionalTestCase
{
protected function setUp(): void
{
parent::setUp();
$this->setUpEntitySchema([GH10334FooCollection::class, GH10334Foo::class, GH10334ProductType::class, GH10334Product::class]);
}
public function testTicket(): void
{
$collection = new GH10334FooCollection();
$foo = new GH10334Foo($collection, GH10334ProductTypeId::Jean);
$foo2 = new GH10334Foo($collection, GH10334ProductTypeId::Short);
$this->_em->persist($collection);
$this->_em->persist($foo);
$this->_em->persist($foo2);
$this->_em->flush();
$this->_em->clear();
$result = $this->_em
->getRepository(GH10334FooCollection::class)
->createQueryBuilder('collection')
->leftJoin('collection.foos', 'foo')->addSelect('foo')
->getQuery()
->getResult();
$this->_em
->getRepository(GH10334FooCollection::class)
->createQueryBuilder('collection')
->leftJoin('collection.foos', 'foo')->addSelect('foo')
->getQuery()
->getResult();
$this->assertCount(1, $result);
$this->assertCount(2, $result[0]->getFoos());
}
public function testGetChildWithBackedEnumId(): void
{
$jean = new GH10334ProductType(GH10334ProductTypeId::Jean, 23.5);
$short = new GH10334ProductType(GH10334ProductTypeId::Short, 45.2);
$product = new GH10334Product('Extra Large Blue', $jean);
$jean->addProduct($product);
$this->_em->persist($jean);
$this->_em->persist($short);
$this->_em->persist($product);
$this->_em->flush();
$this->_em->clear();
$entity = $this->_em->find(GH10334Product::class, 1);
self::assertNotNull($entity);
self::assertSame($entity->getProductType()->getId(), GH10334ProductTypeId::Jean);
}
}
|