public function serializeNodeToJson(JsonSerializationVisitor $visitor, NodeManager $node, array $type, NodeContext $context)
 {
     $serialized = [];
     $repository = $context->getRepository();
     $workspaceName = $context->getWorkspaceName();
     $serialized['name'] = $node->getName();
     $serialized['path'] = $node->getPath();
     $serialized['workspace'] = $workspaceName;
     $serialized['children'] = [];
     foreach ($node->getChildren() as $childNode) {
         $serialized['children'][] = ['name' => $childNode->getName(), 'path' => $childNode->getPath(), 'children' => [], 'hasChildren' => $childNode->hasChildren()];
     }
     $serialized['hasChildren'] = $node->hasChildren();
     if ($node->getPath() != $repository->getRootNode()->getPath()) {
         $serialized['parent'] = $node->getParent()->getName();
     }
     if ($context->isReducedTreeEnabled()) {
         $serialized['reducedTree'] = $node->getReducedTree();
     }
     $serialized['properties'] = $node->getPropertiesAsArray();
     foreach ($serialized['properties'] as $name => $property) {
         if ($property['type'] === PropertyType::WEAKREFERENCE) {
             if (is_array($property['value'])) {
                 foreach ($property['value'] as $subkey => $subvalue) {
                     $serialized['properties'][$name]['value'][$subkey] = $repository->getNodeByIdentifier($subkey)->getPath();
                 }
             } else {
                 $serialized['properties'][$name]['value'] = $repository->getNodeByIdentifier($property['value'])->getPath();
             }
         }
     }
     return $serialized;
 }
 public function testItShouldCallAddNodeAndFinallySave()
 {
     $node = $this->mock('\\PHPCRAPI\\PHPCR\\Node')->addNode($this->once())->new($this->nodeInterface);
     $sessionManager = $this->mock('\\PHPCRAPI\\API\\Manager\\SessionManager')->save($this->once())->new();
     $manager = new NodeManager($node, $sessionManager);
     $manager->addNode('/test');
 }