mirror of
https://github.com/nextcloud/server.git
synced 2026-05-28 04:32:30 -04:00
test: improve notify tests for smb
Signed-off-by: Robin Appelman <robin@icewind.nl>
This commit is contained in:
parent
ea8a774a0a
commit
d1c6e82d77
1 changed files with 22 additions and 7 deletions
|
|
@ -105,6 +105,7 @@ class SmbTest extends \Test\Files\Storage\Storage {
|
|||
$this->instance->unlink('/renamed.txt');
|
||||
sleep(1); //time for all changes to be processed
|
||||
|
||||
/** @var IChange[] $changes */
|
||||
$changes = [];
|
||||
$count = 0;
|
||||
// wait up to 10 seconds for incoming changes
|
||||
|
|
@ -115,14 +116,23 @@ class SmbTest extends \Test\Files\Storage\Storage {
|
|||
}
|
||||
$notifyHandler->stop();
|
||||
|
||||
$expected = [
|
||||
new Change(IChange::ADDED, 'newfile.txt'),
|
||||
new RenameChange(IChange::RENAMED, 'newfile.txt', 'renamed.txt'),
|
||||
new Change(IChange::REMOVED, 'renamed.txt')
|
||||
];
|
||||
// depending on the server environment, the initial create might be detected as a change instead
|
||||
if ($changes[0]->getType() === IChange::MODIFIED) {
|
||||
$expected = [
|
||||
new Change(IChange::MODIFIED, 'newfile.txt'),
|
||||
new RenameChange(IChange::RENAMED, 'newfile.txt', 'renamed.txt'),
|
||||
new Change(IChange::REMOVED, 'renamed.txt')
|
||||
];
|
||||
} else {
|
||||
$expected = [
|
||||
new Change(IChange::ADDED, 'newfile.txt'),
|
||||
new RenameChange(IChange::RENAMED, 'newfile.txt', 'renamed.txt'),
|
||||
new Change(IChange::REMOVED, 'renamed.txt')
|
||||
];
|
||||
}
|
||||
|
||||
foreach ($expected as $expectedChange) {
|
||||
$this->assertTrue(in_array($expectedChange, $changes), 'Actual changes are:' . PHP_EOL . print_r($changes, true) . PHP_EOL . 'Expected to find: ' . PHP_EOL . print_r($expectedChange, true));
|
||||
$this->assertTrue(in_array($expectedChange, $changes), "Expected changes are:\n" . print_r($expected, true) . PHP_EOL . 'Expected to find: ' . PHP_EOL . print_r($expectedChange, true) . "\nGot:\n" . print_r($changes, true));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -141,7 +151,12 @@ class SmbTest extends \Test\Files\Storage\Storage {
|
|||
return false;//stop listening
|
||||
});
|
||||
|
||||
$this->assertEquals(new Change(IChange::ADDED, 'newfile.txt'), $result);
|
||||
// depending on the server environment, the initial create might be detected as a change instead
|
||||
if ($result->getType() === IChange::ADDED) {
|
||||
$this->assertEquals(new Change(IChange::ADDED, 'newfile.txt'), $result);
|
||||
} else {
|
||||
$this->assertEquals(new Change(IChange::MODIFIED, 'newfile.txt'), $result);
|
||||
}
|
||||
}
|
||||
|
||||
public function testRenameRoot() {
|
||||
|
|
|
|||
Loading…
Reference in a new issue