Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

[DDC-93] Show CRUD with value objects with current change tracking as…

…sumptions.
  • Loading branch information...
commit 879ab6e52b1d20565074b5abfeb995926505461a 1 parent 011776f
@beberlei beberlei authored
Showing with 24 additions and 1 deletion.
  1. +24 −1 tests/Doctrine/Tests/ORM/Functional/ValueObjectsTest.php
View
25 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));
}
}
Please sign in to comment.
Something went wrong with that request. Please try again.