From 580c3f4ffe9608d2beb56d418c68b3b112420e76 Mon Sep 17 00:00:00 2001 From: Mario Date: Sun, 10 Nov 2019 12:49:51 +0000 Subject: another bulk of composer updates (cherry picked from commit 6685381fd8db507493c3d7c1793f8c05c681bbce) --- vendor/sabre/dav/tests/Sabre/DAV/TreeTest.php | 162 ++++++++++++-------------- 1 file changed, 73 insertions(+), 89 deletions(-) (limited to 'vendor/sabre/dav/tests/Sabre/DAV/TreeTest.php') diff --git a/vendor/sabre/dav/tests/Sabre/DAV/TreeTest.php b/vendor/sabre/dav/tests/Sabre/DAV/TreeTest.php index c70d17a22..51ff5ccde 100644 --- a/vendor/sabre/dav/tests/Sabre/DAV/TreeTest.php +++ b/vendor/sabre/dav/tests/Sabre/DAV/TreeTest.php @@ -1,110 +1,104 @@ assertTrue($tree->nodeExists('hi')); $this->assertFalse($tree->nodeExists('hello')); - } - function testCopy() { - + 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([])); - } - function testCopyFile() { - + public function testCopyFile() + { $tree = new TreeMock(); $tree->copy('hi/file', 'hi/newfile'); $this->assertArrayHasKey('newfile', $tree->getNodeForPath('hi')->newFiles); } - function testCopyFile0() { - + public function testCopyFile0() + { $tree = new TreeMock(); $tree->copy('hi/file', 'hi/0'); $this->assertArrayHasKey('0', $tree->getNodeForPath('hi')->newFiles); } - function testMove() { - + public function testMove() + { $tree = new TreeMock(); $tree->move('hi', 'hi2'); $this->assertEquals('hi2', $tree->getNodeForPath('hi')->getName()); $this->assertTrue($tree->getNodeForPath('hi')->isRenamed); - } - function testDeepMove() { - + public function testDeepMove() + { $tree = new TreeMock(); $tree->move('hi/sub', 'hi2'); $this->assertArrayHasKey('hi2', $tree->getNodeForPath('')->newDirectories); $this->assertTrue($tree->getNodeForPath('hi/sub')->isDeleted); - } - function testDelete() { - + public function testDelete() + { $tree = new TreeMock(); $tree->delete('hi'); $this->assertTrue($tree->getNodeForPath('hi')->isDeleted); - } - function testGetChildren() { - + public function testGetChildren() + { $tree = new TreeMock(); $children = $tree->getChildren(''); - $this->assertEquals(2, count($children)); - $this->assertEquals('hi', $children[0]->getName()); - + $firstChild = $children->current(); + $this->assertEquals('hi', $firstChild->getName()); } - function testGetMultipleNodes() { - + 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('sub', $result['hi/sub']->getName()); $this->assertEquals('file', $result['hi/file']->getName()); - } - function testGetMultipleNodes2() { + 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 { - +class TreeMock extends Tree +{ private $nodes = []; - function __construct() { - + public function __construct() + { $file = new TreeFileTester('file'); $file->properties = ['test1' => 'value']; $file->data = 'foobar'; @@ -119,92 +113,86 @@ class TreeMock extends Tree { new TreeFileTester('1'), new TreeFileTester('2'), new TreeFileTester('3'), - ]) + ]), ]) ); - } - } -class TreeDirectoryTester extends SimpleCollection { - +class TreeDirectoryTester extends SimpleCollection +{ public $newDirectories = []; public $newFiles = []; public $isDeleted = false; public $isRenamed = false; - function createDirectory($name) { - + public function createDirectory($name) + { $this->newDirectories[$name] = true; - } - function createFile($name, $data = null) { - + public function createFile($name, $data = null) + { $this->newFiles[$name] = $data; - } - function getChild($name) { + 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]); + } - 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); - } - function childExists($name) { - - return !!$this->getChild($name); - + public function childExists($name) + { + return (bool) $this->getChild($name); } - function delete() { - + public function delete() + { $this->isDeleted = true; - } - function setName($name) { - + public function setName($name) + { $this->isRenamed = true; $this->name = $name; - } - } -class TreeFileTester extends File implements IProperties { - +class TreeFileTester extends File implements IProperties +{ public $name; public $data; public $properties; - function __construct($name, $data = null) { - + public function __construct($name, $data = null) + { $this->name = $name; - if (is_null($data)) $data = 'bla'; + if (is_null($data)) { + $data = 'bla'; + } $this->data = $data; - } - function getName() { - + public function getName() + { return $this->name; - } - function get() { - + public function get() + { return $this->data; - } - function getProperties($properties) { - + public function getProperties($properties) + { return $this->properties; - } /** @@ -217,19 +205,16 @@ class TreeFileTester extends File implements IProperties { * Read the PropPatch documentation for more information. * * @param PropPatch $propPatch - * @return void */ - function propPatch(PropPatch $propPatch) { - + public function propPatch(PropPatch $propPatch) + { $this->properties = $propPatch->getMutations(); $propPatch->setRemainingResultCode(200); - } - } -class TreeMultiGetTester extends TreeDirectoryTester implements IMultiGet { - +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. @@ -237,10 +222,11 @@ class TreeMultiGetTester extends TreeDirectoryTester implements IMultiGet { * If any children are not found, you do not have to return them. * * @param array $paths + * * @return array */ - function getMultipleChildren(array $paths) { - + public function getMultipleChildren(array $paths) + { $result = []; foreach ($paths as $path) { try { @@ -252,7 +238,5 @@ class TreeMultiGetTester extends TreeDirectoryTester implements IMultiGet { } return $result; - } - } -- cgit v1.2.3