1
0
mirror of synced 2025-02-09 00:39:25 +03:00

#6613 #6614 removing phone/user specifics, using ORM naming for associations

This commit is contained in:
Marco Pivetta 2017-08-11 14:44:04 +02:00
parent b9ba4e3207
commit 5a0d3e5fb8
No known key found for this signature in database
GPG Key ID: 4167D3337FD9D629

View File

@ -23,41 +23,41 @@ class DDC6613Test extends OrmFunctionalTestCase
parent::setUp(); parent::setUp();
$this->setUpEntitySchema([ $this->setUpEntitySchema([
DDC6613Phone::class, DDC6613InverseSide::class,
DDC6613User::class, DDC6613OwningSide::class,
]); ]);
} }
public function testFail() public function testFail()
{ {
$newUser = new DDC6613User(); $owningSide = new DDC6613OwningSide();
$this->_em->persist($newUser); $this->_em->persist($owningSide);
$this->_em->flush(); $this->_em->flush();
$this->_em->clear(); $this->_em->clear();
$phone1 = new DDC6613Phone(); $item1 = new DDC6613InverseSide();
$phone2 = new DDC6613Phone(); $item2 = new DDC6613InverseSide();
$this->_em->persist($phone1); $this->_em->persist($item1);
$this->_em->persist($phone2); $this->_em->persist($item2);
$this->_em->flush(); $this->_em->flush();
/* @var DDC6613User $user */ /* @var DDC6613OwningSide $foundOwningSide */
$user = $this->_em->find(DDC6613User::class, $newUser->id); $foundOwningSide = $this->_em->find(DDC6613OwningSide::class, $owningSide->id);
self::assertInstanceOf(DDC6613User::class, $user); self::assertInstanceOf(DDC6613OwningSide::class, $foundOwningSide);
/* @var $phones PersistentCollection */ /* @var $phones PersistentCollection */
$phones = $user->phones; $phones = $foundOwningSide->phones;
self::assertInstanceOf(PersistentCollection::class, $phones); self::assertInstanceOf(PersistentCollection::class, $phones);
self::assertFalse($phones->isInitialized()); self::assertFalse($phones->isInitialized());
$phones->add($phone1); $phones->add($item1);
$this->_em->flush(); $this->_em->flush();
$phones->add($phone2); $phones->add($item2);
$phones->initialize(); $phones->initialize();
@ -68,17 +68,17 @@ class DDC6613Test extends OrmFunctionalTestCase
self::assertFalse($phones->isDirty()); self::assertFalse($phones->isDirty());
self::assertTrue($phones->isInitialized()); self::assertTrue($phones->isInitialized());
self::assertCount(2, $user->phones); self::assertCount(2, $foundOwningSide->phones);
} }
} }
/** @Entity */ /** @Entity */
class DDC6613User class DDC6613OwningSide
{ {
/** @Id @Column(type="string") */ /** @Id @Column(type="string") */
public $id; public $id;
/** @ManyToMany(targetEntity=DDC6613Phone::class) */ /** @ManyToMany(targetEntity=DDC6613InverseSide::class) */
public $phones; public $phones;
public function __construct() public function __construct()
@ -89,7 +89,7 @@ class DDC6613User
} }
/** @Entity */ /** @Entity */
class DDC6613Phone class DDC6613InverseSide
{ {
/** @Id @Column(type="string") */ /** @Id @Column(type="string") */
private $id; private $id;