From 879ab6e52b1d20565074b5abfeb995926505461a Mon Sep 17 00:00:00 2001 From: Benjamin Eberlei Date: Wed, 27 Mar 2013 07:44:47 +0100 Subject: [PATCH] [DDC-93] Show CRUD with value objects with current change tracking assumptions. --- .../Tests/ORM/Functional/ValueObjectsTest.php | 25 ++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/tests/Doctrine/Tests/ORM/Functional/ValueObjectsTest.php b/tests/Doctrine/Tests/ORM/Functional/ValueObjectsTest.php index 26f129c7158..d1f81189c0f 100644 --- a/tests/Doctrine/Tests/ORM/Functional/ValueObjectsTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/ValueObjectsTest.php @@ -17,7 +17,7 @@ public function setUp() )); } - public function testMetadata() + public function testCRUD() { $person = new DDC93Person(); $person->name = "Tara"; @@ -26,17 +26,40 @@ public function testMetadata() $person->address->zip = "12345"; $person->address->city = "funkytown"; + // 1. check saving value objects works $this->_em->persist($person); $this->_em->flush(); $this->_em->clear(); + // 2. check loading value objects works $person = $this->_em->find(DDC93Person::CLASSNAME, $person->id); $this->assertInstanceOf(DDC93Address::CLASSNAME, $person->address); $this->assertEquals('United States of Tara Street', $person->address->street); $this->assertEquals('12345', $person->address->zip); $this->assertEquals('funkytown', $person->address->city); + + // 3. check changing value objects works + $person->address->street = "Street"; + $person->address->zip = "54321"; + $person->address->city = "another town"; + $this->_em->flush(); + + $this->_em->clear(); + + $person = $this->_em->find(DDC93Person::CLASSNAME, $person->id); + + $this->assertEquals('Street', $person->address->street); + $this->assertEquals('54321', $person->address->zip); + $this->assertEquals('another town', $person->address->city); + + // 4. check deleting works + $personId = $person->id;; + $this->_em->remove($person); + $this->_em->flush(); + + $this->assertNull($this->_em->find(DDC93Person::CLASSNAME, $personId)); } }