From 1e9fdeaf142374bf0f11b64fb3997c7ab89ff4e1 Mon Sep 17 00:00:00 2001 From: Wouter Samaey Date: Thu, 29 Apr 2021 16:14:42 +0200 Subject: [PATCH 1/2] New event "afterCreateCollection" like "afterCreateFile" --- lib/DAV/Server.php | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/DAV/Server.php b/lib/DAV/Server.php index 11e3608b4f..1f8300d4a5 100644 --- a/lib/DAV/Server.php +++ b/lib/DAV/Server.php @@ -1237,6 +1237,7 @@ public function createCollection($uri, MkCol $mkCol) $this->tree->markDirty($parentUri); $this->emit('afterBind', [$uri]); + $this->emit('afterCreateCollection', [$uri]); } /** From 759efe8d346ff8be9eb9b294f726a28be35996d1 Mon Sep 17 00:00:00 2001 From: Phil Davis Date: Tue, 16 Nov 2021 12:43:41 +0545 Subject: [PATCH 2/2] Add tests for afterBind afterCreateFile afterCreateCollection --- tests/Sabre/DAV/ServerEventsTest.php | 36 +++++++++++++++++++++++++--- 1 file changed, 33 insertions(+), 3 deletions(-) diff --git a/tests/Sabre/DAV/ServerEventsTest.php b/tests/Sabre/DAV/ServerEventsTest.php index b1f6754ea9..e9490d4f97 100644 --- a/tests/Sabre/DAV/ServerEventsTest.php +++ b/tests/Sabre/DAV/ServerEventsTest.php @@ -12,9 +12,9 @@ class ServerEventsTest extends AbstractServer private $exception; - public function testAfterBind() + public function testAfterBindOfFile() { - $this->server->on('afterBind', [$this, 'afterBindHandler']); + $this->server->on('afterBind', [$this, 'afterHandler']); $newPath = 'afterBind'; $this->tempPath = ''; @@ -22,7 +22,37 @@ public function testAfterBind() $this->assertEquals($newPath, $this->tempPath); } - public function afterBindHandler($path) + public function testAfterBindOfCollection() + { + $this->server->on('afterBind', [$this, 'afterHandler']); + $newPath = 'afterBind'; + + $this->tempPath = ''; + $this->server->createDirectory($newPath); + $this->assertEquals($newPath, $this->tempPath); + } + + public function testAfterCreateFile() + { + $this->server->on('afterCreateFile', [$this, 'afterHandler']); + $newPath = 'afterCreateFile'; + + $this->tempPath = ''; + $this->server->createFile($newPath, 'body'); + $this->assertEquals($newPath, $this->tempPath); + } + + public function testAfterCreateCollection() + { + $this->server->on('afterCreateCollection', [$this, 'afterHandler']); + $newPath = 'afterCreateCollection'; + + $this->tempPath = ''; + $this->server->createDirectory($newPath); + $this->assertEquals($newPath, $this->tempPath); + } + + public function afterHandler($path) { $this->tempPath = $path; }