diff options
author | Mario <mario@mariovavti.com> | 2021-03-08 09:31:23 +0000 |
---|---|---|
committer | Mario <mario@mariovavti.com> | 2021-03-08 09:31:23 +0000 |
commit | 951e9c8c4f39dd8577834d5bc501c05d80722de9 (patch) | |
tree | 6a42c6a229c7b2b3e13bc5af77a733d054242695 /vendor/sabre/dav/tests/Sabre/DAV/TreeTest.php | |
parent | f94b046333c57acde493ee5dc2511acc6baca701 (diff) | |
parent | 89415e17313578eb115c441480b6e0ddfa90afef (diff) | |
download | volse-hubzilla-5.4.tar.gz volse-hubzilla-5.4.tar.bz2 volse-hubzilla-5.4.zip |
Merge branch '5.4RC'5.4
Diffstat (limited to 'vendor/sabre/dav/tests/Sabre/DAV/TreeTest.php')
-rw-r--r-- | vendor/sabre/dav/tests/Sabre/DAV/TreeTest.php | 238 |
1 files changed, 0 insertions, 238 deletions
diff --git a/vendor/sabre/dav/tests/Sabre/DAV/TreeTest.php b/vendor/sabre/dav/tests/Sabre/DAV/TreeTest.php deleted file mode 100644 index e3f04ea3a..000000000 --- a/vendor/sabre/dav/tests/Sabre/DAV/TreeTest.php +++ /dev/null @@ -1,238 +0,0 @@ -<?php - -declare(strict_types=1); - -namespace Sabre\DAV; - -class TreeTest extends \PHPUnit\Framework\TestCase -{ - public function testNodeExists() - { - $tree = new TreeMock(); - - $this->assertTrue($tree->nodeExists('hi')); - $this->assertFalse($tree->nodeExists('hello')); - } - - public function testCopy() - { - $tree = new TreeMock(); - $tree->copy('hi', 'hi2'); - - $this->assertArrayHasKey('hi2', $tree->getNodeForPath('')->newDirectories); - $this->assertEquals('foobar', $tree->getNodeForPath('hi/file')->get()); - $this->assertEquals(['test1' => 'value'], $tree->getNodeForPath('hi/file')->getProperties([])); - } - - public function testCopyFile() - { - $tree = new TreeMock(); - $tree->copy('hi/file', 'hi/newfile'); - - $this->assertArrayHasKey('newfile', $tree->getNodeForPath('hi')->newFiles); - } - - public function testCopyFile0() - { - $tree = new TreeMock(); - $tree->copy('hi/file', 'hi/0'); - - $this->assertArrayHasKey('0', $tree->getNodeForPath('hi')->newFiles); - } - - public function testMove() - { - $tree = new TreeMock(); - $tree->move('hi', 'hi2'); - - $this->assertEquals('hi2', $tree->getNodeForPath('hi')->getName()); - $this->assertTrue($tree->getNodeForPath('hi')->isRenamed); - } - - public function testDeepMove() - { - $tree = new TreeMock(); - $tree->move('hi/sub', 'hi2'); - - $this->assertArrayHasKey('hi2', $tree->getNodeForPath('')->newDirectories); - $this->assertTrue($tree->getNodeForPath('hi/sub')->isDeleted); - } - - public function testDelete() - { - $tree = new TreeMock(); - $tree->delete('hi'); - $this->assertTrue($tree->getNodeForPath('hi')->isDeleted); - } - - public function testGetChildren() - { - $tree = new TreeMock(); - $children = $tree->getChildren(''); - $firstChild = $children->current(); - $this->assertEquals('hi', $firstChild->getName()); - } - - public function testGetMultipleNodes() - { - $tree = new TreeMock(); - $result = $tree->getMultipleNodes(['hi/sub', 'hi/file']); - $this->assertArrayHasKey('hi/sub', $result); - $this->assertArrayHasKey('hi/file', $result); - - $this->assertEquals('sub', $result['hi/sub']->getName()); - $this->assertEquals('file', $result['hi/file']->getName()); - } - - public function testGetMultipleNodes2() - { - $tree = new TreeMock(); - $result = $tree->getMultipleNodes(['multi/1', 'multi/2']); - $this->assertArrayHasKey('multi/1', $result); - $this->assertArrayHasKey('multi/2', $result); - } -} - -class TreeMock extends Tree -{ - private $nodes = []; - - public function __construct() - { - $file = new TreeFileTester('file'); - $file->properties = ['test1' => 'value']; - $file->data = 'foobar'; - - parent::__construct( - new TreeDirectoryTester('root', [ - new TreeDirectoryTester('hi', [ - new TreeDirectoryTester('sub'), - $file, - ]), - new TreeMultiGetTester('multi', [ - new TreeFileTester('1'), - new TreeFileTester('2'), - new TreeFileTester('3'), - ]), - ]) - ); - } -} - -class TreeDirectoryTester extends SimpleCollection -{ - public $newDirectories = []; - public $newFiles = []; - public $isDeleted = false; - public $isRenamed = false; - - public function createDirectory($name) - { - $this->newDirectories[$name] = true; - } - - public function createFile($name, $data = null) - { - $this->newFiles[$name] = $data; - } - - public function getChild($name) - { - if (isset($this->newDirectories[$name])) { - return new self($name); - } - if (isset($this->newFiles[$name])) { - return new TreeFileTester($name, $this->newFiles[$name]); - } - - return parent::getChild($name); - } - - public function childExists($name) - { - return (bool) $this->getChild($name); - } - - public function delete() - { - $this->isDeleted = true; - } - - public function setName($name) - { - $this->isRenamed = true; - $this->name = $name; - } -} - -class TreeFileTester extends File implements IProperties -{ - public $name; - public $data; - public $properties; - - public function __construct($name, $data = null) - { - $this->name = $name; - if (is_null($data)) { - $data = 'bla'; - } - $this->data = $data; - } - - public function getName() - { - return $this->name; - } - - public function get() - { - return $this->data; - } - - public function getProperties($properties) - { - return $this->properties; - } - - /** - * Updates properties on this node. - * - * This method received a PropPatch object, which contains all the - * information about the update. - * - * To update specific properties, call the 'handle' method on this object. - * Read the PropPatch documentation for more information. - */ - public function propPatch(PropPatch $propPatch) - { - $this->properties = $propPatch->getMutations(); - $propPatch->setRemainingResultCode(200); - } -} - -class TreeMultiGetTester extends TreeDirectoryTester implements IMultiGet -{ - /** - * This method receives a list of paths in it's first argument. - * It must return an array with Node objects. - * - * If any children are not found, you do not have to return them. - * - * @return array - */ - public function getMultipleChildren(array $paths) - { - $result = []; - foreach ($paths as $path) { - try { - $child = $this->getChild($path); - $result[] = $child; - } catch (Exception\NotFound $e) { - // Do nothing - } - } - - return $result; - } -} |