public function testDeleteOneInMany()
{
$refManyTestObj = new RefManyTestObj();
$refManyTestObj->id = "/functional/refManyTestObj";
$max = 5;
for ($i = 0; $i < $max; $i++) {
$newRefRefTestObj = new RefRefTestObj();
$newRefRefTestObj->id = "/functional/refRefTestObj{$i}";
$newRefRefTestObj->name = "refRefTestObj{$i}";
$refManyTestObj->references[] = $newRefRefTestObj;
}
$this->dm->persist($refManyTestObj);
$this->dm->flush();
$this->dm->clear();
$referrer = $this->dm->find($this->referrerManyType, '/functional/refManyTestObj');
$pos = 2;
$this->dm->remove($referrer->references[$pos]);
$referrer->references[$pos] = null;
$this->dm->persist($referrer);
$this->dm->flush();
$this->dm->clear();
$names = array();
for ($i = 0; $i < $max; $i++) {
if ($i != $pos) {
$names[] = "refRefTestObj{$i}";
}
}
$this->assertCount($max - 1, $names);
$i = 0;
foreach ($this->session->getNode('/functional')->getNode('refManyTestObj')->getProperty('myReferences')->getNode() as $node) {
if ($i != $pos) {
$this->assertTrue(in_array($node->getProperty('name')->getValue(), $names));
}
$i++;
}
$this->assertEquals($max - 1, $i);
}