#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;
|
namespace Doctrine\Tests\ORM\Functional\Ticket;
|
||||||
|
|
||||||
use Doctrine\Common\Collections\ArrayCollection;
|
use Doctrine\Common\Collections\ArrayCollection;
|
||||||
use Doctrine\DBAL\Schema\SchemaException;
|
|
||||||
use Doctrine\ORM\PersistentCollection;
|
use Doctrine\ORM\PersistentCollection;
|
||||||
use Doctrine\Tests\OrmFunctionalTestCase;
|
use Doctrine\Tests\OrmFunctionalTestCase;
|
||||||
|
|
||||||
@ -23,46 +22,43 @@ class DDC6613Test extends OrmFunctionalTestCase
|
|||||||
{
|
{
|
||||||
parent::setUp();
|
parent::setUp();
|
||||||
|
|
||||||
try {
|
$this->setUpEntitySchema([
|
||||||
$this->setUpEntitySchema(
|
DDC6613Phone::class,
|
||||||
[
|
DDC6613User::class,
|
||||||
DDC6613Phone::class,
|
]);
|
||||||
DDC6613User::class,
|
|
||||||
]
|
|
||||||
);
|
|
||||||
} catch (SchemaException $e) {
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testFail()
|
public function testFail()
|
||||||
{
|
{
|
||||||
$newUser = new DDC6613User();
|
$newUser = new DDC6613User();
|
||||||
|
|
||||||
$this->_em->persist($newUser);
|
$this->_em->persist($newUser);
|
||||||
$this->_em->flush();
|
$this->_em->flush();
|
||||||
|
|
||||||
$this->_em->clear();
|
$this->_em->clear();
|
||||||
|
|
||||||
/** @var DDC6613User $user */
|
$phone1 = new DDC6613Phone();
|
||||||
$user = $this->_em->find(DDC6613User::class, $newUser->id);
|
$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);
|
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 */
|
/* @var $phones PersistentCollection */
|
||||||
// $phones = $user->phones;
|
$phones = $user->phones;
|
||||||
|
|
||||||
self::assertInstanceOf(PersistentCollection::class, $phones);
|
self::assertInstanceOf(PersistentCollection::class, $phones);
|
||||||
self::assertFalse($phones->isInitialized());
|
self::assertFalse($phones->isInitialized());
|
||||||
|
|
||||||
|
$phones->add($phone1);
|
||||||
|
$this->_em->flush();
|
||||||
|
|
||||||
|
$phones->add($phone2);
|
||||||
|
|
||||||
$phones->initialize();
|
$phones->initialize();
|
||||||
|
|
||||||
self::assertTrue($phones->isInitialized());
|
self::assertTrue($phones->isInitialized());
|
||||||
@ -95,7 +91,7 @@ class DDC6613User
|
|||||||
/** @Entity */
|
/** @Entity */
|
||||||
class DDC6613Phone
|
class DDC6613Phone
|
||||||
{
|
{
|
||||||
/** @Id @Column(type="integer") */
|
/** @Id @Column(type="string") */
|
||||||
private $id;
|
private $id;
|
||||||
|
|
||||||
public function __construct()
|
public function __construct()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user