Skip to content

Commit

Permalink
Add tests for afterBind afterCreateFile afterCreateCollection
Browse files Browse the repository at this point in the history
  • Loading branch information
phil-davis committed Nov 16, 2021
1 parent 1e9fdea commit 759efe8
Showing 1 changed file with 33 additions and 3 deletions.
36 changes: 33 additions & 3 deletions tests/Sabre/DAV/ServerEventsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,17 +12,47 @@ 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 = '';
$this->server->createFile($newPath, 'body');
$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;
}
Expand Down

0 comments on commit 759efe8

Please sign in to comment.