3 namespace Doctrine\Tests\ORM\Functional\Ticket;
5 use Doctrine\Common\Collections\ArrayCollection;
6 use Doctrine\Tests\Models\CMS\CmsEmployee;
8 require_once __DIR__ . '/../../../TestInit.php';
14 class DDC1228Test extends \Doctrine\Tests\OrmFunctionalTestCase
16 public function setUp()
20 $this->_schemaTool->createSchema(array(
21 $this->_em->getClassMetadata(__NAMESPACE__ . '\\DDC1228User'),
22 $this->_em->getClassMetadata(__NAMESPACE__ . '\\DDC1228Profile'),
24 } catch(\Exception $e) {
29 public function testOneToOnePersist()
31 $user = new DDC1228User;
32 $profile = new DDC1228Profile();
33 $profile->name = "Foo";
34 $user->profile = $profile;
36 $this->_em->persist($user);
37 $this->_em->persist($profile);
41 $user = $this->_em->find(__NAMESPACE__ . '\\DDC1228User', $user->id);
43 $this->assertFalse($user->getProfile()->__isInitialized__, "Proxy is not initialized");
44 $user->getProfile()->setName("Bar");
45 $this->assertTrue($user->getProfile()->__isInitialized__, "Proxy is not initialized");
47 $this->assertEquals("Bar", $user->getProfile()->getName());
48 $this->assertEquals(array("id" => 1, "name" => "Foo"), $this->_em->getUnitOfWork()->getOriginalEntityData($user->getProfile()));
53 $user = $this->_em->find(__NAMESPACE__ . '\\DDC1228User', $user->id);
54 $this->assertEquals("Bar", $user->getProfile()->getName());
57 public function testRefresh()
59 $user = new DDC1228User;
60 $profile = new DDC1228Profile();
61 $profile->name = "Foo";
62 $user->profile = $profile;
64 $this->_em->persist($user);
65 $this->_em->persist($profile);
69 $user = $this->_em->getReference(__NAMESPACE__ . '\\DDC1228User', $user->id);
71 $this->_em->refresh($user);
76 $user = $this->_em->find(__NAMESPACE__ . '\\DDC1228User', $user->id);
77 $this->assertEquals("Baz", $user->name);
87 * @Id @Column(type="integer") @GeneratedValue
93 * @Column(type="string")
99 * @OneToOne(targetEntity="DDC1228Profile")
104 public function getProfile()
106 return $this->profile;
116 * @Id @Column(type="integer") @GeneratedValue
122 * @column(type="string")
127 public function getName()
132 public function setName($name)