Skip to content

Commit

Permalink
add test that cached parent nodes are used in Tree::getNodeForPath
Browse files Browse the repository at this point in the history
  • Loading branch information
icewind1991 committed Feb 21, 2024
1 parent 0bf4dc6 commit 1434739
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions tests/Sabre/DAV/TreeTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,23 @@ public function testGetSubTreeNode()
$this->assertInstanceOf(INode::class, $tree->getNodeForPath('subtree/sub/1'));
$this->assertInstanceOf(INode::class, $tree->getNodeForPath('subtree/2/3'));
}

public function testGetNodeCacheParent()
{
$tree = new TreeMock();

/** @var TreeDirectoryTester $root */
$root = $tree->getNodeForPath('');
$root->createDirectory('new');
$parent = $tree->getNodeForPath('new');
$parent->createDirectory('child');

// make it so we can't create the 'new' folder again
unset($root->newDirectories['new']);

// we should still be able to query child items from the 'new' folder because it is cached in the tree
$this->assertInstanceOf(INode::class, $tree->getNodeForPath('new/child'));
}
}

class TreeMock extends Tree
Expand Down

0 comments on commit 1434739

Please sign in to comment.