11 $this->assertTrue(
$tree->nodeExists(
'hi'));
12 $this->assertFalse(
$tree->nodeExists(
'hello'));
19 $tree->copy(
'hi',
'hi2');
21 $this->assertArrayHasKey(
'hi2',
$tree->getNodeForPath(
'')->newDirectories);
22 $this->assertEquals(
'foobar',
$tree->getNodeForPath(
'hi/file')->get());
23 $this->assertEquals([
'test1' =>
'value'],
$tree->getNodeForPath(
'hi/file')->getProperties([]));
30 $tree->move(
'hi',
'hi2');
32 $this->assertEquals(
'hi2',
$tree->getNodeForPath(
'hi')->getName());
33 $this->assertTrue(
$tree->getNodeForPath(
'hi')->isRenamed);
40 $tree->move(
'hi/sub',
'hi2');
42 $this->assertArrayHasKey(
'hi2',
$tree->getNodeForPath(
'')->newDirectories);
43 $this->assertTrue(
$tree->getNodeForPath(
'hi/sub')->isDeleted);
51 $this->assertTrue(
$tree->getNodeForPath(
'hi')->isDeleted);
58 $children =
$tree->getChildren(
'');
59 $this->assertEquals(2, count($children));
60 $this->assertEquals(
'hi', $children[0]->getName());
67 $result =
$tree->getMultipleNodes([
'hi/sub',
'hi/file']);
68 $this->assertArrayHasKey(
'hi/sub',
$result);
69 $this->assertArrayHasKey(
'hi/file',
$result);
71 $this->assertEquals(
'sub',
$result[
'hi/sub']->getName());
72 $this->assertEquals(
'file',
$result[
'hi/file']->getName());
78 $result =
$tree->getMultipleNodes([
'multi/1',
'multi/2']);
79 $this->assertArrayHasKey(
'multi/1',
$result);
80 $this->assertArrayHasKey(
'multi/2',
$result);
93 $file->properties = [
'test1' =>
'value'];
94 $file->data =
'foobar';
116 public $newDirectories = [];
117 public $newFiles = [];
118 public $isDeleted =
false;
119 public $isRenamed =
false;
123 $this->newDirectories[
$name] =
true;
135 if (isset($this->newDirectories[
$name]))
return new self(
$name);
136 if (isset($this->newFiles[$name]))
return new TreeFileTester($name, $this->newFiles[$name]);
137 return parent::getChild($name);
143 return !!$this->getChild(
$name);
149 $this->isDeleted =
true;
155 $this->isRenamed =
true;
190 return $this->properties;
229 foreach ($paths as
$path) {
231 $child = $this->getChild($path);
This class represents a set of properties that are going to be updated.
getChild($name)
Returns a specific child node, referenced by its name.
createFile($name, $data=null)
Creates a new file in the directory.
getProperties($properties)
Returns a list of properties for this nodes.
setRemainingResultCode($resultCode)
Sets the result code for all properties that did not have a result yet.
createDirectory($name)
Creates a new subdirectory.
__construct($name, $data=null)
childExists($name)
Checks if a child-node with the specified name exists.
setName($name)
Renames the node.
getMutations()
Returns the full list of mutations.
getName()
Returns the name of the node.
propPatch(PropPatch $propPatch)
Updates properties on this node.
getMultipleChildren(array $paths)
This method receives a list of paths in it's first argument.
The tree object is responsible for basic tree operations.