function testPerformFailedEntityHasChildren()
 {
     $entity = new ServiceNode();
     $entity->set('oid', $id = 1001);
     $node =& $entity->getNodePart();
     $node->set('id', $node_id = 10);
     $this->tree->expectOnce('countChildren', array($node_id));
     $this->tree->setReturnValue('countChildren', 1);
     $command = new ServiceNodeDeleteCommand($entity);
     $this->assertEqual($command->perform(), LIMB_STATUS_ERROR);
     $uow =& $this->toolkit->getUOW();
     $this->assertFalse($uow->isDeleted($entity));
 }
 function _registerRootObject()
 {
     $toolkit =& Limb::toolkit();
     $uow =& $toolkit->getUOW();
     $uow->start();
     $entity = new ServiceNode();
     $node =& $entity->getNodePart();
     $node->set('identifier', 'services');
     $service =& $entity->getServicePart();
     $service->set('title', 'Services page');
     $service->set('name', 'ServiceNode');
     $uow->register($entity);
     $uow->commit();
     return $entity;
 }
 function testPerformOk()
 {
     $service_node = new ServiceNode();
     $node =& $service_node->getNodePart();
     $service =& $service_node->getServicePart();
     $node->set('id', $node_id = 50);
     $node->set('parent_id', $parent_id = 100);
     $node->set('identifier', $identifier = 'test identifier');
     $service->set('name', $service_name = 'test service');
     $service->set('title', $title = 'test title');
     $command = new MapServiceNodeToDataspaceCommand($service_node);
     $this->assertEqual($command->perform(), LIMB_STATUS_OK);
     $toolkit =& Limb::toolkit();
     $dataspace =& $toolkit->getDataspace();
     $this->assertEqual($dataspace->get('title'), $title);
     $this->assertEqual($dataspace->get('node_id'), $node_id);
     $this->assertEqual($dataspace->get('parent_node_id'), $parent_id);
     $this->assertEqual($dataspace->get('identifier'), $identifier);
     $this->assertEqual($dataspace->get('service_name'), $service_name);
 }
 function testPerformOkAndSwitchPath()
 {
     $toolkit =& Limb::toolkit();
     $dataspace =& $toolkit->getDataspace();
     $dataspace->set('path', $path = 'Some path');
     // will change parent_node_id
     $dataspace->set('parent_node_id', 100);
     // will be changed
     $dataspace->set('service_name', $service_name = 'some service name');
     $dataspace->set('title', $title = 'some title');
     $dataspace->set('identifier', $identifier = 'some identifier');
     $this->tree->expectOnce('getNodeByPath', array($path));
     $this->tree->setReturnValue('getNodeByPath', $node = array('id' => $new_parent_node_id = 101));
     $service_node = new ServiceNode();
     $command = new MapDataspaceToServiceNodeCommand($service_node);
     $this->assertEqual($command->perform(), LIMB_STATUS_OK);
     $node =& $service_node->getNodePart();
     $this->assertEqual($node->get('parent_id'), $new_parent_node_id);
     $this->assertEqual($node->get('identifier'), $identifier);
     $service =& $service_node->getServicePart();
     $this->assertEqual($service->get('name'), $service_name);
     $this->assertEqual($service->get('title'), $title);
 }
 function ContentServiceNode()
 {
     parent::ServiceNode();
     $this->registerPart('content', new Object());
 }