Skip to content
Next Next commit
feat(tests): Test that mtime is the same after move or rename
Signed-off-by: Côme Chilliet <[email protected]>
  • Loading branch information
come-nc committed Feb 20, 2024
commit 531ec42b64a64ca309e5b40af004298a2a944ea6
10 changes: 10 additions & 0 deletions tests/lib/Files/Storage/Storage.php
Original file line number Diff line number Diff line change
Expand Up @@ -243,12 +243,14 @@ public function testCopy($source, $target) {
public function testMove($source, $target) {
$this->initSourceAndTarget($source);

$mTime = $this->instance->filemtime($source);
$this->instance->rename($source, $target);

$this->wait();
$this->assertTrue($this->instance->file_exists($target), $target . ' was not created');
$this->assertFalse($this->instance->file_exists($source), $source . ' still exists');
$this->assertSameAsLorem($target);
$this->assertEquals($mTime, $this->instance->filemtime($target), 'mtime was not preserved by move');
}

/**
Expand All @@ -271,11 +273,13 @@ public function testCopyOverwrite($source, $target) {
public function testMoveOverwrite($source, $target) {
$this->initSourceAndTarget($source, $target);

$mTime = $this->instance->filemtime($source);
$this->instance->rename($source, $target);

$this->assertTrue($this->instance->file_exists($target), $target . ' was not created');
$this->assertFalse($this->instance->file_exists($source), $source . ' still exists');
$this->assertSameAsLorem($target);
$this->assertEquals($mTime, $this->instance->filemtime($target), 'mtime was not preserved by move');
}

public function testLocal() {
Expand Down Expand Up @@ -485,6 +489,10 @@ public function testRenameDirectory() {
$this->instance->file_put_contents('source/test2.txt', 'qwerty');
$this->instance->mkdir('source/subfolder');
$this->instance->file_put_contents('source/subfolder/test.txt', 'bar');

$mTimeDirectory = $this->instance->filemtime('source');
$mTimeTestFile = $this->instance->filemtime('source/subfolder/test.txt');

$this->instance->rename('source', 'target');

$this->assertFalse($this->instance->file_exists('source'));
Expand All @@ -505,6 +513,8 @@ public function testRenameDirectory() {
$this->assertEquals('foo', $this->instance->file_get_contents('target/test1.txt'));
$this->assertEquals('qwerty', $this->instance->file_get_contents('target/test2.txt'));
$this->assertEquals('bar', $this->instance->file_get_contents('target/subfolder/test.txt'));
$this->assertEquals($mTimeDirectory, $this->instance->filemtime('target'), 'directory mtime was not preserved by rename');
$this->assertEquals($mTimeTestFile, $this->instance->filemtime('target/subfolder/test.txt'), 'file mtime was not preserved by rename');
}

public function testRenameOverWriteDirectory() {
Expand Down