Skip to content

Commit

Permalink
Add test coverage for Sabre\DAV\FSExt\File\patch
Browse files Browse the repository at this point in the history
  • Loading branch information
phil-davis committed Feb 11, 2021
1 parent 9232fc1 commit fe56232
Showing 1 changed file with 28 additions and 1 deletion.
29 changes: 28 additions & 1 deletion tests/Sabre/DAV/FSExt/FileTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,16 @@ public function testPut()
);
}

public function testRange()
public function testRangeAppend()
{
$file = new File(SABRE_TEMPDIR.'/file.txt');
$file->put('0000000');
$file->patch('111', 1);

$this->assertEquals('0000000111', file_get_contents(SABRE_TEMPDIR.'/file.txt'));
}

public function testRangeOffset()
{
$file = new File(SABRE_TEMPDIR.'/file.txt');
$file->put('0000000');
Expand All @@ -43,6 +52,24 @@ public function testRange()
$this->assertEquals('0001110', file_get_contents(SABRE_TEMPDIR.'/file.txt'));
}

public function testRangeOffsetEnd()
{
$file = new File(SABRE_TEMPDIR.'/file.txt');
$file->put('0000000');
$file->patch('11', 3, -4);

$this->assertEquals('0001100', file_get_contents(SABRE_TEMPDIR.'/file.txt'));
}

public function testRangeOffsetDefault()
{
$file = new File(SABRE_TEMPDIR.'/file.txt');
$file->put('0000000');
$file->patch('11', 0);

$this->assertEquals('000000011', file_get_contents(SABRE_TEMPDIR.'/file.txt'));
}

public function testRangeStream()
{
$stream = fopen('php://memory', 'r+');
Expand Down

0 comments on commit fe56232

Please sign in to comment.