#6613 #6614 correcting column mapping (was integer
, should be string
), segregating phone creation away
This commit is contained in:
parent
d7919678e5
commit
b9ba4e3207
@ -9,7 +9,6 @@
|
||||
namespace Doctrine\Tests\ORM\Functional\Ticket;
|
||||
|
||||
use Doctrine\Common\Collections\ArrayCollection;
|
||||
use Doctrine\DBAL\Schema\SchemaException;
|
||||
use Doctrine\ORM\PersistentCollection;
|
||||
use Doctrine\Tests\OrmFunctionalTestCase;
|
||||
|
||||
@ -23,46 +22,43 @@ class DDC6613Test extends OrmFunctionalTestCase
|
||||
{
|
||||
parent::setUp();
|
||||
|
||||
try {
|
||||
$this->setUpEntitySchema(
|
||||
[
|
||||
DDC6613Phone::class,
|
||||
DDC6613User::class,
|
||||
]
|
||||
);
|
||||
} catch (SchemaException $e) {
|
||||
}
|
||||
$this->setUpEntitySchema([
|
||||
DDC6613Phone::class,
|
||||
DDC6613User::class,
|
||||
]);
|
||||
}
|
||||
|
||||
public function testFail()
|
||||
{
|
||||
$newUser = new DDC6613User();
|
||||
|
||||
$this->_em->persist($newUser);
|
||||
$this->_em->flush();
|
||||
|
||||
$this->_em->clear();
|
||||
|
||||
/** @var DDC6613User $user */
|
||||
$user = $this->_em->find(DDC6613User::class, $newUser->id);
|
||||
$phone1 = new DDC6613Phone();
|
||||
$phone2 = new DDC6613Phone();
|
||||
|
||||
$this->_em->persist($phone1);
|
||||
$this->_em->persist($phone2);
|
||||
$this->_em->flush();
|
||||
|
||||
/* @var DDC6613User $user */
|
||||
$user = $this->_em->find(DDC6613User::class, $newUser->id);
|
||||
|
||||
self::assertInstanceOf(DDC6613User::class, $user);
|
||||
|
||||
$phone1 = new DDC6613Phone();
|
||||
$phones = $user->phones;
|
||||
$user->phones->add($phone1);
|
||||
$this->_em->persist($phone1);
|
||||
$this->_em->flush();
|
||||
|
||||
$phone2 = new DDC6613Phone();
|
||||
$user->phones->add($phone2);
|
||||
$this->_em->persist($phone2);
|
||||
|
||||
/* @var $phones PersistentCollection */
|
||||
// $phones = $user->phones;
|
||||
$phones = $user->phones;
|
||||
|
||||
self::assertInstanceOf(PersistentCollection::class, $phones);
|
||||
self::assertFalse($phones->isInitialized());
|
||||
|
||||
$phones->add($phone1);
|
||||
$this->_em->flush();
|
||||
|
||||
$phones->add($phone2);
|
||||
|
||||
$phones->initialize();
|
||||
|
||||
self::assertTrue($phones->isInitialized());
|
||||
@ -95,7 +91,7 @@ class DDC6613User
|
||||
/** @Entity */
|
||||
class DDC6613Phone
|
||||
{
|
||||
/** @Id @Column(type="integer") */
|
||||
/** @Id @Column(type="string") */
|
||||
private $id;
|
||||
|
||||
public function __construct()
|
||||
|
Loading…
x
Reference in New Issue
Block a user