<?php

include 'configuration.php';
include 'objects/class.database.php';
include 'objects/class.object.php';
include 'objects/class.sibling.php';
include 'objects/class.parent_.php';
include 'objects/class.child.php';
$object = new object();
$object->attribute = 'obj att';
$sibling = new sibling('sibling att');
$sibling2 = new sibling('sibling att2');
$child = new child('child att');
$parent = new parent_('parent att');
$parent->Save();
$object->AddChild($child);
$object->AddSibling($sibling);
$object->AddSibling($sibling2);
$object->SetParent_($parent);
$object->Save();
$child->attribute = 'changed att';
$object->Save();
echo "<br/>changing child after it has been assigned a parent";
echo "<pre>";
print_r($object);
echo "</pre>";
echo "saving parent, object, child, sibling<br/>";
echo "<pre>";
print_r($object);
echo "</pre>";
//test to avoid circular dependency
 /**
  * Should delete parent and children/sibling recursivelu
  *
  */
 function testDelete_Deep()
 {
     $this->object->AddChild($this->child);
     $this->object->AddSibling($this->sibling);
     $this->parent_->AddObject($this->object);
     $this->parent_->Save();
     $this->parent_->Delete(true);
     $someParent = new parent_();
     $parentList = $someParent->GetList(array(array("parent_Id", ">", 0)));
     $this->assertEquals(0, sizeof($parentList));
     $someObject = new object();
     $objectList = $someObject->GetList(array(array("objectId", ">", 0)));
     $this->assertEquals(0, sizeof($objectList));
     $someChild = new child();
     $childList = $someChild->GetList(array(array("childId", ">", 0)));
     $this->assertEquals(0, sizeof($childList));
     $someSibling = new sibling();
     $siblingList = $someSibling->GetList(array(array("siblingId", ">", 0)));
     $this->assertEquals(0, sizeof($siblingList));
 }
 /**
  * Associates the parent_ object to this one
  * @return boolean
  */
 function GetParent_()
 {
     $parent_ = new parent_();
     return $parent_->Get($this->parent_Id);
 }